GeneralHelp formatting TOC

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
ganda97
Posts: 13
Joined: Fri Mar 14, 2008 12:34 am

Help formatting TOC

Post by ganda97 »

I'm writing my dissertation and need help with my TOC. My knowledge of Latex is very limited. The TOC needs to look like this example:

1. Introduction

1.1 Motivation
1.2 Method

2. Background

3. Stuff

3.1 Stuff 1
3.2 Stuff 2

(The sections should be indented to the first letter in the chapter's name. That part is working but I couldn't format it in the e-mail). My current TOC looks like this:

1. Introduction
1.1 Motivation
1.2 Method

2. Background

3. Stuff
3.1 Stuff 1
3.2 Stuff 2

I need to put a blank line between the chapter and first section in each chapter. This is what I'm using on my main tex file:

\documentclass[12pt]{report}
\usepackage{amsmath,amsthm,amsfonts,amscd} % Some packages to write mathematics.
\usepackage{eucal} % Euler fonts
\usepackage{verbatim} % Allows quoting source with commands.
\usepackage{setspace}
\usepackage[usenames]{color}
\usepackage{colortbl}
\usepackage{hhline}
\usepackage{longtable}
\usepackage{graphicx}
\usepackage[square]{natbib}

Thanks for looking and any help you may provide,

Ariel

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

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Help formatting TOC

Post by Stefan Kottwitz »

Hi Ariel!

One simple way is to insert after a \chapter call and before the next \section one line:

Code: Select all

\addtocontents{toc}{\protect\addvspace{10pt}}
That inserts 10pt into the toc in the right place. Of course you may change that value.

If you dont whant to repeat that inside each chapter, you could redefine the \@chapter macro.

Stefan
ganda97
Posts: 13
Joined: Fri Mar 14, 2008 12:34 am

Re: Help formatting TOC

Post by ganda97 »

Thanks. That worked great. Just out of curiosity, how would I modify the \@chapter macro?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: Help formatting TOC

Post by Stefan Kottwitz »

You will find the definition of the \@chapter macro inside report.cls, it's defined like \def\@chapter[#1]#2{... \addcontentsline{toc}{chapter}{#1} ... more code ... }.
You could use \renewcommand\@chapter inside your preamble to modify this: copy the original code of \@chapter into it and insert \addtocontents{toc}{\protect\addvspace{10pt}} just after the original \addcontentsline{toc}{chapter}{#1}. And \makeatletter ... \makeatother around this redefinition is necessary because of the @-symbol inside the command names.

Stefan
Post Reply