Inserting title page with image in Rmarkdown to render a pdf document

試著忘記壹切 提交于 2020-01-10 18:56:29

问题


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

![Caption](folder/image.png)

\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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!