In a 2014 post of the XeTeX list, the Great Master David Carlisle gives the following code for obtaining the same result as with the \showhyphens command, but with OpenType fonts in XeTeX:

\def\showhyphenspace#1 {%
#1\vadjust{\penalty\@ne} \expandafter\showhyphenspace

\pretolerance\m at ne\tolerance\m at ne
\pretolerance\m at ne
\tolerance\m at ne\hbadness\z@
\parfillskip\z at skip
\showhyphenspace#1 {} \par
 \setbox2\hbox{\unhbox4 \unhbox2}\count@\z@
 \setbox2\hbox{ \unhbox2}\count@\z@

When I run this code I get a lot of error messages such as

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

and merely a third of the text that I wanted to see hyphenated.

Could you please tell me what to replace \z and \m with, so that it works in XeLaTeX?

  • 1
    You've got an oddly-formatted version: you want for example \m@ne not \m at ne
    – Joseph Wright
    Commented Apr 9, 2021 at 15:19
  • 2
    There's a problem in copy-pasting. All <space>at<space> bits should be @
    – egreg
    Commented Apr 9, 2021 at 15:19
  • Thank you so much! If only all problems were so easy to solve! (Please write an answer instead of a comment, so that I can validate it and you get the well-deserved credit!)
    – yannis
    Commented Apr 9, 2021 at 15:22
  • BTW, with a medium size text (~ 2,000 words) it works smoothly and produces an immediate result. With a 12,000-word text it takes ages and produces nothing. Am I doing something wrong? Or are there some limits not to cross?
    – yannis
    Commented Apr 9, 2021 at 15:39
  • note if you are using xelatex or lualatex then something equivalent to that is the default definition of \showhyphens you don't need any extra re-definition. Commented Apr 9, 2021 at 21:40

1 Answer 1


You are reading a version that has been mangled by a mail or website re-formatting changing @ to at to make email addresses safe from copying...

\m at ne is \m@ne ie -1

But you do not need this at all, the default definition of \showhyphens in XeLaTeX is the following slightly updated version of that code.

    \hsize 1sp %
    \brokenpenalty1127 %
     \ifnum\lastnodetype=13 %
                   \ifnum\count@=1127 \else\ \fi
  • I like very much your answer and the "Great Master David Carlisle" written by the user. :-) +1
    – Sebastiano
    Commented Apr 9, 2021 at 21:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .