在rmarkdown的页眉和页脚中添加图像,并以pdf格式输出
我试图在RStudio服务器中创建带有自定义标题的pdf文档,但latex在编译时遇到问题,因此我没有得到任何输出 我尝试按照中提供的代码在标题中添加图像,但这似乎不起作用在rmarkdown的页眉和页脚中添加图像,并以pdf格式输出,r,r-markdown,pdflatex,rstudio-server,R,R Markdown,Pdflatex,Rstudio Server,我试图在RStudio服务器中创建带有自定义标题的pdf文档,但latex在编译时遇到问题,因此我没有得到任何输出 我尝试按照中提供的代码在标题中添加图像,但这似乎不起作用 --- title: '' output: pdf_document: latex_engine: pdflatex classoption: landscape geometry: left=0.5in,right=0.5in,top=0.5in,bottom
---
title: ''
output:
pdf_document:
latex_engine: pdflatex
classoption: landscape
geometry: left=0.5in,right=0.5in,top=0.5in,bottom=0.5in
header-includes:
-\usepackage{graphicx}
-\usepackage{fancyhdr}
-\pagestyle{fancy}
-\fancyhead[R]{\includegraphics[width=3cm]{Capture.JPG}}
-\fancyfoot[R]{\includegraphics[width=3cm]{Capture2.JPG}}
-\renewcommand{\headrulewidth}{0.4pt}
-\renewcommand{\footrulewidth}{0.4pt}
---
我得到的错误是:
! LaTeX Error: Missing \begin{document}.
Error: Failed to compile Main_pdf.tex. See Main_pdf.log for more info.
In addition: There were 50 or more warnings (use warnings() to see the first 50)
Execution halted
我试图解决的问题之一是指定pdf latex位置的路径,但这不起作用。YAML在格式化方面可能会相当挑剔。在这种情况下,需要在
-
和以下文本之间留出一个空格:
---
title: ''
output:
pdf_document:
latex_engine: pdflatex
keep_tex: yes
classoption: landscape
geometry: left=0.5in,right=0.5in,top=0.5in,bottom=0.5in
header-includes:
- \usepackage{graphicx}
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyhead[R]{\includegraphics[width=3cm]{Capture.JPG}}
- \fancyfoot[R]{\includegraphics[width=3cm]{Capture2.JPG}}
- \renewcommand{\headrulewidth}{0.4pt}
- \renewcommand{\footrulewidth}{0.4pt}
---
顺便说一句,
keep_-tex:yes
是我用来调试类似问题的工具。然而,在这种特殊情况下,这是不必要的,因为.tex
文件仍然存在以供检查,它在序言中显示了文字-
s。YAML在格式化方面可能相当挑剔。在这种情况下,需要在-
和以下文本之间留出一个空格:
---
title: ''
output:
pdf_document:
latex_engine: pdflatex
keep_tex: yes
classoption: landscape
geometry: left=0.5in,right=0.5in,top=0.5in,bottom=0.5in
header-includes:
- \usepackage{graphicx}
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyhead[R]{\includegraphics[width=3cm]{Capture.JPG}}
- \fancyfoot[R]{\includegraphics[width=3cm]{Capture2.JPG}}
- \renewcommand{\headrulewidth}{0.4pt}
- \renewcommand{\footrulewidth}{0.4pt}
---
顺便说一句,keep_-tex:yes
是我用来调试类似问题的工具。然而,在这种特殊情况下,它是不必要的,因为.tex
文件仍然存在以供检查,显示了序言中的文字-
s