我正在尝试使用Rmarkdown在beamer presenation中插入徽标,看起来\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()
答案 0 :(得分:5)
我找到了解决方案;在beamer手册中有另一种使用徽标功能的方法,它工作正常。
\pgfdeclareimage[height=0.2787cm, width=2.5cm]{logo}{logo.png}
\logo{\pgfuseimage{logo}}