I am writing my thesis with bookdown. I want to include a List of Figures, but I don't want to include the whole of each figure's caption. My thought was to give each figure one caption that appears in the lof
and a second caption that doesn't. I have tried to do this using fig.subcap
but this doesn't give a second caption, I presume because it needs a second figure to exist.
In the example below I want to create a figure that has the caption "My Main Caption. Here is more detail"
, but in the lof
just has: "My Main Caption"
.
---
title: "Queries"
header-includes:
- \usepackage{subfig}
output:
bookdown::pdf_book:
toc: true
lof: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(ggplot2)
```{r irisfig, fig.cap='My Main Caption. Here is more detail'}
ggplot2::ggplot(iris, aes(Sepal.Length, Sepal.Width))+
geom_point()
This doesn't work:
```{r irisfig2, fig.cap='My Main Caption.', fig.subcap= c('Here is more detail')}
ggplot2::ggplot(iris, aes(Sepal.Length, Sepal.Width))+
geom_point()
The LaTeX command \caption
offers an optional argument to specify a shorter caption for the toc, in the form \caption[Short caption]{Long caption}
. This option is accessible through fig.scap
in the header:
```{r irisfig2, echo=F, fig.cap='My Main Caption PLUS More Detail', fig.scap='My Main Caption', out.extra=''}
ggplot2::ggplot(iris, aes(Sepal.Length, Sepal.Width))+
geom_point()
```
Which yields latex code:
\begin{figure}
\includegraphics{test9_files/figure-latex/irisfig2-1}
\caption[My Main Caption]{My Main Caption PLUS More Detail}\label{fig:irisfig2}
\end{figure}