[Tex/LaTex] Problem about double space in list of figures when using endfloat package

endfloatline-spacingtable of contents

I'm writing a manuscript using endfloat to make all the figures at the end of the article.

However, when using the code below to eliminate numbers from lists of figures, the definition \AtBeginDelayedFloats{\renewcommand{\baselinestretch}{1.4}} does not work:

\renewcommand*{\l@figure}[2]{%
\setlength\@tempdima{2.3em}%
\noindent\hspace*{1.5em}#1\hfil\newline }

By the way, \renewcommand{\baselinestretch}{1.4} works well if the above code does not exist.

Any suggestion?

MWE

\documentclass{article}
\usepackage[lists]{endfloat}

\AtBeginDelayedFloats{\renewcommand{\baselinestretch}{1.4}}

\makeatletter
\renewcommand*{\l@figure}[2]{%
\setlength\@tempdima{2.3em}%
\noindent\hspace*{1.5em}#1\hfil\newline }
\makeatother

\begin{document}

\section{title}
text text text text text text text text text text text text text text text   text text text text text text text text text text text

\begin{figure}[!ht]\caption{This is caption 1}\end{figure}
\begin{figure}[!ht]\caption{This is a long caption 2 This is a long caption 2 This is a long caption 2 This is a long caption 2}\end{figure}


\end{document}

Best Answer

There are three problems in your input.

  1. Redefinitions of code that contains commands with an @ in their names should be surrounded by special commands

    \makeatletter
    \renewcommand*{\l@figure}[2]{%
      \setlength\@tempdima{2.3em}%
      \noindent\hspace*{1.5em}#1\hfil\newline }
    \makeatother
    

    Unfortunately the documentation of endfloat doesn't make this very clear.

  2. The code for figures must be properly input with \begin{figure} and \end{figure} on lines by themselves:

    \begin{figure}[!htp]
    <code for the figure>
    \caption{The caption}\label{label}
    \end{figure}
    

    (the \label is optional, of course).

  3. Changing the definition of \baselinestretch is not sufficient, in general for getting increased line space: often the first paragraph will not be spaced. Use

    \AtBeginDelayedFloats{\linespread{1.4}}