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

前端 未结 1 1378
悲&欢浪女
悲&欢浪女 2020-12-31 11:23

In Rmarkdown, the following sets the context to generate the pdf document:

---
title: \"My Report\"
author: NDE
output:
  pdf_document:
  fig_caption: true
          


        
相关标签:
1条回答
  • 2020-12-31 11:35

    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.

    0 讨论(0)
提交回复
热议问题