我正在尝试使用Rmarkdown将标志插入到beamer演示文稿中,似乎在\logo{\includegraphics[height=1cm,width=3cm]{logo.png}}
中的尺寸控制无效,无论我放什么值,图像始终是相同大小。除了手动修改图像之外,还有什么建议吗?
---
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。
\logo{\includegraphics[height=1cm,width=3cm]{logo.png}}
\usetheme{Madrid}
\usefonttheme{serif}
\institute{Institute}
\setbeamertemplate{navigation symbols}{}
更新:快速解决方法 - 仅修改图像并不起作用 - 图像会变得模糊且像素化。将其转换为pdf也效果不佳,因此我使用以下R代码创建了pdf并在\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()