1

The line spacing (or line height?) in my Table of Contents is irregular, see image below.

For example: the vertical gap between 1-1-1 and 1-1-2 is larger than that between 1-1-2 and 1-1-3.

As @ChristianHupfer suggested in the comments; when a line contains a letter with a descender such as 'p' or 'y', more vertical space is claimed.

Does anyone know how to fix this?

enter image description here

The example above can be produced by the following code:

\documentclass[a4paper,11pt,twoside,onecolumn,openright]{book}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%    Changes to the default book class style
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\makeatletter
\renewcommand\contentsname{Table of Contents}
%
\renewcommand\tableofcontents{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\contentsname
        \@mkboth{%
           \contentsname}{\contentsname}}%
    \@starttoc{toc}%
    \if@restonecol\twocolumn\fi
    }%
\renewcommand\listoffigures{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listfigurename}%
      \@mkboth{\listfigurename}%
              {\listfigurename}%
    \@starttoc{lof}%
    \if@restonecol\twocolumn\fi
    }%
\renewcommand\listoftables{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listtablename}%
      \@mkboth{%
          \listtablename}%
         {\listtablename}%
    \@starttoc{lot}%
    \if@restonecol\twocolumn\fi
    }%
\makeatother
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%    Definitions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\newcommand*{\loflotintoc}[1]%
            {\def\loflot_in_toc{#1}}
%
\loflotintoc{}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%    Fancy Chapter Headings
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\RequirePackage{fncychap}
%
\makeatletter
  \ChNameVar{\raggedleft\Huge\rm}
  \ChNumVar{\Huge\rm}
  \ChTitleVar{\raggedleft\Huge\sf\bfseries}
  \ChRuleWidth{2pt}

  \renewcommand{\DOCH}{%
    \vskip -0.5\baselineskip
    \mghrulefill{\RW}\par\nobreak
    \CNV\FmN{\@chapapp}\space \CNoV\thechapter
    \par\nobreak
    \vskip -0.5\baselineskip
   }
  \renewcommand{\DOTI}[1]{%
    \mghrulefill{\RW}\par\nobreak
    \CTV\FmTi{#1}\par\nobreak
    \vskip 60\p@
    }
  \renewcommand{\DOTIS}[1]{%
    \mghrulefill{\RW}\par\nobreak
    \CTV\FmTi{#1}\par\nobreak
    \vskip 60\p@
    }
\makeatother
%
\RequirePackage{ifthen}
\RequirePackage{ifpdf}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%    Change format TOC, sections, subsections, etc.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\renewcommand\thesection      {\thechapter-\arabic{section}}
\renewcommand\thesubsection   {\thesection-\arabic{subsection}}
\renewcommand\thesubsubsection{\thesubsection-\arabic{subsubsection}}
\renewcommand\theparagraph    {\thesubsubsection-\arabic{paragraph}}
\renewcommand\thesubparagraph {\theparagraph-\arabic{subparagraph}}
\renewcommand\thefigure       {\thechapter-\arabic{figure}}
\renewcommand\thetable        {\thechapter-\arabic{table}}
%
\makeatletter
%
\renewcommand\section{\@startsection{section}{1}{\z@}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\sffamily\Large\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\sffamily\large\bfseries}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\sffamily\normalsize\bfseries}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                    {3.25ex \@plus1ex \@minus.2ex}%
                                    {-1em}%
                                    {\sffamily\normalsize\bfseries}}
\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
                                       {3.25ex \@plus1ex \@minus .2ex}%
                                       {-1em}%
                                      {\sffamily\normalsize\bfseries}}
%
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >-2\relax
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    \markboth{}{}%
    {\centering
     \interlinepenalty \@M
     \sffamily
     \ifnum \c@secnumdepth >-2\relax
       \huge\bfseries \partname\nobreakspace\thepart
       \par
       \vskip 20\p@
     \fi
     \Huge \bfseries #2\par}%
    \@endpart}
%
\def\@spart#1{%
    {\centering
     \interlinepenalty \@M
     \sffamily
     \Huge \bfseries #1\par}%
    \@endpart}
%
\renewcommand*\l@part[2]{%
  \ifnum \c@tocdepth >-2\relax
    \addpenalty{-\@highpenalty}%
    \addvspace{2.25em \@plus\p@}%
    \setlength\@tempdima{3em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      {\leavevmode
       \large \bfseries \sffamily #1\hfil \hb@xt@\@pnumwidth{\hss #2}}\par
       \nobreak
         \global\@nobreaktrue
         \everypar{\global\@nobreakfalse\everypar{}}%
    \endgroup
  \fi}
%
\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries \sffamily
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}
%
\renewcommand*\l@section{\sffamily \@dottedtocline{1}{1.5em}{2.3em}}
\renewcommand*\l@subsection{\sffamily \@dottedtocline{2}{3.8em}{3.2em}}
\renewcommand*\l@subsubsection{\sffamily \@dottedtocline{3}{7.0em}{4.1em}}
\renewcommand*\l@paragraph{\sffamily \@dottedtocline{4}{10em}{5em}}
\renewcommand*\l@subparagraph{\sffamily \@dottedtocline{5}{12em}{6em}}
\renewcommand*\l@figure{\sffamily \@dottedtocline{1}{1.5em}{2.3em}}
\renewcommand*\l@table{\sffamily \@dottedtocline{1}{1.5em}{2.3em}}
%
\makeatother
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%    HyperReference
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\RequirePackage[hyperref]{xcolor}
\ifpdf
  \RequirePackage{hyperref}
\else
  \RequirePackage{pstricks,pst-node}
  \RequirePackage[dvips]{hyperref}
\fi
%
\RequirePackage{colortbl}
\definecolor{darkred}{rgb}{0.5,0,0}
\definecolor{darkgreen}{rgb}{0,0.3,0}
\definecolor{darkblue}{rgb}{0,0,0.5}
\definecolor{darkbrown}{rgb}{0.28,0.07,0.07}
\definecolor{black}{rgb}{0,0,0}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%    Extra Packages and Options
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\RequirePackage[headheight=14.6pt,hmarginratio=1:1,top=3.5cm,height=22.5cm,width=14.9cm,headsep=1.0cm,footskip=1.5cm]{geometry}
\RequirePackage{fancyhdr}
%
\RequirePackage{caption}
\RequirePackage{subcaption}
\RequirePackage{graphicx}
%
\RequirePackage{psfrag}
%
\RequirePackage[notintoc]{nomencl}[2005/09/22]
%
% separate paragraphs instead of indenting them
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
%
% small sans-serif font family for captions
\renewcommand{\captionfont}{\small\sffamily}
\renewcommand{\captionlabelfont}{\small\bfseries\sffamily}
\setlength{\captionmargin}{20pt}
%
% better vertical spacing in tables
\newcommand\T{\rule{0pt}{2.6ex}}
\newcommand\B{\rule[-1.2ex]{0pt}{0pt}}
%
\newcommand{\clearemptydoublepage}{\newpage{\pagestyle{empty}\cleardoublepage}}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%    Header Definition
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\pagestyle{fancyplain}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\lhead[\fancyplain{}{\sffamily\bfseries\thepage}]{\fancyplain{}{\sffamily\bfseries\rightmark}}
\rhead[\fancyplain{}{\sffamily\bfseries\leftmark}]{\fancyplain{}{\sffamily\bfseries\thepage}}
\cfoot{}
% Headers and footers for plain (blank) pages
\fancypagestyle{plain}{%
  \fancyhf{}%
  %\fancyhead[RO,LE]{\bfseries \thepage}%
  \fancyfoot[C]{\sffamily \bfseries \thepage}%
  \renewcommand{\headrulewidth}{0pt}%
  \renewcommand{\footrulewidth}{0pt}%
}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%    TOC / LOF / LOT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\newcommand{\toc}{
    \thispagestyle{empty}
    \setlength{\baselineskip}{0.5\baselineskip}
    \tableofcontents\cleardoublepage
    \setlength{\baselineskip}{2\baselineskip}
}
%
\newcommand{\toclof}{
    \thispagestyle{empty}
    \setlength{\baselineskip}{0.5\baselineskip}
    \tableofcontents\cleardoublepage
    \listoffigures%
    \ifthenelse{ \equal{\loflot_in_toc}{0} }{\cleardoublepage}{%
        \addcontentsline{toc}{chapter}{\numberline{}\listfigurename}\cleardoublepage%
        %\addcontentsline{toc}{chapter}{\listfigurename}\cleardoublepage%
    }%
    \setlength{\baselineskip}{2\baselineskip}
}
%
\newcommand{\tocloflot}{
    \thispagestyle{empty}
    \setlength{\baselineskip}{0.5\baselineskip}%
    \tableofcontents\cleardoublepage%
    \listoffigures%
    \ifthenelse{ \equal{\loflot_in_toc}{0} }{\cleardoublepage}{%
        \addcontentsline{toc}{chapter}{\numberline{}\listfigurename}\cleardoublepage%
        %\addcontentsline{toc}{chapter}{\listfigurename}\cleardoublepage%
    }%
    \listoftables%
    \ifthenelse{ \equal{\loflot_in_toc}{0} }{\cleardoublepage}{%
        \addcontentsline{toc}{chapter}{\numberline{}\listtablename}\cleardoublepage%
        %\addcontentsline{toc}{chapter}{\listtablename}\cleardoublepage%
    }%
    \setlength{\baselineskip}{2\baselineskip}%
    \cleardoublepage
}
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%    Begin document
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\begin{document}%

% Front matter
\frontmatter

\loflotintoc{1} % 1 = include LOF and LOT in TOC
\tocloflot

% Main matter
\mainmatter

\chapter{Example Chapter}
\section{Section without descender}
\subsection{Subsection with descender, such as p or y}
\subsection{Subsection without descender}
\subsection{Subsection without descender}
\section{Section without descender}
\section{Section with descender, such as p or y}
\section{Section with descender, such as p or y}
\section{Section without descender}
\section{Section without descender}

\appendix

% Back matter
\backmatter

\end{document}
  • Simulation Set-Up has a descender in p, so there is more vertical space between the first two entries – user31729 Jan 25 '18 at 11:03
  • (1) welcome, (2) can we get some (full) code that generates this. (3) Have you verified that this is not a bug in the viewer used by sharelatex? The build in PDF viewers in browsers are known to have issues from time to time. – daleif Jan 25 '18 at 11:08
  • @ChristianHupfer I see. So line-spacing is regular, but the line-height is not? Do you know how this can be fixed? – woeterb Jan 25 '18 at 11:08
  • @daleif (1) Thank you :) (2) I've added some code (3) Yes, I've exported to PDF and found the same issue. – woeterb Jan 25 '18 at 11:35
  • 2
    the output you show isn't standard but you have not provided any code that anyone can run to debug the issue. Please fix example code so that it produces the spacing shown. For example I assume 6-1 is section 1 in chapter 6 (so generated by l@section ? This would be obvious if we could run the example.... – David Carlisle Jan 25 '18 at 12:01
3

You have

\setlength{\baselineskip}{0.5\baselineskip}

which tells latex to try to fit the lines into half the normal height which is less than the size of the letters, so it has no possibility of maintaining the specified baseline spacing. In such cases rather than try to maintain even space it just stacks the lines one above the other, with \lineskip (1pt) in between, so the space between lines depends on the size of the characters in the line.

  • This works, thanks! I've set {0.5\baselineskip} to {0.8\baselineskip}. – woeterb Jan 25 '18 at 14:40
  • @Wouter That is almost as bad!! the default linespacing at 11pt is 13.5pt so .8 of that is 10.9pt which is still less than than size of the letters. Just remove the lines completely. – David Carlisle Jan 25 '18 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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