如何在标题中添加引号(bookdown)

How to add quotation marks in caption (bookdown)

我在使用 bookdown 的字幕中遇到引号问题。以下 rmarkdown 文档说明了该问题。

---
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.\'\'')
```

上面的代码对 html 和 latex 都正确编译(最后一个 table 除外,它对 latex 正确编译,但不是 html)。但是,将文档的 body 复制到随 bookdown 提供的“A Minimal Book Example”中并没有排版正确的引号。我尝试同时使用 xelatex 和 pdflatex 来编译文档。对于 xelatex,它给出以下内容:

pdflatex 给出:

正如 bookdown 作者所指出的,Yihui Xie, when writing long captions, or captions with special characters (e.g. quotation marks), authors should use text references.

在上面的例子中,它看起来像这样:

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)')
```