使用R Markdown将徽标插入到投影仪演示中 [英] Inserting logo into beamer presentation using R Markdown

查看:117
本文介绍了使用R Markdown将徽标插入到投影仪演示中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Rmarkdown将徽标插入投影仪外观,并且\logo{\includegraphics[height=1cm,width=3cm]{logo.png}}中的尺寸控件似乎不起作用,无论我在此处输入什么值,图像始终具有相同的尺寸.除了手动修改图片还有其他建议吗?

I am trying to insert logo into beamer presenation using Rmarkdown, and it looks like size controls in \logo{\includegraphics[height=1cm,width=3cm]{logo.png}} do not work, no matter what values I put there, image is always of the same size. Any suggestions besides modifying image manually?

---
title: "Presentation"
author: "Author"
output:
  beamer_presentation:
    includes:
      in_header: mystyle.tex

---

## R Markdown

This is an R Markdown presentation. Markdown is a simple formatting
syntax for authoring HTML, PDF, and MS Word documents. For more
details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that
includes both content as well as the output of any embedded R code
chunks within the document.

## Slide with Bullets

- Bullet 1
- Bullet 2
- Bullet 3

## Slide with R Code and Output

```{r}
summary(cars)
```

## Slide with Plot

```{r, echo=FALSE}
plot(cars)
```

这是mystyle.tex

This is mystyle.tex

\logo{\includegraphics[height=1cm,width=3cm]{logo.png}}
\usetheme{Madrid}
\usefonttheme{serif}
\institute{Institute}
\setbeamertemplate{navigation symbols}{}

更新:快速解决-仅修改图像将不起作用-图像丑陋且像素化.简单地转换为pdf也不起作用,因此我使用了以下R代码来创建pdf并将其用于\ logo {\ includegraphics {logo.pdf}}

UPDATE: Quick work around - simply modifying image will not work - image is ugly and pixelated. Simply converting to pdf also didn't work well, so I used following R code to create pdf and use it in \logo{\includegraphics{logo.pdf}}

library(png)
library(grid)
img <- readPNG('logo.png')
img <- rasterGrob(img, interpolate=TRUE)
pdf(file = 'logo.pdf', width = 1, height = 0.25)
grid.newpage()
grid.raster(img)
dev.off()

推荐答案

我找到了解决方案;在投影机手册中,还有另一种使用徽标功能的方法,它可以正常工作.

I found solution; in beamer manual there is another way of using logo function and it works fine.

\pgfdeclareimage[height=0.2787cm, width=2.5cm]{logo}{logo.png}
\logo{\pgfuseimage{logo}}

这篇关于使用R Markdown将徽标插入到投影仪演示中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆