使用 pandoc 時取得標點符號前的 babel-french 自動空格

使用 pandoc 時取得標點符號前的 babel-french 自動空格

我正在嘗試pandoc(使用 LaTeX 將 Markdown 轉換為 PDF)生成遵循法語排版規則的 PDF不可破壞的空間

這裡的建議似乎不起作用,例如pandoc test.md -V lang:fr-FR -o test.pdfpandoc test.md -M lang:fr-FR -o test.pdf

我缺什麼?我pandoc在 Ubuntu 16.04 上使用2.7.3。目標是從 Markdown 文件開始,text.md例如a;b並在輸出中獲取 PDF 文件,其中顯示a ;b空格不可破壞的位置。

答案1

LaTeX 輸出的預設pandoc範本似乎強制包含shorthands=offbabel選項中。事實上,運行後pandoc -D latex >default.latex,您應該會看到:

\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere

(...)

$if(lang)$
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}
$if(babel-newcommands)$
  $babel-newcommands$
$endif$
\else

(...)

\end{document}

這個shorthands=off選項會殺死你想要的功能。您可以透過以下方式修復此問題:

  1. 在名為 的檔案中取得預設的 LaTeX 範本mytemplate.latex

    pandoc -D latex >mytemplate.latex
    
  2. 在 中mytemplate.latex,使用您喜歡的文字編輯器刪除shorthands=off傳遞給 的選項babel

  3. 編譯:

    pandoc -f markdown -t latex -M lang:fr-FR --template=mytemplate -o test.pdf test.md
    

如果mytemplate.latex在目前目錄或在~/.pandoc/templates.

相關內容