0

I use Bookdown with a pdf output. In my document, I include images generally using the method \![\label{imagelabel}image title](image_path.png).

I would like to know if it is possible, in addition to a title, to add comments to the image. I would like to see "Figure #: Image Title. My comments (e.g. this figure shows that...)", but that the comments are not displayed in the List of Figures.

Is this possible and if so, how?

Thank you in advance!

Siong Thye Goh
  • 3,518
  • 10
  • 23
  • 31
GagGeo
  • 1
  • 1

1 Answers1

0

I don't use bookdown, but it's a close relative of pdf_document in rmarkdown. This works there:

---
title: "image.Rmd"
output: 
  pdf_document:
    keep_tex: true
    toc: true
---

```{r}
knitr::opts_chunk$set(dev='pdf')
```

\newcommand{\comment}[1]{}

\listoffigures

```{r theplot,fig.show="hide"}
plot(rnorm(1000))
```

![\label{thefig}This is the caption\comment{this is the comment}](image_files/figure-latex/theplot-1.pdf)

Interestingly, the comment doesn't show up in the .tex file, it was removed by Pandoc. If you actually do want to see the comment in the output, you can turn it on using something like

\newcommand{\comment}[1]{\textit{#1}}

in place of the definition above.

user2554330
  • 37,248
  • 4
  • 43
  • 90
  • Hello, Thank you very much for your answer. I have tried to do what you propose, both in a `pdf_document` `rmarkdown` and my `bookdown` document. For `rmarkdown` it happens that I get the same result (i.e. the comment continues to appear in the list of figure). In `bookdown` however, the figure title (just like the `\label{}`) no longer works (no more display, neither in the text, nor in the list of figures). – GagGeo Aug 20 '19 at 14:17
  • I think you will need to post a reproducible example if you want any more help. – user2554330 Aug 20 '19 at 15:57