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

11,658

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.

Share:
11,658

Related videos on Youtube

Next Door Engineer
Author by

Next Door Engineer

Amateur Engineer and Data Analytics Professional.

Updated on September 23, 2022

Comments

  • Next Door Engineer
    Next Door Engineer over 1 year

    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?

    • user3498523
      user3498523 over 8 years
      Check answer here is a solution using LaTeX
  • Anna Dunietz
    Anna Dunietz almost 9 years
    @Next Door Engineer: Were you ever able to figure this out?
  • Next Door Engineer
    Next Door Engineer almost 9 years
    @Anna, Nope. Haven't gotten to get this route to work.