Document ClassesToC Formatting of custom Document Class

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
davidfall
Posts: 14
Joined: Thu Aug 11, 2011 4:11 pm

ToC Formatting of custom Document Class

Post by davidfall »

Hi,

I'm currently struggling with a modification of a custom class, created for thesis on my university. I have been able to modify the ToC so that I obtain indentations for section etc. But would like to develop this further so that each chapter is bold and that content of each chapter is separated by a blank line.

Got:
Abstract
1. Introduction
1.1 Background
2. The main things
2.1 Something else
2.1.1 Something very specific
3. Conclusions
Want it like:
Abstract

1. Introduction
1.1 Background

2. The main things
2.1 Something else
2.1.1 Something very specific

3. Conclusions
I think you get it...

My addition so far:

Code: Select all

\renewcommand\tableofcontents{% \ev is used for temporary storage of \parskip
\newlength\ev
\setlength{\ev}{\parskip}
\parskip0pt 

     \clearpage  \global\@topnum\z@
      \presectiontitle{\contentsname}
    \@afterindenttrue
     \begin{center}
      { \normalfont
       \interlinepenalty\@M
       \vskip21pt \vskip0.8\baselineskip
      }\end{center}
     \@afterheading
    \vskip 1em
     \@starttoc{toc}%
\parskip\ev}

\renewcommand\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode
      \advance\leftskip@tempdima
      \hskip -\leftskip
      \nobreak\leaders\hbox{$\m@th \mkern \@dotsep mu.\mkern \@dotsep 
       mu$}\hfil  \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}

\renewcommand*\l@chapter{\@dottedtocline{1}{1.5em}{2.em}}
\renewcommand*\l@section{\@dottedtocline{2}{3.8em}{2.9em}}
\renewcommand*\l@subsection{\@dottedtocline{3}{7em}{3.8em}}
\renewcommand*\l@paragraph{\@dottedtocline{4}{11.1em}{4.7em}}
\renewcommand*\l@subparagraph{\@dottedtocline{5}{16.1em}{5.7em}}
Simply put: Where to put the \textbf and \vspace{}? (or what other commandos to use?)

Thanks in advance!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

davidfall
Posts: 14
Joined: Thu Aug 11, 2011 4:11 pm

Re: ToC Formatting of custom Document Class

Post by davidfall »

Hi again,
Sorry for bumping, but can anyone help me?
Let me know if you latex-oracales need something more from me!

/D
davidfall
Posts: 14
Joined: Thu Aug 11, 2011 4:11 pm

ToC Formatting of custom Document Class

Post by davidfall »

Hi again,
After extensive trial and error, I have been able to produce a semi-good solution! Boldface on chapters, proper indention and vertical spacing between blocks of chapter are now working. However, now I get dotted lines on all tocline. As the chapters is boldfaced this doesn't come out very nicely...
Any idea on how to make dotted lines only on sections and subsections?

As you can see in the code below I have tried to modify the dot seperation (@dotsep) but obviously Iäm doing it wrong because these addition doesn't have any effect...

Code: Select all

\renewcommand\tableofcontents{% \ev is used for temporary storage of \parskip
\newlength\ev
\setlength{\ev}{\parskip}
\parskip0pt %Controls space between heading and toc
% A line as 'TABLE OF CONTENTS' must not appear in the
% Table of Contents. Hence we reproduce the \chapter* here except that
% no entry is put into the toc file.
     \clearpage  \global\@topnum\z@
      \presectiontitle{\contentsname}

    \@afterindenttrue
     \begin{center}
      { \normalfont
       \interlinepenalty\@M
       %\large \bfseries  \contentsname\par\nobreak
       \vskip21pt \vskip0.8\baselineskip
      }\end{center}
     \@afterheading
    \vskip 1em
     \@starttoc{toc}%
\parskip\ev}

\renewcommand\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode
      \advance\leftskip@tempdima
      \hskip -\leftskip
      \nobreak\leaders\hbox{$\m@th \mkern \@dotsep mu.\mkern \@dotsep %Add textbf here somewhere
       mu$}\hfil  \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}

\renewcommand\@dotsep{100000}
\renewcommand*\l@chapter{\bfseries\vspace{5pt}\@dottedtocline{1}{1.5em}{2.em}}
\renewcommand\@dotsep{1}
\renewcommand*\l@section{\normalfont\@dottedtocline{2}{3.8em}{2.9em}}
\renewcommand*\l@subsection{\normalfont\@dottedtocline{3}{7em}{3.8em}}
\renewcommand*\l@paragraph{\normalfont\@dottedtocline{4}{11.1em}{4.7em}}
\renewcommand*\l@subparagraph{\normalfont\@dottedtocline{5}{16.1em}{5.7em}}
Post Reply