LuaTeX 和破折號

LuaTeX 和破折號

LuaLaTeX 不會插入長破折號,除非三重破折號周圍有空格。當使用 unicode em dash 或明確使用巨集時,它運作得很好\textemdash

這是一個 MWE:

\documentclass{article}

\begin{document}

\begin{enumerate}
  \item en--dash
  \item em---dash
  \item em --- dash space
\end{enumerate}
\begin{enumerate}
  \item en–dash unicode
  \item em—dash unicode
  \item em — dash space unicode
\end{enumerate}
\begin{enumerate}
  \item en\textendash{}dash macro
  \item em\textemdash{}dash macro
  \item em \textemdash{} dash space macro
\end{enumerate}

\end{document}

其產生:

缺少破折號

使用 LuaTeX 編譯,版本 1.07.0 (TeX Live 2018)

問題是:

我想知道為什麼沒有周圍空格的長破折號連字在 PDF 輸出中不會呈現為長破折號。對我來說這似乎是個錯誤。我該如何修復它?

答案1

您可以\automatichyphenmode=1在序言中加入:

\documentclass{article}
\automatichyphenmode=1
\begin{document}

\begin{enumerate}
  \item en--dash
  \item em---dash
  \item em --- dash space
\end{enumerate}
\begin{enumerate}
  \item en–dash unicode
  \item em—dash unicode
  \item em — dash space unicode
\end{enumerate}
\begin{enumerate}
  \item en\textendash{}dash macro
  \item em\textemdash{}dash macro
  \item em \textemdash{} dash space macro
\end{enumerate}

\end{document}

程式碼的輸出

答案2

更新 3/2019

該錯誤將在下一個 luaotfload 更新中解決

==================================================== = ===========

稍微擴展一下艾倫的答案:

恕我直言,這顯然是從上下文匯入的字體載入器中的錯誤(如果您設定,您會在上下文中看到相同的錯誤\automatichyphenmode=0)。只有當字體使用以下方式呈現時才會發生這種情況mode=node

\documentclass{article}

\begin{document}
\font\test={file:lmroman10-regular.otf:mode=node;+tlig}
\test

A---B

\font\test={file:lmroman10-regular.otf:mode=base;+tlig}
\test

A---B
\end{document}

在此輸入影像描述

問題的根源是恕我直言\automatichyphenmode=0,luatex 首先將最後一個連字符轉換為任意連字符以允許換行:

A---B  ---> A--\discretionary{-}{}{-}B

設定好該行後,必須再次將其轉換回---,而此步驟似乎失敗了。

該問題已被報告,但尚不清楚是否會解決。

\automatichyphenmode=1在許多情況下,透過不將連字符轉換為任意字元來避免該問題。因此,您應該意識到這樣的事實:在許多情況下這會抑制換行:

\documentclass[parskip=half-]{scrartcl}
\begin{document}


\parbox[t]{1pt}{%
\textbf{0}

\automatichyphenmode=0
A-B

A--B

A---B

-begin

A!-B}
\hspace{2cm}
\parbox[t]{1pt}{\automatichyphenmode=1
\textbf{1}

A-B

A--B

A---B

-begin

A!-B}

\end{document}

在此輸入影像描述

相關內容