如何使用 pandoc 获取本地化的引号?

How can I get localized quotation marks with pandoc?

我想得到像这些“...”这样的引号,但是当我用 Pandoc 处理我的降价文本时,它给了我“...”。它可能归结为如何让 Pandoc 使用语言环境设置的问题?这是我的命令行:

pandoc -o out.pdf  -f markdown -t latex in.md

Pandoc 当前(2015 年 11 月)only generates English type quotes。但是你有两个选择:

  1. 您可以使用 --no-tex-ligatures 选项关闭 LaTeX 输出默认打开的 --smart typography 选项。然后使用您想要的正确的 unicode 字符(例如 „...”)并使用支持 unicode(lualatexxelatex)的 --latex-engine

  2. 您可以在 Pandoc LaTeX template. From the README:

    中使用 \usepackage[danish=quotes]{csquotes} 或类似的

    If the --smart option is specified, pandoc will produce typographically correct output, converting straight quotes to curly quotes, --- to em-dashes, -- to en-dashes, and ... to ellipses. Nonbreaking spaces are inserted after certain abbreviations, such as “Mr.”

    Note: if your LaTeX template calls for the csquotes package, pandoc will detect this automatically and use \enquote{...} for quoted text.

尽管 already provided an answer, I would like to add, that nowadays it's possible to simply include what you need in (for example) your yaml metadata block,因此不再需要创建自己的模板。示例:

---
title: foo
author: bar
# other stuff
header-includes:
    - \usepackage[german=quotes]{csquotes}
---

# contents

您可能想要为整个文档指定语言,这样它不仅会影响引号,还会影响连字、不可分割的空格和其他区域设置细节。

为此,您可以指定 lang 选项。来自 pandoc's manual:

lang: identifies the main language of the document, using a code according to BCP 47 (e.g. en or en-GB). For some output formats, pandoc will convert it to an appropriate format stored in the additional variables babel-lang, polyglossia-lang (LaTeX) and context-lang (ConTeXt).

此外,同一手册指出:

if your LaTeX template or any included header file call for the csquotes package, pandoc will detect this automatically and use \enquote{...} for quoted text.

在我看来,确保引号本地化的最佳方法是添加:

---
lang: fr-FR
header-includes:
- \usepackage{csquotes}
---

或者更好的是,编辑 pandoc 默认模板

pandoc -D latex > ~/.pandoc/templates/default.latex

并永久添加 \usepackage{csquotes}