[Tugindia] Alignment of numbers in toc

Ragu ragu at ttiindia.com
Thu Mar 20 13:21:01 CET 2003


Hi

Please check the following lines of macros for you; I have defined for one
of my jobs; hope this will help you to solve the problem.

I have defined a  control sequence called \TOCdigits  -- please note this
commend.  For you it should be \TOCdigits{2}{2}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newdimen\TOCindentA
\newdimen\TOCindentB
\newdimen\TOCindentC
\def\TOCdigits#1#2{%
  \TOCindentA=1.25\ssem \TOCindentB=2.0\ssem
  \ifnum #1=2
    \advance\TOCindentA 0.5\ssem % another digit
    \advance\TOCindentB 0.5\ssem % another digit in the subsection entries
  \fi
  \ifnum #2=2
    \advance\TOCindentB 0.5\ssem
  \fi
  \TOCindentC\TOCindentA \advance\TOCindentC\TOCindentB}
\TOCdigits{1}{1}% default (< 10 sections with no more that 9 subsections
each)



\makeatletter
\def\TOCPageNumbersYes{%
\def\EXPDOTTEDTOCLINE##1##2##3##4##5{%
  \ifnum ##1=1%
  \def\numberline####1{\hb at xt@ ##3{\null\hfill\hskip ##2
####1\,\kern0.5\ssem\hss}}%
  \else
  \ifnum ##1=2%
  \def\numberline####1{\hb at xt@ ##3{\null\hfill\hskip ##2
####1\,\kern0.5\ssem\hss}}%
  \else
  \let\numberline=\relax
  \fi\fi
  \ifnum ##1>\c at tocdepth
  \else
  \ifnum ##1=1
    \vskip 2pt plus 2pt
  \fi
    {\leftskip 6.25pc %% 24.001pt
     \rightskip 9pc plus 20pc \parfillskip -2.5pc plus -20pc
     \parindent 0pc\relax %%\@afterindenttrue
     \interlinepenalty\@M%
     \leavevmode\@tempdima##2\advance\leftskip##2
     \noindent\hangindent##3\advance\hangindent-\@tempdima
     \hskip-##2{##4\myfill}\mbox{\hskip 1pt##5}\par}%
  \fi}}
 \TOCPageNumbersYes %%
\makeatother

\TOCdigits{2}{2}

With Warm Regards
S.Ragu



%%%%%%%%%%%%%%%%%%%%%%%%%



> Dear all,
>
>     Here is the counter alignment problem, that I could not solve. If we
use
> the enumerate environment, we get numbers aligned right. For example,
>
>   7.
>   8.
>   9.
> 10.
>
> However, in toc it does not happen so. The following is a part of my toc
> that prints lime
>
> 7.
> 8.
> 9.
> 10.
>
> Actually I want 7,8 and 9 to appear above 0 of ten. Thus 1 to 9 should be
> padded with a blank.
>
> Can anybody help me in achieving so?
>
>
>
>
>
> \contentsline {chapter}{\tocchapter {Chapter}{1}{My Chapter}}{1}
> \contentsline {section}{\tocsection {}{1}{Preliminaries}}{1}
> \contentsline {section}{\tocsection {}{2}{Preliminaries}}{3}
> \contentsline {section}{\tocsection {}{3}{Preliminaries}}{16}
> \contentsline {section}{\tocsection {}{4}{Preliminaries}}{19}
> \contentsline {section}{\tocsection {}{5}{Preliminaries}}{23}
> \contentsline {section}{\tocsection {}{6}{Preliminaries}}{35}
> \contentsline {section}{\tocsection {}{7}{Preliminaries}}{39}
> \contentsline {section}{\tocsection {}{8}{Preliminaries}}{52}
> \contentsline {section}{\tocsection {}{9}{Preliminaries}}{53}
> \contentsline {section}{\tocsection {}{10}{Preliminaries}}{53}
> \contentsline {section}{\tocsection {}{11}{Preliminaries}}{55}
>
> Thanks in advance.
>
> Dinesh Karia




More information about the Tugindia mailing list