【问题标题】:rmarkdown to pdf: image in headers x marginrmarkdown 到 pdf:标题 x 边距中的图像
【发布时间】:2015-12-05 02:35:30
【问题描述】:

我是 Markdown 的新手,想在每一页上制作带有大学(和其他)标志的 pdf 文件。我尝试使用fancyheadings,但遇到了问题:

仅当我在文档中调用图像时,将图像放在标题中才有效,否则不会生成 pdf

注意:我还必须设置标题高度,否则第 2 页将无法使用 - \setlength{\headheight}{2.4 cm}。

有什么建议是问题所在? (在 Rstudio 中使用 knit,全部全新安装)

    ---
title: "Test"
author: "Author Name"
header-includes:
- \usepackage{fancyhdr}
- \usepackage{lipsum}
- \pagestyle{fancy}
- \rhead {\includegraphics{pictures/headers.pdf}}
- \fancyfoot[CO,CE]{}
- \setlength{\headheight}{2.4 cm}
- \fancyfoot[LE,RO]{\thepage}
geometry: top=2cm, bottom=3cm
output: pdf_document
abstract: This is a pandoc test . . .
---

\lipsum[1-20]
![](./pictures/headers.pdf)
this line needed or it doesnot make an output ???

\cleardoublepage
This is an R Markdown document. 

【问题讨论】:

  • 获取这段代码而不是图片也可以使它工作:{r, echo=FALSE} plot(cars)

标签: pdf rstudio r-markdown


【解决方案1】:

仅当文档中有图片时,includegraphics 才有效,可能是因为乳胶模板 (?)。

解决办法是创建一个缓存图片(1个白色像素图片),并在代码末尾调用:

【讨论】:

    猜你喜欢
    • 2020-05-07
    • 2015-06-06
    • 2021-12-06
    • 2017-08-28
    • 2017-10-05
    • 2014-11-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多