I am having an issue with quotation marks inside captions using bookdown
. The following rmarkdown
doc illustrates the issue.
---
title: "testdoc"
author: "Dayne Filer"
date: "10/21/2020"
output:
pdf_document: default
html_document: default
---
In the main document, "quotation marks" are appropriately typeset.
```{r}
knitr::kable(matrix(1:2), caption = "In a caption, \"they are not\".")
```
```{r}
knitr::kable(matrix(1:2), caption = '"I did try some alternatives...".')
```
```{r}
knitr::kable(matrix(1:2), caption = '\`\`this works for latex, but not html.\'\'')
```
The above compiles correctly for both html and latex (except the last table, which compiles correctly for latex, but NOT html). However, copying the body of the document into "A Minimal Book Example" provided with bookdown
does not typeset the correct quotation marks. I have tried using both xelatex and pdflatex to compile the documents. For xelatex, it gives the following:
pdflatex gives:
As pointed out by the bookdown
author, Yihui Xie, when writing long captions, or captions with special characters (e.g. quotation marks), authors should use text references.
In the above example, it would look like this:
In the main document, "quotation marks" are appropriately typeset.
And when using text references,
(ref:tabCap) "quotation" marks are properly formatted.
```{r}
knitr::kable(matrix(1:2), caption = '(ref:tabCap)')
```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With