Rmarkdown Table of Contents on page 2 and cross referencing

626 Views Asked by At

I would like my pdf output to satisfy 3 conditions:

  1. Title page on page 1
  2. Table of contents on page 2
  3. Cross reference figures and tables.

I am able to do 1 and 2 with pdf_document but as explained here, pdf_document2 is required for 3.

How can I build a pdf document that can satisfy these 3 conditions? I would like to avoid setting my document class to a report if possible.

This answer is the closest I have found.

Sample code:

---
title: "Untitled"
output: 
  pdf_document:
    number_sections: true
---

\newpage
\tableofcontents
\listoffigures
\listoftables
\newpage


```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

Figure (...) below is a 

```{r pressure}
plot(pressure)
```
1

There are 1 best solutions below

0
On

You just need to add \ref{}

## R Markdown

Figure (\ref{fig:pressure}) below is a ...

```{r pressure}
plot(pressure)
```