问题
In Rmarkdown, the following sets the context to generate the pdf document:
---
title: "My Report"
author: NDE
output:
pdf_document:
fig_caption: true
toc: true
highlight: kate
---
I want to insert a title page with an image, title before table of contents gets printed. Is there a way I can achieve it?
回答1:
For me it worked using LaTeX commands \clearpage
and \tableofcontents
:
---
title: "image before toc"
output: pdf_document
---
\centering

\raggedright
\clearpage
\tableofcontents
# header 1
lore ipsum
## header 2
lore ipsum
## header 3
lore ipsum
# header 4
If you want the table of contents on the title page, just leave \clearpage
command out.
I included \centering
and \raggedright
commands to center the image on the title page but not the text.
Hope that works for you.
来源:https://stackoverflow.com/questions/28962651/inserting-title-page-with-image-in-rmarkdown-to-render-a-pdf-document