1

In my dissertation, text needs to be double spaced but lines in table of contents and list of figures that exceed one line are needed to be single space. In the following code, I am able to do this in table of contents but it is not working for list of figures:

\documentclass[12pt]{article}
\usepackage{setspace}
\doublespacing 
\usepackage{tocloft}
\renewcommand\cftsecafterpnum{\vskip\baselineskip}
\renewcommand\cftsubsecafterpnum{\vskip\baselineskip}
\renewcommand\cftsubsubsecafterpnum{\vskip\baselineskip}
\titleformat{\section}[block]{\Large\bfseries\filcenter}{}{}{}
\renewcommand{\contentsname}{\hfill\bfseries\Large TABLE OF CONTENTS\hfill}  
\renewcommand{\cfttoctitlefont}{\hspace*{\fill}\Huge\bfseries}
\renewcommand{\cftaftertoctitle}{\hspace*{\fill}}
\renewcommand{\cftlottitlefont}{\hspace*{\fill}\Huge\bfseries}
\renewcommand{\cftafterlottitle}{\hspace*{\fill}}
\renewcommand{\cftloftitlefont}{\hspace*{\fill}\Huge\bfseries}
\renewcommand{\cftafterloftitle}{\hspace*{\fill}} 
\renewcommand{\cftfigpresnum}{Figure \ }
\renewcommand{\cfttabpresnum}{Table \ }
\newlength{\mylenf}
\settowidth{\mylenf}{\cftfigpresnum}
\setlength{\cftfignumwidth}{\dimexpr\mylenf+1.5em}
\setlength{\cfttabnumwidth}{\dimexpr\mylenf+1.5em}


\begin{document}

\begin{singlespace}
  \tableofcontents
\end{singlespace}
\newpage

\begin{singlespace}
    \listoftables
\end{singlespace}   
\addcontentsline{toc}{section}{List of Tables}
\newpage

\begin{singlespace}
    \listoffigures
\end{singlespace}   
\addcontentsline{toc}{section}{List of Figures}
\newpage

\end{document}

Based on this code, the entire list of tables and list of figures become single spaced. Could you please tell me how can I solve this issue?

  • Welcome! First you say it works for the ToC but not at all for the LoF. Then you say affects both the ToC and the LoF in the same way, but not the way you want. So is it OK in the ToC? Do you want something different in the LoF? Or do you not have it working in the ToC either after all? – cfr Jul 21 '17 at 0:39
  • Please also provide complete code for a minimal example demonstrating the issue. It will need some sections and figures, presumably, to do this, and it will certainly need \end{document}. This makes it much easier for people to help you. – cfr Jul 21 '17 at 0:41
  • It works for TOC (double spaced for all and single spaced for lines that exceed one line) but is not working for LOF and LOT. – Sina Jul 21 '17 at 0:44
1

The statements in the question are unclear. It works indeed for the ToC but not for the LoF and LoT, since the relevant \cftfigureafterpnum macros are not redefined similarly to their sec, subsec and subsubsec variants.

However, it does not really look nice altogether, especially with the fact that there is additionally spacing before each sec etc. entry that could be controlled with \cftbeforesecskip (and the related variants for subsec and subsubsec as well, i.e. \cftbeforesubsecskip and \cftbeforesubsubsecskip).

I've changed the explicit \begin{singlespacing}...\end{singlespacing} to be written to the relevant .toc etc. files as well added tocbibind package in order to include the list of... in the ToC.

Finally, I changed the weird \renewcommand{\contentsname} to something more convenient with \cfttoctitlefont etc.

\documentclass[12pt]{article}

\usepackage{blindtext}
\usepackage{pgffor}
\usepackage{setspace}
\doublespacing 
\usepackage{tocloft}
\usepackage{tocbibind}


\renewcommand\cftsecafterpnum{\vskip\baselineskip}
\renewcommand\cftsubsecafterpnum{\vskip\baselineskip}
\renewcommand\cftsubsubsecafterpnum{\vskip\baselineskip}

% My invention (C.H)
\renewcommand\cftfigafterpnum{\vskip\baselineskip}
\renewcommand\cfttabafterpnum{\vskip\baselineskip}


%\titleformat{\section}[block]{\Large\bfseries\filcenter}{}{}{}% No titlesec

%\renewcommand{\contentsname}{\hfill\bfseries\Large TABLE OF CONTENTS\hfill}% Bad idea

\renewcommand{\contentsname}{TABLE OF CONTENTS}
\renewcommand{\cfttoctitlefont}{\hfill\bfseries\Large}
\renewcommand{\cftaftertoctitle}{\hfill}

\renewcommand{\cfttoctitlefont}{\hspace*{\fill}\Huge\bfseries}
\renewcommand{\cftaftertoctitle}{\hspace*{\fill}}
\renewcommand{\cftlottitlefont}{\hspace*{\fill}\Huge\bfseries}
\renewcommand{\cftafterlottitle}{\hspace*{\fill}}
\renewcommand{\cftloftitlefont}{\hspace*{\fill}\Huge\bfseries}
\renewcommand{\cftafterloftitle}{\hspace*{\fill}} 
\renewcommand{\cftfigpresnum}{Figure \ }
\renewcommand{\cfttabpresnum}{Table \ }


% Only if needed
%\setlength{\cftbeforesubsecskip}{0pt}
%\setlength{\cftbeforesecskip}{0pt}


\newlength{\mylenf}
\settowidth{\mylenf}{\cftfigpresnum}
\setlength{\cftfignumwidth}{\dimexpr\mylenf+1.5em}
\setlength{\cfttabnumwidth}{\dimexpr\mylenf+1.5em}


\AtBeginDocument{
  \addtocontents{toc}{\protect\begin{singlespacing}}
  \addtocontents{lof}{\protect\begin{singlespacing}}
  \addtocontents{lot}{\protect\begin{singlespacing}}
}

\AtEndDocument{%
  \addtocontents{toc}{\protect\end{singlespacing}}
  \addtocontents{lof}{\protect\end{singlespacing}}
  \addtocontents{lot}{\protect\end{singlespacing}}
}


\begin{document}



\tableofcontents

\clearpage
\listoftables

\clearpage
\listoffigures
\clearpage

\foreach \x in {1,2,3,4,5} 
{
  \section{My foo section \x}
  \subsection{My foo subsection \x} 
  \begin{figure}
    \caption{ A caption \x}
  \end{figure}

  \blindtext[10]

  \begin{table}
    \caption{ A caption \x}
  \end{table}


  \begin{figure}
    \caption{ Another caption \x}
  \end{figure}

  \blindtext[3]


  \begin{table}
    \caption{ Another caption \x}
  \end{table}

}

\end{document}

enter image description here

I've omitted a screen shot for the list of tables, however -- it does not show something really different from the LoF.

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.