Page LayoutAdd extra Lines between Chapters but not Sections in ToC

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Ile
Posts: 7
Joined: Fri Aug 05, 2011 2:17 am

Add extra Lines between Chapters but not Sections in ToC

Post by Ile »

Hi. I'm down to just two stumbling blocks before I can submit the final draft of my thesis.

The first problem I've already solved thanks to one of the older threads here. The second I can't find the answer to anywhere: how do I add extra lines between chapters in my Table of Contents without adding extra lines beneath sections?

This is what I have:

Code: Select all

\def\nnfootnote{%
     \@ifnextchar [\@xfootnotenext
       {\protected@xdef%
%       \@thefnmark{\thempfn}%   removed the number from FOOTNOTETEXT command:
        \@thefnmark{ }%
    \@footnotetext}}
%
\renewcommand{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi
%                   \thispagestyle{myheadings}%
                    \global\@topnum\z@
                    \@afterindentfalse
                    \secdef\@chapter\@schapter}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne 
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline {\thechapter .}#1}% % I added .  so there would be a period after roman numeral 
                    \else
                      \addcontentsline{toc}{chapter}{#1}%
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}
\def\@makechapterhead#1{%
%  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
        \centerline{\large\bfseries \@chapapp\space \thechapter}
        \par\nobreak
        \vskip 12\p@
    \fi
    \interlinepenalty\@M
    \centerline{\large \bfseries \uppercase{#1}}\par\nobreak
    \vskip 18\p@
  }}
\def\@schapter#1{\if@twocolumn
                   \@topnewpage[\@makeschapterhead{#1}]%
                 \else
                   \@makeschapterhead{#1}%
                   \@afterheading
                 \fi}
\def\@makeschapterhead#1{%
  %\vspace*{50\p@}%
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \centerline{\large \bfseries  \uppercase{#1}}\par\nobreak
    \vskip 18\p@
  }}
This is the result:

Code: Select all

I. Introduction................................	1 
II. Chapter 2................................ 7
   II.1	Subsection 1................................	7 
   II.2 Subsection 2 ............................. 10
III. Chapter 3................................ 23
This is what I want the result to look like:

Code: Select all

I. Introduction................................	1 

II. Chapter 2................................ 7
   II.1	Subsection 1................................	7 
   II.2 Subsection 2 ............................. 10

III. Chapter 3................................ 23
Can anyone help? Thanks.
Last edited by Ile on Sun Aug 07, 2011 2:27 am, edited 1 time in total.

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

paul
Posts: 49
Joined: Thu Apr 08, 2010 5:56 am

Add extra Lines between Chapters but not Sections in ToC

Post by paul »

Ile wrote:

Code: Select all

\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne 
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline {\thechapter .}#1}% 
At this point, where you add \numberline... to the toc, you could add some vertical space. A much better solution would be to load the titlesec and titletoc packages instead, and use \titlecontents to adjust the formatting...
Ile
Posts: 7
Joined: Fri Aug 05, 2011 2:17 am

Add extra Lines between Chapters but not Sections in ToC

Post by Ile »

Thank you for your reply. I did try something like this:

Code: Select all

\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%  
                             {\protect\vskip 12\p@\numberline{\thechapter .}#1}
This does add the vertical space but it also splits the number of the chapter and the title of the chapter onto two different lines.
paul
Posts: 49
Joined: Thu Apr 08, 2010 5:56 am

Add extra Lines between Chapters but not Sections in ToC

Post by paul »

Ile wrote:Thank you for your reply. I did try something like this:

Code: Select all

\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%  
                             {\protect\vskip 12\p@\numberline{\thechapter .}#1}
This does add the vertical space but it also splits the number of the chapter and the title of the chapter onto two different lines.

Code: Select all

\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addtocontents{toc}{\vspace{12pt}\protect\contentsline{chapter}{\protect\numberline {\thechapter .}#1}{\thepage}}
[color=#0000BF]...[/color]
(actually, it'd probably be better to change \l@chapter...but)

Better:

Code: Select all

\titlecontents{chapter}[0pt]
  {\addvspace{12pt}\bfseries}
  {\makebox[1.5em][l]{\thecontentslabel.}}
  {}
  {\hfill\contentspage}
(with \usepackage{titletoc})
Ile
Posts: 7
Joined: Fri Aug 05, 2011 2:17 am

Re: Add extra Lines between Chapters but not Sections in ToC

Post by Ile »

That works! Thank you so much.
Post Reply