【问题标题】:Germany quotation marks broken in tinytex/rmarkdown - even when using package `csquotes`德国引号在 tinytex/rmarkdown 中损坏 - 即使使用包 `csquotes`
【发布时间】:2020-04-26 17:53:14
【问题描述】:

我想要什么:

我想在 MacOS (Catalina) 上通过 rmarkdown 和 tinytex 在我的 TeX-PDF 中添加德语引号。例如:

问题:

它曾经按照as proposed here 的指导方针工作。但是现在,它停止了工作。我只得到英文引号,但没有德文引号:

我试过了,没有成功:

  • 我更新了我的 R 包
  • 我更新了 TeX 包
  • 我检查了 TeX 包“csquotes”是否已安装
  • 我将语言从“de”更改为“de-De”

R 代码:

---
title: "German quotation marks"
output: 
    pdf_document:
        keep_tex: yes
lang: de-DE
header-includes:
    - \usepackage{csquotes}
---

"Das ist sehr schön", sagte sie. 

会话信息:

  • R 版本 3.6.0 (2019-04-26)
  • 平台:x86_64-apple-darwin15.6.0(64 位)
  • 运行于:macOS 10.15.2
  • tinytex v0.18
  • TeX 3.14159265(TeX Live 2019)
loaded via a namespace (and not attached):
 [1] compiler_3.6.0  htmltools_0.4.0 tools_3.6.0     yaml_2.2.0      Rcpp_1.0.3     
 [6] rmarkdown_2.0   knitr_1.26      xfun_0.11       digest_0.6.23   packrat_0.5.0  
[11] rlang_0.4.2     evaluate_0.14  

编辑

根据下面@RalfStubner 的建议,这是由上面的代码编译的 TeX 文件的最小可复制版本:

\documentclass[
  ngerman,
]{article}
\usepackage[shorthands=off,main=ngerman]{babel}


\title{German quotation marks}
\author{}
\date{\vspace{-2.5em}}

\begin{document}
\maketitle

``Das ist sehr schön'', sagte sie.

\end{document}

代码确实编译了 - 但问题仍然存在(没有德文引号,只有英文引号):

【问题讨论】:

  • 使用keep-tex: yes,您将获得一个可以独立检查的.tex 文件: 1. 验证编译.tex 是否会重现该问题。 2. 通过从.tex 文件中删除不需要重现问题的任何内容来生成minimal reproducible example。 3.Edit你的问题包括最小的.tex。
  • 顺便说一句,只有当.tex 文件中存在工作解决方案的最低限度时,这种减少才有意义:包babel 和csquotes 以及选项ngerman。跨度>

标签: r localization r-markdown quotes tinytex


【解决方案1】:

感谢@NMarkgraf,我刚刚了解到这个解决方案确实有效:

---
title: "German quotation marks"
output: 
    pdf_document:
        keep_tex: yes
lang: de-DE
csquotes: true  # THIS IS THE IMPORTANT LINE

header-includes:
    - \usepackage{csquotes}
---

"Das ist sehr schön", sagte sie. 

所以,重点是添加一个 YAML 变量 csquotes,其值为 yes。

【讨论】:

  • 有趣。您使用哪个pandoc 版本?你还需要header-includes吗?对我来说,csquotes: true 标头什么都不做。
  • 这很奇怪,对我来说也是新的。 pandoc 版本:rmarkdown::pandoc_version() [1] ‘2.9.1’。不是 100% 确信 RStudio 实际使用的是哪个版本,因为 RStudio 在某些版本中附带了一些 pandoc。
  • 这种方式找到的版本就是用于处理的版本。这比我使用的版本(2.5)要新得多,这可能解释了不同的行为。
【解决方案2】:

我也在处理这个问题。 YAML 描述 states 那

如果您的 LaTeX 模板或任何包含的头文件调用 [csquotes] 包,pandoc 将自动检测到这一点并使用 \enquote{...} 引用文本。

所以你实际上只需要添加

csquotes: true  # THIS IS THE IMPORTANT LINE

无需添加

    - \usepackage{csquotes}

至少这对我有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-02-06
    • 1970-01-01
    • 1970-01-01
    • 2016-10-07
    • 1970-01-01
    • 1970-01-01
    • 2016-08-06
    • 2016-04-14
    相关资源
    最近更新 更多