使用R Markdown将Logo插入到beamer演示文稿中

8

我正在尝试使用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()

只是一个侧面的评论:如果你想用Markdown做演示文稿,为什么不直接使用像RemarkJS这样的工具呢? - rlegendi
它将使用R自动生成,它将提取数据,处理数据,创建图表和表格。 - ilya
哦,好的,谢谢你的澄清 :-) - rlegendi
2个回答

8
我找到了解决方案;在beamer手册中有另一种使用logo函数的方法,它可以很好地工作。
\pgfdeclareimage[height=0.2787cm, width=2.5cm]{logo}{logo.png}
\logo{\pgfuseimage{logo}}

0

我发现这个beamer教程非常有用。只需将以下内容添加到传递给YAML选项in_header的文件mystyle.tex中(如问题所示):

\usepackage{tikz}
\titlegraphic { 
\begin{tikzpicture}[overlay,remember picture]
\node[left=0.2cm] at (current page.30){
    \includegraphics[width=3cm]{Beamer-Logo}
};
\end{tikzpicture}
}

然后您可以玩弄节点参数来调整您的标志(Beamer-Logo)的位置。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接