Sorry if I implied there was something magic with litl
… what was really important was that the bits that needed to be offset needed to have their own markup (but then you change the hook to be before whatever the relevant marker is.
Now, \hfill
(and \leaders
) getting discarded if there’s a line-break is a very useful feature, not a bug - it stops there being a space at the start/end of a broken line. There’s no need to treat things as exceptions, we just need to educate TeX…
The question that needs to be answered, though, is what would you like to happen?
- Never ever break the line before the number (even if the result is horrible): change the end of the sethook to be:
litl}{\penalty10000\hfill}
- A whole blank line / line of dots before the number:
litl}{\unskip\penalty500\hbox{}\penalty10000\hfill}
In both of these, if you are using the \leaders
, put the extra bit in front of that instead.
Explanation:
What these are doing is giving the line-breaking algorithm some extra instructions.
I’ve also added \unskip
which removes a preceding space if there is one - that’s more useful for the \leaders
-based code, and stops there being a space between the dots and the preceding word.
The \penalty 500
means the line can be broken there, but it’s a long way from ideal. and \hbox{}
is just a zero-width thing that it can’t discard. \penalty10000
says the cost of breaking the line here is ‘infinite’. Thus for both of these versions, TeX is not allowed to break the line at (just before) the fill, and thus it cannot be discarded by the normal process.