11

When I'm generating a List of Figures in my project, all figures are grouped by chapter. I would like to have the whole list without any additional new lines between different chapters.

How it looks like:

Figure 1.1 
Figure 1.2

Figure 2.1

Figure 3.1 
Figure 3.2

How it should:

Figure 1.1 
Figure 1.2
Figure 2.1
Figure 3.1 
Figure 3.2

I tried to apply the following solutions but failed completely :

My main file:

\documentclass[12pt,oneside,titlepage,utf8x]{report}

\usepackage{times,a4wide,multirow,tabularx,graphicx} 
\usepackage{psfrag,fancyhdr,longtable}

\usepackage[T1]{fontenc}
\usepackage{float}
\usepackage[utf8]{inputenc}

\usepackage{url}
\usepackage{color}
\usepackage{verbatim}
\usepackage{fancyvrb}
\usepackage{natbib}
\usepackage{relsize}

\usepackage{caption}
\captionsetup[longtable]{belowskip=10pt}

\usepackage[left=4cm,top=2cm,right=3cm,bottom=2.5cm]{geometry}

\renewcommand{\chaptermark}[1]{\markboth{\nouppercase{\thechapter.\ #1}}{}}
\pagestyle{fancy}
\headheight 30pt
\rhead{}
\lfoot{}
\cfoot{\thepage}
\rfoot{}

\setlength{\parindent}{2em}
\setlength{\parskip}{1em}
\linespread{1.3} 

\begin{document}

\begin{titlepage}
\maketitle
\end{titlepage}

\tableofcontents

\chapter{First}
\label{sec:First}
\input{chapter1/chapter1}

\chapter{Second}
\label{sec:Second}
\input{chapter2/chapter2}

\chapter{Third}
\label{sec:Third}
\input{chapter3/chapter3}

\relsize{-1}
\listoffigures
\normalsize

\bibliography{praca_mgr}
\bibliographystyle{plain}
\nocite{*}

\end{document}
  • 1
    The two linked answers deal with different situations: the classicthesis package and the scrreprt class feature a way for disabling the added space, while report doesn't. Don't load a4wide which is dangerous; also times should be mathptmx; remove the utf8x option from the \documentclass line. Do you really need psfrag? If not leave it alone. – egreg Jun 30 '13 at 21:00
11

This is done automatically when you call \chapter, as can be seen from its definition in book.cls and report.cls:

\newcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
                    \thispagestyle{plain}%
                    \global\@topnum\z@
                    \@afterindentfalse
                    \secdef\@chapter\@schapter}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                       \if@mainmatter
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}#1}%
                       \else
                         \addcontentsline{toc}{chapter}{#1}%
                       \fi
                    \else
                      \addcontentsline{toc}{chapter}{#1}%
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}% <-- Gap in LoF
                    \addtocontents{lot}{\protect\addvspace{10\p@}}% <-- Gap in LoT
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}

Add the following to your document preamble:

\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
% \patchcmd{<cmd>}{<search>}{<replace>}{<succes>}{<failure>}
\patchcmd{\@chapter}{\addtocontents{lof}{\protect\addvspace{10\p@}}}{}{}{}% LoF
\patchcmd{\@chapter}{\addtocontents{lot}{\protect\addvspace{10\p@}}}{}{}{}% LoT
\makeatother

The above patch removes the insertion of \addvspace to both the LoF and the LoT; the cause of the additional gap between entries on a per-chapter basis.

enter image description here

\documentclass{report}
\newcommand{\insertfigure}{\begin{figure}\caption{A figure}\end{figure}}
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
% \patchcmd{<cmd>}{<search>}{<replace>}{<succes>}{<failure>}
\patchcmd{\@chapter}{\addtocontents{lof}{\protect\addvspace{10\p@}}}{}{}{}
\patchcmd{\@chapter}{\addtocontents{lot}{\protect\addvspace{10\p@}}}{}{}{}
\makeatother
\begin{document}
\tableofcontents
\listoffigures
\chapter{A chapter}\insertfigure\insertfigure\insertfigure
\chapter{A chapter}\insertfigure\insertfigure\insertfigure
\chapter{A chapter}\insertfigure\insertfigure\insertfigure
\chapter{A chapter}\insertfigure\insertfigure\insertfigure
\end{document}

You can choose to use either both or only one by commenting out the required patch. An easier patch to remove both gap insertions would be

\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
\def\@gobblesix#1#2#3#4#5#6{}
\patchcmd{\@chapter}% <cmd>
  {\chaptermark{#1}}% <search>
  {\chaptermark{#1}\@gobblesix}% <replace>
  {}{}% <success><failure>
\makeatother
  • I had to solve the same problem. However my file originally used package bm, and this solution (using etoolbox) would not work. The workaround was to use \mathbf instead of \bm. It works now. – Juan Zuluaga Jan 5 '14 at 17:18
  • None of these patches worked for me, but disabling \addvspace in the list of figures worked: tex.stackexchange.com/a/793/88028 – antoine Oct 9 '15 at 1:05
  • @Antoine: These patches will only work if the <search> term is found. If you're using a different class, then the construction of the <cmd> macro might be different and not contain the <search> term exactly. – Werner Oct 9 '15 at 5:32
  • @Werner: I see. I'm indeed using a custom class, but there is \addtocontents{lof}{\protect\addvspace{10\p@}}% under the \@chapter command. Anyway, it's not a big deal :) – antoine Oct 9 '15 at 20:02
4

This is a quick and dirty solution that works for tufte-book, and doesn't require any additional packages. I just temporarily overwrite the \addvspace command with a dummy command. Important is to reverse back to the old definition for the rest of the document.

 \let\origaddvspace\addvspace
 \renewcommand{\addvspace}[1]{}
 \listoffigures
 \listoftables
 \renewcommand{\addvspace}[1]{\origaddvspace{#1}}
  • The question was about the report class and the spacings there. While your solution might work as well, you should elaborate a little bit on it and provide an example – user31729 Nov 2 '14 at 16:06

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.