[texhax] Tables of contents

Ivan Griffin ivan at skynet.ie
Tue Jun 19 22:24:55 CEST 2012


Depends on what your base document class is and what additional support 
packages you are using (for example, memoir or koma-script).

I'm not sure if there is a really easy way of doing it (like a dedicated 
package or an option to a package or other), but you can do it relatively 
easily by some macro redefinitions.

If vanilla LaTeX classes like book, or report, you could try something 
like the following crude example - note you don't need to redefine 
\l at chapter for article.cls as it doesn't define it so we check if its 
defined first before trying to redefine it...

\documentclass{book} % or article, or report

% Begin redefinitions to remove page numbers from TOC

% remove page numbers from \part
\let\oldl at part=\l at part
\renewcommand*{\l at part}[2]
     \oldl at part{#1}{ }

% remove page numbers from \chapter for book.cls and report.cls
\@ifundefined{l at chapter}
   % undefined so nothing to do
   % \l at chapter only defined in book.cls and report.cls
   \let\oldl at chapter=\l at chapter
   \renewcommand*{\l at chapter}[2]
       \oldl at chapter{#1}{ }

% remove page numbers from \section for article.cls
\let\oldl at section=\l at section
\renewcommand*{\l at section}[2]
     \oldl at section{#1}{ }

% remove dots and page numbers for all document classes (*.cls)
     \ifnum #1>\c at tocdepth \else
     \vskip \z@ \@plus.2\p@
     {\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
      \parindent #2\relax\@afterindenttrue
      \@tempdima #3\relax
      \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
      % removed the dotting until the page number (#5) from here

% End redefinitions



\chapter{Foobar} % Obviously remove if changing the doc class to article







Hope this helps,

On Mon, 18 Jun 2012, T. Michael Sommers wrote:

> Is there a relatively easy way to create a table of contents that does not 
> have page numbers?  That is, I just want a table of the sections and 
> subsections, etc.
> -- 
> T.M. Sommers -- tmsommers2 at gmail.com -- ab2sb
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/texhax/
> More links: http://tug.org/begin.html
> Automated subscription management: http://tug.org/mailman/listinfo/texhax
> Human mailing list managers: postmaster at tug.org

More information about the texhax mailing list