I can hardly determine a good title for this question, I'm sorry.
Minimal test code:
\documentclass{minimal}
\usepackage{lipsum}
\begin{document}
foo
{\fontsize{18}{18}\leaders\hbox{$\mkern 10000mu.\mkern 10000mu$}\hfill}
bar
\lipsum
\end{document}
If I compile this, bar
and the result of \lipsum
is gone. It's amazing. And,
If I replace the arguments of
\fontsize
with 15 or 20, everything is correct!If I replace
\hbox{$\mkern 10000mu.\mkern 10000mu$}
to something else, e.g. delete one\mkern 10000mu
, the result may be correct too.
I know that \fontsize
changes the length of a mu unit. But I totally cannot understand what happens.
Here is an example of Plain TeX:
% fine
% Width of hbox less than \maxdimen
a\leaders\hbox{\kern8000pt.\kern8000pt}\hfill b
text text
\vfill\eject
% BAD: text after the leaders is gone
% Width of hbox more than \maxdimen
a\leaders\hbox{\kern10000pt.\kern10000pt}\hfill b
text text
\vfill\eject
% fine?
% Width of hbox more than \maxdimen
a\leaders\hbox{\kern12000pt.\kern12000pt}\hfill b
text text
\vfill\eject
\bye
I wonder why a box of 20000pt width makes wrong output, but a box of 24000pt width seems correct. I know it is an overflow thus it cannot be a bug of TeX, but what happens?
Background
The code comes from tocloft
package. Now I believe it is a bug of tocloft
. In tocloft
, it defines
\providecommand{\cftdotfill}[1]{%
\leaders\hbox{$\m@th\mkern #1 mu\hbox{\cftdot}\mkern #1 mu$}\hfill}
And \cftnodots
is 10000
. Then this test file fails:
\documentclass{article}
\usepackage{tocloft}
\renewcommand{\cftsecleader}{\fontsize{16}{19}\cftdotfill{\cftnodots}}
\usepackage{lipsum}
\begin{document}
\contentsline{section}{TEST}{1}
\lipsum
\end{document}
I can fix the bug by redefining \cftdotfill
to
\renewcommand{\cftdotfill}[1]{%
\leaders\hbox to #1\p@{\hss\cftdot\hss}\hfill}
But the bug still shocked me.