4

Consider the following document run by xelatex

\documentclass{article}
\usepackage{color}
\usepackage{fontspec}
\XeTeXinterchartokenstate = 1
\newXeTeXintercharclass \mycharclassa
\newXeTeXintercharclass \mycharclassb
\XeTeXcharclass `\a \mycharclassa
\XeTeXcharclass `\b \mycharclassa
\XeTeXcharclass `\c \mycharclassa
\XeTeXcharclass `\x \mycharclassb
\XeTeXcharclass `\y \mycharclassb
\XeTeXcharclass `\z \mycharclassb
\XeTeXinterchartoks \mycharclassa \mycharclassb = {{\color{red}\leaders\hrule height 10pt\hskip0pt plus 0.5em}}
\begin{document}
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
abcxyzaxbyczabxcyzabcxyzaxbyczabxcyzabcxyzaxbyczabxcyz%
\end{document}

When you look at the output, some of the red \hrules are thicker than the others. What parameter does define this variable thickness? Can one access it as a dimen?

8
  • 1
    Welcome to TeX.SX! You're inserting glue between letters, and justification does the rest, stretching the glue where necessary.
    – egreg
    Jan 5 '18 at 16:39
  • the glue stretch here is (by design) not accessible from within TeX to avoid exposing machine dependent arithmetic Jan 5 '18 at 16:42
  • 1
    @egreg Thank you. I would like to know if it is possible to access this variable glue (variable thickness of the red \hrules) as a dimen. I wish to know exactly how much glue is inserted at each place. Jan 5 '18 at 16:44
  • @DavidCarlisle That is too bad. TeX has its limitations then like any other tools after all. Jan 5 '18 at 16:46
  • the glue that is inserted is what you specified 0pt plus 0.5em all the glue in a single line will stretch to the same amount so if you know which letters of each class are on a line you can calculate the stretch Jan 5 '18 at 16:46
4

The final thickness is not available, because it comes from the justification algorithm.

Leaders behave the same as glue. The end result of your input is the same as having

\spaceskip=0pt plus 0.5em

and, an extract from the first line,

abc xyza xb yc zab xc yzabc xyza xb yc zab ...

The justification algorithm will stretch some lines so that they fill the line, after having chosen the line breaks.

Instead of the spaces you have rules, but it's really the same thing. And, no, the amount of stretching is not available during processing, but it can only be seen with \showoutput (or similar methods) in the log file.

2
  • Thanks. Suppose that I did not have the \leaders\hrule height 10pt\hskip0pt plus 0.5em part in my code, then is it possible to replace it with a conditional test \ifdim\somedimen>0pt \hrule height 10pt width \somedimen\fi where \somedimen is the needed variable dimen so that all lines are justified without any badness? Jan 5 '18 at 16:56
  • @CazSandison How? The lines have different natural width, so justification needs different amount of stretching for each line.
    – egreg
    Jan 5 '18 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.