Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using a shorttoc with tocloft to put the names of chapters on a newline. Unfortunately, there are some chapters (such as the Preface or Index) which are not numbered, and I end up with additional, ugly, newlines between them:

Shorttoc with ugly newlines

Here is a MWE of my problem:

\documentclass{scrbook}

\usepackage[english]{babel}
\usepackage{shorttoc}

\usepackage{tocloft}
\renewcommand\cftchappresnum{Chapter\ }
\renewcommand\cftchapaftersnumb{\newline} % This is the newline I'd like to be contextual
\renewcommand\cftchapleader{\cftdotfill{1}}
\renewcommand\cftsecleader{\cftdotfill{1}}


\usepackage{blindtext}


\begin{document}

\shorttableofcontents{Contents}{0}

\addchap{Preface}
\blindtext

\Blinddocument

\addchap{Postface}
\blindtext

\tableofcontents

\end{document}

and the result is:

MWE of the problem

How could I keep the newlines for numbered chapters and get rid of it for entries that are not numbered?

Edit:

Actually, I'm realizing that what I'm trying to achieve is to reduce the interline between the chapter entries in the toc. How can I do that?

share|improve this question
    
Personally, I think the ToC looks better with the extra spacing. IMHO, the only thing that needs changing is adding extra space above the index heading. Then all ‘normal’ chapters would be seen as one block, and ‘special’ chapters would be separate blocks. –  Karl Ove Hufthammer Nov 14 '11 at 10:41

2 Answers 2

Instead of \newline use your own macro, redefined by each chapter head to give a newline and then empty itself (hence to only produce one newline for each chapter head). When the Chapter\ head is not used, the newline won't either.

\newcommand{\newlineornot}{}
\renewcommand\cftchappresnum{Chapter\ \gdef\newlineornot{\newline\gdef\newlineornot{}}}
\renewcommand\cftchapaftersnumb{\newlineornot}

Or, in a full document,

\documentclass{scrbook}

\usepackage[english]{babel}
\usepackage{shorttoc}

\usepackage{tocloft}
\newcommand{\newlineornot}{}
\renewcommand\cftchappresnum{Chapter\ \gdef\newlineornot{\newline\gdef\newlineornot{}}}
\renewcommand\cftchapaftersnumb{\newlineornot}
\renewcommand\cftchapleader{\cftdotfill{1}}
\renewcommand\cftsecleader{\cftdotfill{1}}


\usepackage{blindtext}


\begin{document}

\shorttableofcontents{Contents}{0}

\addchap{Preface}
\blindtext

\Blinddocument

\Blinddocument

\addchap{Postface}
\blindtext

\tableofcontents

\end{document}
share|improve this answer
    
Thanks for the suggestion, but that doesn't fix my issue. –  ℝaphink Aug 10 '11 at 5:54
    
@Raphnik: ah, yes, actually I should have realized that the output still had the same spaces. –  Bruno Le Floch Aug 10 '11 at 15:32
up vote 2 down vote accepted

It turns out that the problem was the spacing between chapter entries in the toc.

This simple setting did the job:

\setlength{\cftbeforechapskip}{-0.3em}

So I end up with something like:

\setlength{\cftbeforechapskip}{-0.3em}
\renewcommand\cftchappresnum{Chapter\ }
\renewcommand\cftchapaftersnumb{\newline}
\renewcommand\cftchapleader{\cftdotfill{1}}
\renewcommand\cftsecleader{\cftdotfill{1}}

After adjusting the title, the result is:

Fixed line skip

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.