我正在嘗試創建一個rmarkdown文檔。我終於想出了一個辦法來解決這個問題,儘管它花了相當長的一段時間。我希望能夠做的最後一件事是將圖像添加到我的PDF文檔的標題頁面。在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)放在我的標題上面,那會很棒。
這是否幫助? http://stackoverflow.com/questions/25890939/inserting-logo-into-beamer-presentation-using-r-markdown – tonytonov 2015-04-01 12:56:41
不是我試圖複製它。我正在嘗試PDF而不是Beamer Presentation,所以我不太清楚如何調整代碼以適應。將有一個搜索,看看我是否可以找到PDF類似的東西。 – Dan 2015-04-07 09:33:07
原來我需要重新排列YAML語句,將'includes'放在'pdf_document:'行後面。所以我現在在.tex文件中有'in_header:mystyle.tex'和'{\ includegraphics {tdclogo.png}}'。這會拋出一個錯誤'! LaTeX錯誤:缺少\ begin {document}。即使我把'\ begin {document}'放在那裏,我也會得到更多的錯誤信息。有什麼想法嗎? – Dan 2015-04-07 10:28:05