7

Follow-up question of Why are \listof{}{} and \listoffigures styled differently?...

With the issue mentioned above I finally managed to design my \listof{}{} and \listoffigures as desired but one issue remains unsolved: How to avoid global settings for my document like \setlength{\parskip}{3mm} being applied to list of figures, list of tables, etc.?

MWE: Uncommenting \setlength{\parskip}{3mm} affects the \listoffigures but not the \listof{algo}{List of Algorithms}.

\documentclass[12pt,a4paper,twoside,openright]{report}
 \usepackage[english]{babel}
 \usepackage{float}
  \newfloat{algo}{tbp}{loa}[chapter]
%  \setlength{\parskip}{3mm}
%  \setlength{\parindent}{3mm}
  \frenchspacing
  \sloppy
 \usepackage{etoolbox}
 \makeatletter
  \patchcmd{\@chapter}%
  {\addtocontents{lof}}%
  {\addtocontents{loa}{\protect\addvspace{10pt}}%
   \addtocontents{lof}}%
  {\typeout{*** SUCCESS ***}}{\typeout{*** FAIL ***}}
 \makeatother


 \begin{document}
  \listoffigures
  \listof{algo}{List of Algorithms}

  \chapter{foo}
   \begin{figure}
    \centering
    \rule{1cm}{1cm}
    \caption{A figure}
   \end{figure}
   \begin{algo}
    (algo)
    \caption{An algorithm}
   \end{algo}
   \begin{figure}
    \centering
    \rule{1cm}{1cm}
    \caption{Another figure}
   \end{figure}
   \begin{algo}
    (algo)
    \caption{Another algorithm}
   \end{algo}

  \chapter{bar}
   \begin{figure}
    \centering
    \rule{1cm}{1cm}
    \caption{Yet another figure}
   \end{figure}
   \begin{algo}
    (algo)
    \caption{Yet another algorithm}
   \end{algo}

 \end{document}
9

You shouldn't be setting \parskip to a rigid value, to begin with and probably using the parskip package is better. Just enclose the lists in a group where you set the parskip to zero.

\documentclass[12pt,a4paper,twoside,openright]{report}
\usepackage[english]{babel}
\usepackage{float}
\newfloat{algo}{tbp}{loa}[chapter]

\usepackage{parskip}

\frenchspacing

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@chapter}
  {\addtocontents{lof}}
  {\addtocontents{loa}{\protect\addvspace{10pt}}\addtocontents{lof}}
  {}{}
\makeatother


\begin{document}
\begingroup\setlength{\parskip}{0pt plus .1pt}
\listoffigures
\listof{algo}{List of Algorithms}
\endgroup

\chapter{foo}
...

I would never use a nonzero parskip and a nonzero indentation (to be honest I'd never use a nonzero parskip). Also declaring \sloppy for the whole document is asking for poor typography even when TeX could do better.

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.