hadley / ggplot2-book

ggplot2: elegant graphics for data analysis
https://ggplot2-book.org/
1.57k stars 684 forks source link

underscores in figure captions break latex output #319

Closed stevelinberg closed 1 year ago

stevelinberg commented 2 years ago

When rendering to latex, the caption for figure 17.1 fails to render because it contains unescaped underscores (in "facet_grid()" and "facet_wrap()"). A fix is to create the caption above the block and reference it in the figure, which causes it to be correctly escaped when rendering to either latex or HTML, as described in the "Text References" section of Authoring Books with R Markdown.

Also submitting a PR with this fix.

djnavarro commented 1 year ago

closing the issue per discussion in #320.