这个答案显示一个间距合适的破折号。我想知道,如果使用 lualatex 及其所有功能,是否可以自动转换---
为\dash
上述链接中的命令?(例如使用切换\autodashON
和\autodashOFF
)
答案1
您可以---
在输入中替换\dash
\documentclass{article}
\DeclareRobustCommand\dash{%
\unskip\nobreak\thinspace\textemdash\allowbreak\thinspace\ignorespaces}
\directlua{
function dashes(s)
return string.gsub(s,'[-][-][-]','\string\\dash ')
end}
\def\autodashON{\directlua{%
luatexbase.add_to_callback("process_input_buffer",dashes,"spaced em dash")%
}}
\def\autodashOFF{\directlua{%
luatexbase.remove_from_callback("process_input_buffer","spaced em dash")%
}}
\setlength\parskip{20pt}
\setlength\parindent{0pt}
\begin{document}
One---two three --- four five.
One---two three --- four five.
One---two three --- four five.
One---two three --- four five.
\autodashON
One---two three --- four five.
One---two three --- four five.
One---two three --- four five.
One---two three --- four five.
\autodashOFF
One---two three --- four five.
One---two three --- four five.
One---two three --- four five.
One---two three --- four five.
\end{document}