【问题标题】:How to export inline quotations from emacs org mode to latex csquotes syntax?如何将内联引号从 emacs org 模式导出为乳胶 csquotes 语法?
【发布时间】:2020-07-07 19:06:44
【问题描述】:

我想将 org-document 中的内联引用导出到 \enquote{} 命令。然后,csquotes 包会确保在生成的 pdf 文档中使用法语引号 « »。

我很清楚在here 之前已经提出过这个问题——@Jonathan Leech-Pepin 和@Christophe Poile 已经提出了解决方案。我尝试了所有建议的解决方案,但没有成功。我想避免(1)硬编码正确的引号或(2)在我的组织文档中使用 latex 命令。 OSX 10.15.5、emacs 26.2、org 9.2.5。

组织文件标题:

#+Title: GS
#+AUTHOR: HDV
#+SEQ_TODO: 
#+TAGS: 
#+STARTUP: indent
#+LANGUAGE: fr
#+LaTeX_CLASS: article
#+LATEX_CLASS_OPTIONS: [a4paper,11pt,twoside]
#+LATEX_HEADER: \usepackage[utf8]{inputenc}
#+LATEX_HEADER: \usepackage{ae,lmodern}
#+LATEX_HEADER: \usepackage[french]{babel}
#+LATEX_HEADER: \usepackage[T1]{fontenc}
#+LATEX_HEADER: \usepackage{graphicx} 
#+LATEX_HEADER: \usepackage[babel=true]{csquotes} 

导出的乳胶序言:

    % Created 2020-07-07 Tue 20:45
% Intended LaTeX compiler: pdflatex
\documentclass[a4paper,11pt,twoside]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage{ae,lmodern}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx} 
\usepackage[babel=true]{csquotes} 
\author{}
\date{\today}
\title{}
\hypersetup{
 pdfauthor={},
 pdftitle={},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 26.2 (Org mode 9.2.5)}, 
 pdflang={French}}
\begin{document}

【问题讨论】:

    标签: emacs latex org-mode


    【解决方案1】:

    我曾经使用以下代码将@xxx@ 转换为\hl{xxx}(使用灵魂LaTeX 包)。您也许可以调整它以将“xxx”转换为 \enquote{xxx}?

    ** convert @highlighted@ text on export to ~\hl{highlighted}~
    #+begin_src emacs-lisp
      (defun esf/latex-filter-highlight (text backend info)
        "Convert @...@ to \hl{...} in LaTeX export."
        (when (org-export-derived-backend-p backend 'latex)
          (replace-regexp-in-string "@\\([^@]+\\)@" "\\\\hl{\\1}" text)))
    
      (add-to-list 'org-export-filter-plain-text-functions
                   'esf/latex-filter-highlight)
    #+end_src 
    

    【讨论】:

      【解决方案2】:

      您不需要csquotes\enquote{} 来获取guillemets;在 Org 模式下,有开箱即用的 smart quote 支持。以下就足够了:

      #+OPTIONS: ':t
      #+LANGUAGE: fr
      #+LATEX_HEADER: \usepackage[french]{babel}
      
      * foo
      
      As somebody once said:
        
      "You cannot explain anything to a stone."
      

      你打开smart quotes,将#+LANGUAGE设置为fr,选择法式智能引号,然后让babel搞定。生成的 TeX 文件如下所示(仅显示重要部分):

      ...
      \usepackage[french]{babel}
      ...
      \begin{document}
      
      ...
      
      \section{foo}
      \label{sec:orgd0ec1fc}
      
      As somebody once said:
      
      \og You cannot explain anything to a stone.\fg{}
      \end{document}
      

      如果你真的想要\enquote,你可以修改org-export-smart-quotes-alist的值。我认为最好的方法是复制fr 的当前部分,根据您的目的对其进行修改,并将其添加到 alist 的开头,它将遮蔽现有条目:

        (setq fr-quotes '("fr"
                  (primary-opening :utf-8 "« " :html "« " :latex "\\enquote{" :texinfo "@guillemetleft{}@tie{}")
                  (primary-closing :utf-8 " »" :html " »" :latex "}" :texinfo "@tie{}@guillemetright{}")
                  (secondary-opening :utf-8 "« " :html "« " :latex "\\\enquote{" :texinfo "@guillemetleft{}@tie{}")
                  (secondary-closing :utf-8 " »" :html " »" :latex "\\}" :texinfo "@tie{}@guillemetright{}")
                  (apostrophe :utf-8 "’" :html "’"))
      
        (add-to-list 'org-export-smart-quotes-alist fr-quotes)
      

      如您所见,我将LaTeX 的开头和结尾引号更改为使用\enquote{ 打开和} 关闭。将其添加到列表的最前面可以让您快速摆脱它,如果您想返回默认值:

      (setq org-export-smart-quotes-alist (cdr org-export-smart-quotes-alist))
      

      去掉第一个条目(添加的“fr”条目),允许看到默认的“fr”条目。您可能应该使用C-h v org-export-smart-quotes-alist 并仔细查看它的值。

      那么Org模式文件就变成了:

      #+OPTIONS: ':t
      #+LANGUAGE: fr
      #+LATEX_HEADER: \usepackage[french]{babel}
      #+LATEX_HEADER: \usepackage[babel=true]{csquotes}
      
      * foo
      
      As somebody once said:
        
      "You cannot explain anything to a stone."
      

      生成的 tex 文件如下所示(同样,仅显示重要部分):

      ...
      \usepackage[french]{babel}
      \usepackage[babel=true]{csquotes}
      ...
      \begin{document}
      ...
      \section{foo}
      \label{sec:orgb8fcb36}
      
      As somebody once said:
      
      \enquote{You cannot explain anything to a stone.}
      \end{document}
      

      【讨论】:

        猜你喜欢
        • 2023-04-09
        • 1970-01-01
        • 2014-01-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-11
        相关资源
        最近更新 更多