Irregular line spacing in TOC

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?

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\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{}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\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}%
\else
\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
\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
\vskip 1.0em \@plus\p@
\setlength\@tempdima{1.5em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode \bfseries \sffamily
\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{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}}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\pagestyle{fancyplain}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\cfoot{}
% Headers and footers for plain (blank) pages
\fancypagestyle{plain}{%
\fancyhf{}%
\fancyfoot[C]{\sffamily \bfseries \thepage}%
\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}{%
}%
\setlength{\baselineskip}{2\baselineskip}
}
%
\newcommand{\tocloflot}{
\thispagestyle{empty}
\setlength{\baselineskip}{0.5\baselineskip}%
\tableofcontents\cleardoublepage%
\listoffigures%
\ifthenelse{ \equal{\loflot_in_toc}{0} }{\cleardoublepage}{%
}%
\listoftables%
\ifthenelse{ \equal{\loflot_in_toc}{0} }{\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
• 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

\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