在一个2014 年 XeTeX 列表帖子,大师 David Carlisle 给出了以下代码,用于获得与命令相同的结果\showhyphens
,但使用 XeTeX 中的 OpenType 字体:
\catcode`\@=11
\def\showhyphenspace#1 {%
\ifx\valign#1\valign\else
#1\vadjust{\penalty\@ne} \expandafter\showhyphenspace
\fi}
\def\showhyphens#1{{%
\showboxbreadth\maxdimen
\showboxdepth\maxdimen
\pretolerance\m at ne\tolerance\m at ne
\setbox2\hbox{}%
\setbox0\vbox{%
\pretolerance\m at ne
\tolerance\m at ne\hbadness\z@
\parfillskip\z at skip
\hsize1sp
\noindent
\hskip\z@
\hfuzz\maxdimen
\hbadness\maxdimen
\showhyphenspace#1 {} \par
\loop
\count@\@ne
\ifnum1=\lastnodetype
\setbox4\lastbox
\setbox2\hbox{\unhbox4 \unhbox2}\count@\z@
\fi
\ifnum11=\lastnodetype\unskip\count@\z@\fi
\ifnum13=\lastnodetype
\count2\lastpenalty
\unpenalty\count@\z@
\ifnum\count2=\@ne
\setbox2\hbox{ \unhbox2}\count@\z@
\fi
\fi
\ifnum\z@=\count@
\repeat
\hsize\maxdimen
\hfuzz\z@
\hbadness\z@
\par
\unhbox2
\par
}}}
当我运行此代码时,我收到很多错误消息,例如
! Undefined control sequence.
\showhyphens ...xdepth \maxdimen \pretolerance \m
at ne\tolerance \m at ne \...
l.129 }
和
! Undefined control sequence.
\showhyphens ...t ne\hbadness \z@ \parfillskip \z
at skip \hsize 1sp \noinde...
l.129 }
而我希望看到的带连字符的文本只有三分之一。
您能告诉我用什么来替换\z
它\m
,以便它在 XeLaTeX 中可以正常工作吗?
答案1
您正在阅读的版本已被邮件或网站重新格式化而损坏,@
以at
使电子邮件地址免遭复制......
\m at ne
即\m@ne
-1
但是你根本不需要这个,\showhyphens
XeLaTeX 中的默认定义是该代码的以下稍微更新的版本。
\DeclareRobustCommand\showhyphens[1]{%
\setbox0\vbox{%
\usefont{TU}{lmr}{m}{n}%
\hsize 1sp %
\hbadness\@M
\hfuzz\maxdimen
\tracingonline\z@
\everypar={}%
\leftskip\z@skip
\rightskip\z@skip
\parfillskip\z@skip
\hyphenpenalty=-\@M
\pretolerance\m@ne
\interlinepenalty\z@
\clubpenalty\z@
\widowpenalty\z@
\brokenpenalty1127 %
\setbox\z@\hbox{}%
\noindent
\hskip\z@skip
#1%
\par
\loop
\@tempswafalse
\ifnum\lastnodetype=11\unskip\@tempswatrue\fi
\ifnum\lastnodetype=12\unkern\@tempswatrue\fi
\ifnum\lastnodetype=13 %
\count@\lastpenalty
\unpenalty\@tempswatrue
\fi
\ifnum\lastnodetype=\@ne
\setbox\tw@\lastbox\@tempswatrue
\setbox0\hbox{\unhbox\tw@\unskip\unskip\unpenalty
\ifnum\count@=1127 \else\ \fi
\unhbox0}%
\count@\z@
\fi
\if@tempswa
\repeat
\hbadness\z@
\hsize\maxdimen
\showboxdepth\z@
\tolerance\m@ne
\hyphenpenalty\z@
\noindent\unhbox\z@
}}