簡體   English   中英

如何在Org-mode中使用帶有LaTeX導出的csquotes?

[英]How can I use csquotes with LaTeX export in Org-mode?

使用csquotes時 ,csquotes根據上下文添加引號。 這是通過使用\\enquote宏標記引號來完成的,即\\enquote{text}

當從Org模式導出到LaTeX時,引號被標記為``'' ,例如``text''

組織模式是否可以使用\\enquote標記的引號導出到LaTeX?

我找到了http://comments.gmane.org/gmane.emacs.orgmode/43689這樣的功能正在計划中,但我不明白它是否已實現。


在相關的說明中,在AUCTeX中集成了csquotes 集成是當文檔加載csquotes然后分別擴展為\\enquote{} 。這不是我要求的,但可能有一些代碼可能有興趣設置組織模式以導出標記的引號通過\\enquote

@NN和其他人,組織8.0中的新組織模式導出功能有一個名為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-export-default-language設置為"am" (或者您選擇在上面的表單中使用的任何org-export-default-language ),或者放置相應的#+LANGUAGE: am行在org文件的頂部。 如果不這樣做,組織出口商將不會調用上述內容。

在該線程結束之后,然后查看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提供的功能中提供所需的結果。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM