簡體   English   中英

如何將內聯報價從 emacs 組織模式導出到 latex csquotes 語法?

[英]How to export inline quotations from emacs org mode to latex csquotes syntax?

我想將 org-document 中的內聯引號導出到 \enquote{} 命令。 csquotes package 然后確保在生成的 pdf 文檔中使用法語引號 « »。

我很清楚在此之前已經提出過這個問題- @Jonathan Leech-Pepin 和 @Christophe Poile 已經提出了解決方案。 我嘗試了所有建議的解決方案,但沒有成功。 我想避免(1)硬編碼正確的引號或(2)在我的組織文檔中使用 latex 命令。 OSX 10.15.5,emacs 26.2,組織 9.2.5。

組織文件 header:

#+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} 

導出的 latex 前導碼:

    % 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}

我曾經使用以下代碼將@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 

你不需要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到 select 法語風格的智能引號,然后讓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{打開和}關閉。 如果您想將 go 恢復為默認值,將其添加到列表的前面可以讓您快速擺脫它:

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

去掉第一個條目(添加的“fr”條目),允許看到默認的“fr”條目。 您可能應該執行Ch 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}

暫無
暫無

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

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