[texhax] One (more) question about \halign

Donald Arseneau asnd at triumf.ca
Thu Feb 4 03:41:47 CET 2010


Rodolfo Medina <rodolfo.medina at gmail.com> writes:

> Rodolfo Medina <rodolfo.medina at gmail.com> writes:
> 
> >> >>> \halign to \hsize{%
> >> >>>          \rm\rlap{1.2}\ \ \ \ \ \ \
> >> >>>          \vbox{\parindent=0pt\hsize=105mm\hangindent 0em\strut%
> >> >>>                #\hfill\strut}%
> >> >>>        \tabskip=0cm plus20cm minus20cm&\hfil#\tabskip=0pt\cr
> >> >>>        bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla

> > (Actually, for a TOC it is better to use paragraph parameters and no
> > boxes or alignments. Then you have to pre-measure your page numbers
> > and section numbers, but that is inevitable even with halign because
> > you have to set the \hsize.)
> 
> 
> Thanks for your suggestion.  However, I'm not able to build a TOC structure
> otherwise.  Can you suggest how to do that with paragraph parameters?

First, there are three "columns" of specified width, which you must choose.
There is the space for the section number, which you have defined as 
"\ \ \ \ \ \ \ " rather than numerically.  Then the width of the title,
which you set at 105mm.  Then the width for the page numbers, which is
whatever space is left over (\hsize - 105mm - width_of_7_spaces).

Lets define the section number width and the page number width, and leave
the rest of \hsize for the title.  We will make it ragged-right.

\secnumwidth=20pt
\pgnumwidth=30pt

\def\tocleaders{\leaders \hbox{~.~}\hskip 15 pt plus 1fil}


\leftskip=\secnumwidth
\parindent=-\secnumwidth
\rightskip=\pgnumwidth plus 1fil
\parfillskip=-\rightskip
\par
\indent \hbox to\secnumwidth{#1}%   Say #1 is the section number
  \ignorespaces #2\unskip % Say #2 is the title, which may have spurious spaces
  \nobreak \tocleaders 
  #3\par





-- 
Donald Arseneau                          asnd at triumf.ca


More information about the texhax mailing list