【发布时间】:2015-06-06 00:04:28
【问题描述】:
我正在尝试创建一个 rmarkdown 文档。我终于找到了解决这个问题的方法,尽管它花了相当长的时间。我想做的最后一件事是将图像添加到我的 pdf 文档的标题页。
我遇到的麻烦是我的标题页是由 YAML 的顶部定义的。以下是我的example.Rmd 文件的内容。我使用 RStudio 中的 Knit PDF 按钮将其转换为 PDF。
---
title: "This is a my document"
author: "Prepared by: Dan Wilson"
date: '`r paste("Date:",Sys.Date())`'
mainfont: Roboto Light
fontsize: 12pt
documentclass: report
output:
pdf_document:
latex_engine: xelatex
highlight: tango
---
This is an R Markdown document. 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. You can embed an R code chunk like this:
```{r}
summary(cars)
```
You can also embed plots, for example:
```{r, echo=FALSE}
plot(cars)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
如果有人有一些提示可以让我在标题上方放置图片 (logo.png),那就太好了。
【问题讨论】:
-
不是因为我试图复制它。我正在尝试 PDF 而不是 Beamer 演示文稿,所以不太清楚如何调整代码以适应。将进行搜索以查看是否可以找到 PDF 的类似内容。
-
原来我需要重新排序 YAML 语句,将
includes放在pdf_document:行之后。所以我现在在.tex 文件中有in_header: mystyle.tex和{\includegraphics{tdclogo.png}}。这会引发错误! LaTeX Error: Missing \begin{document}.即使我将\begin{document}放在那里,我也会收到更多错误消息。有什么想法吗? -
我能够解决它。我不是 Markdown 或 Latex 的专家,所以我的解决方案可能有点难看,但它确实有效。我会在接下来的一两天内发布。如果我忘记了,请发布提醒。
-
@Dan Hi Dan,我现在正在使用 Rmarkdown 编写报告,并且面临同样的问题?你能发布你是如何解决这个问题的吗?谢谢,非常感谢
标签: r pdf rstudio r-markdown