我该如何在Org-mode中使用csquotes进行LaTeX导出?

3
使用csquotes时,csquotes根据上下文添加引号。这是通过使用\enquote{text}来标记引用的方式实现的。
从Org-mode导出到LaTeX时,引号将被标记为``'',例如``text''
Org-mode能否导出带有\enquote标记的引用的LaTeX?
我在此处发现了一个相关功能的计划,但我不知道它是否已经实现。
另外,AUCTeX中集成了csquotes,当文档加载csquotes时,"会分别扩展为\enquote{}。虽然这不是我所要求的,但可能有一些代码片段可以设置Org-mode以导出带有\enquote标记的引用。
2个回答

5

@N.N.和其他人,org 8.0中的新的org-mode导出函数有一个名为org-export-smart-quotes-alist的列表。您可以将以下内容添加到init.el中,它将把常规的"双引号转换为enquote{},并将'单引号转换为enquote*{}

(add-to-list 'org-export-smart-quotes-alist 
             '("am"
               (primary-opening   :utf-8 "“" :html "“" :latex "\\enquote{"  :texinfo "``")
               (primary-closing   :utf-8 "”" :html "”" :latex "}"           :texinfo "''")
               (secondary-opening :utf-8 "‘" :html "‘" :latex "\\enquote*{" :texinfo "`")
               (secondary-closing :utf-8 "’" :html "’" :latex "}"           :texinfo "'")
               (apostrophe        :utf-8 "’" :html "’")))

警告:如果您希望此功能在org文件的语言中工作,请确保将org-export-default-language设置为"am"(或您选择在上面表单中使用的任何内容),或者在您的org文件顶部放置适当的#+LANGUAGE: am行。如果没有这样做,org导出器将不会调用上述函数。

4
按照这个线索一直追踪到版本7.7的更新日志(请参见版本7.7的标题),我发现他们添加了一个变量org-latex-export-quotes。我不太确定如何自定义它,但我怀疑最终可能需要像以下内容一样进行自定义:
原始内容(因为它只出现在7.7中而包含在内,我认为您正在运行的是7.6版本):
(defcustom org-export-latex-quotes
  '(("fr" ("\\(\\s-\\|[[(]\\)\"" . "«~") ("\\(\\S-\\)\"" . "~»") ("\\(\\s-\\|(\\)'" . "'"))
    ("en" ("\\(\\s-\\|[[(]\\)\"" . "``") ("\\(\\S-\\)\"" . "''") ("\\(\\s-\\|(\\)'" . "`")))
  "Alist for quotes to use when converting english double-quotes.

The CAR of each item in this alist is the language code.
The CDR of each item in this alist is a list of three CONS:
- the first CONS defines the opening quote;
- the second CONS defines the closing quote;
- the last CONS defines single quotes.

For each item in a CONS, the first string is a regexp
for allowed characters before/after the quote, the second
string defines the replacement string for this quote."

致:

(setq org-export-latex-quotes
  '(("en" ("\\(\\s-\\|[[(]\\)\"" . "\\enquote{") ("\\(\\S-\\)\"" . "}") ("\\(\\s-\\|(\\)'" . "`"))))

我刚刚测试了一下,它的表现符合预期。样本文件:

* test
this is a test of "this"

导出为(省略前言):

\section{test}
\label{sec-1}

this is a test of \enquote{this}

我不知道在7.6之内是否能够轻松地添加此功能,更容易的解决方案可能是进行升级。否则,在7.6中更简单的解决方案可能是创建自定义链接(参见:Org教程)。这样做速度可能不会很快,但可以通过7.6提供的功能来实现所需的结果。


很高兴它在新版本中得到了实现。我对elisp不是很擅长,所以无法确定这个diff是否可以轻松地回溯到7.6版本。 - N.N.
也许解决方案是安装emacs-snapshot?这将为您提供emacs 24 pretest(稳定版本),并将org升级到7.8。(请参见:http://www.mikeyboldt.com/2011/11/30/install-emacs-24-in-ubuntu/,其中有一个简单的步骤) - Jonathan Leech-Pepin
是否可以将此解决方案扩展到将“'test'”导出为“\enquote*{test}”? - N.N.
我不这么认为。逻辑是寻找开头的双引号、结尾的双引号和单引号。在开头和结尾的单引号之间没有区别,因此无法区分两端使用的字符。 - Jonathan Leech-Pepin
很遗憾。如果有解决方案可以添加这样的功能,我会提供赏金。 - N.N.
你最好在邮件列表上询问这个问题。这可能需要修改导出器才能将该更改合并进去。 - Jonathan Leech-Pepin

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接