Document Classestocloft spacing when chapter counter changes

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
wheely_chairs
Posts: 26
Joined: Mon Jun 16, 2008 1:22 pm

tocloft spacing when chapter counter changes

Post by wheely_chairs »

Hi everyone,

I've googled everywhere for this and read the documentation cover-to-cover but with no success...

I've used the tocloft package to create a list of equations, which is great :D . However, in the list of figures/tables some extra vertical space is added when the chapter containing the figure/table changes, e.g:

Code: Select all

1.1 Figure 1.1
1.2 Figure 1.2
<Vertical Space>
2.1 Ooh vertical space
2.2 That was nice
But my new list of equations does not have the same behaviour :cry: . I nicked the code off of this forum (thanks gmedina!), the only difference being that I use the hyperref package so place \phantomsection before the \addcontentsline.

Any ideas how I can get this <vertical space>?

Thanks,

Chris

Recommended reading 2024:

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

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

User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

tocloft spacing when chapter counter changes

Post by Juanjo »

Following the notations in gmedina's post, write

Code: Select all

\addtocontents{equ}{\protect\addvspace{10pt}}
before the first equation in every chapter.
To automate this, you should change the definition of \chapter.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
wheely_chairs
Posts: 26
Joined: Mon Jun 16, 2008 1:22 pm

Re: tocloft spacing when chapter counter changes

Post by wheely_chairs »

Many thanks Juanjo. It's a shame it can't be done automatically (I certainly can't be bothered to redefine \chapter!) but this will suffice.

Chris :D
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

tocloft spacing when chapter counter changes

Post by Juanjo »

wheely_chairs wrote:I certainly can't be bothered to redefine \chapter!
Well, not so difficult, I hope:

Code: Select all

\makeatletter
\let\@chapterOLD\@chapter
\renewcommand{\@chapter}[2][]{\@chapterOLD[#1]{#2}\addtocontents{equ}{\protect\addvspace{10pt}}}
\makeatother
Of course, you should put this after the code concerning the definition of the list of equations. The above code mimics the behaviour of \chapter in the book class regarding the LOF and LOT: only numbered chapters add space (i.e. \chapter, not \chapter*).
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10323
Joined: Mon Mar 10, 2008 9:44 pm

tocloft spacing when chapter counter changes

Post by Stefan Kottwitz »

Hi,

Juanjo's code will work very well. I just want to mention an alternative. Instead of redefining the internal \@chapter macro one could redefine \chaptermark, this macro will be called every time a chapter starts (by \@chapter), and that macro is intended to be redefined by users:

Code: Select all

\let\chaptermarkOLD\chaptermark
\renewcommand*\chaptermark[1]{\chaptermarkOLD{#1}\addtocontents{equ}{\protect\addvspace{10pt}}}
Stefan
LaTeX.org admin
Post Reply