Re: Bad TOC alignment on the right (before the page number)



On May 23, 6:09 am, Vincent Lefevre <vincent+n...@xxxxxxxxxx> wrote:
In article <f93b155c7nsjgg2p5b2vaatvlb9dkn3...@xxxxxxx>,
  Dan Luecking <LookIn...@xxxxxxxx> wrote:





On Wed, 20 May 2009 12:28:08 +0000 (UTC), Vincent Lefevre
<vincent+n...@xxxxxxxxxx> wrote:
[...]
Instead of

 1.1  Foo .  .  .  .  .  .  .  .  .  .   3
 1.2  Blaaaah blah blah [...] blah blah  3

I want either

 1.1  Foo  .  .  .  .  .  .  .  .  .  .  3
 1.2  Blaaaah blah blah [...] blah blah  3

or

 1.1  Foo .  .  .  .  .  .  .  .  .  .   3
 1.2  Blaaaah  blah  blah  [...]  blah
      blah   .  .  .  .  .  .  .  .  .   3

(note: a monospace font is needed to understand these examples).

That is, the last letter must not go beyond the last dot.
You should have said this last requirement in your first post.

I thought this was obvious because when LaTeX does justification,
the alignment is done on the last dot.

This is not a bug, but a design decision based on limitations of
TeX. You are asking for a different design than the authors of
book.cls chose, and I don't think TeX can do it without rather
complicated box manipulations.
The dotted line is constructed by concatenating several identical
copies of a box. That box consists of a bit of space, a dot, and
then another bit of space.

OK, so one of the problems here is that another bit of space.
But if I fix this one, there would be the justification problem.
I don't have a simple example, but here's what kind of things
I currently get in the full book:

  1.1  Blaaaah blah blah [...] blah blah  3
  1.2  Blaaaah  blah  blah  [...]  blah
       blah blah .  .  .  .  .  .  .  .   3

After fixing the dot problem, I would get:

  1.1  Blaaaah blah blah [...] blah blah  3
  1.2  Blaaaah  blah  blah  [...]  blah
       blah blah  .  .  .  .  .  .  .  .  3

but I would want:

  1.1  Blaaaah blah blah [...] blah blah  3
  1.2  Blaaaah   blah  blah  [...]  blah
       blah blah  .  .  .  .  .  .  .  .  3

I also wonder what causes the justification in the full book
(I haven't found yet).

If you give up the alignment of the dots, you can
make the last dot align with the ends of other
lines:
 1. Change the box so the dot is at the right
    instead of the middle
 2. Use \xleaders in the definition of \dottedtocline
    instead of plain \leaders.
This inserts space between the boxes, and therefore
ruins the alignment with dots on other lines.
TeX can make leaders (copies of boxes that behave like
stretchable space) that are expanded (\xleaders) to
exactly fill the given space, or centered (\cleaders --
equal space added on both ends), or regular (fitted to
that grid so all instances line up). What you want is
a "right aligned" leaders, which isn't available.

Do you mean that the box (space, dot, space) cannot be redefined,
e.g. to (space, space, dot)?

I didn't mean that. In fact I told you you would have to do
exactly that (among other things).

Here is the situation. Imagine you are printing on paper with
a background grid. Imagine the grid squares are as wide as
the box with the dot. The dotted line in the TOC is produced
by putting one box in each grid square that lies within the
space to be filled. Even if the dot is on the right edge of the
box, there may still be some space to its right: the space to
be filled might end with a partial grid square.

This is the behavior of \leaders, the tex command used in
constructing the dotted line. Tex has two other commands:
\xleaders and \cleaders, which also try to fill the space
with copies of a box. If the space is not a whole number of
boxes, something has to be done.
-- \leaders just ignores grid squares that are not entirely in
the space. Thus, the space is not entirely filled with boxes.
-- \xleaders puts equal spaces between every two boxes
(ignoring the grid entirely) so the space is entirely filled
with boxes and space.
-- \cleaders puts equal space before and after the whole
line of boxes (also ignoring the grid) so the whole space
is filled.

Study the following. It uses the various leaders commands
on a box with {space dot}:

\documentclass{article}
\newsavebox\dotbox
\savebox\dotbox{\hspace{1em}.}
\begin{document}

\parfillskip0pt
\noindent 1.\leaders \copy\dotbox \hfill \null

\noindent 2.\xleaders \copy\dotbox \hfill \null

\noindent 3.\cleaders \copy\dotbox \hfill \null

\noindent\hrulefill %so you can see the width of a line

\noindent 4. A line with less space for dots.\xleaders\copy\dotbox
\hfill \null

\end{document}

There exists no command that does <space><box><box><box> ... <box>.

Notice that only the \xleaders lines have the dot at the
very end. Notice also that, in the two lines with \xleaders
(2 and 4), the dots in 2 first don't align with the dots in 4.
The same would be true of \cleaders. Only \leaders forces this.

The lack of a "\rleaders" and "\lleaders" is a limitation of TeX.
Presumably, Knuth didn't think they was needed. Personally,
I don't have any problem with the outcome of your example.


Dan
.



Relevant Pages

  • Re: hook for line breaks?
    ... the space between these boxes must be allowd to stretch ... rather than simple glue as it sounds like you're ... patrik dot nyman at orient dot su dot se ...
    (comp.text.tex)
  • Re: Good night
    ... His column was usually three dot ... I've got the picture. ... Wink wink nudge nudge :-) ... Now you've given me the impetus to plow through the boxes ...
    (alt.support.stop-smoking)
  • Re: Bad TOC alignment on the right (before the page number)
    ... the space is not entirely filled with boxes. ... (ignoring the grid entirely) ... So, to have the last dot at the right, I need to: ... change some of its commands. ...
    (comp.text.tex)
  • Re: "ALL YOUR BOX ARE BELONG TO STINKY"
    ... am up to my butt in boxes and paper, ... I was watching TV, and half-watching Dante jump in and out of a shoe box, and rattle the paper around, when Stinky came in, and it's so funny how I knew exactly what was going to happen--and it happened just that way. ... Marina, Miranda and Caliban. ... marina (dot) kurten iki fi ...
    (rec.pets.cats.anecdotes)
  • Re: an alternative name for "@."?
    ... two roles depending on its location w.r.t. the dot. ... it establishes it as end of sentence punctuation. ... except after uppercase. ... When a sentence ends for TeX ...
    (comp.text.tex)