13

I include three lists: \listoffigures, \listoftables, and \lstlistoflistings. However each list on a new page. I don't want to have a page break after each list but to list all three on one page.

After some googling I found out that this behavior is connected to the document class. My documents is using scrreprt and I cannot (don't want to) change the type.

If I'm not mistaken I need to rewrite / overwrite these commands to remove the page breaks. But I don't know how to do this.

2
  • 1
    The page break is due to a \clearpage which is placed inside the commands \listoffigures etc. You have to relax \clearpage. See the answer here: tex.stackexchange.com/questions/187602/…, especially at the end of the document, just replace the \printbibliography with your \listof.... commands and omit the \addcontentsline in it.
    – user31729
    Commented Jul 4, 2014 at 6:48
  • 1
    Or see the approach here: tex.stackexchange.com/q/162681 (and please add an MWE, as always).
    – LaRiFaRi
    Commented Jul 4, 2014 at 6:49

1 Answer 1

15

One way is to relax \clearpage, such that is doing nothing when called.

Other possibilities (not in here): Redefine the commands \listoftables etc. and remove the \clearpage in there or use etoolbox package in order to patch them or the answer given in the link in LariFaRi's comment.

Of course, the content lists will not fit on one page if there are a lot entries in them.

\documentclass[paper=a4,12pt]{scrreprt}

\usepackage{listings}
\usepackage{hyperref}


\begin{document}

\let\LaTeXStandardClearpage\clearpage
\let\clearpage\relax  % Do nothing when a \clearpage command appears 
\listoffigures
\listoftables
\lstlistoflistings

\let\clearpage\LaTeXStandardClearpage % Return to the old definition


\chapter{First}

\begin{figure}

\caption{Dummy figure}
\end{figure}

\newpage

\begin{table}

\caption{Dummy table}

\end{table}





\chapter{Second}
\section{First}

\begin{lstlisting}[language=C, caption={Hello World in C}]
#include <stdio.h>

\int main( void )
{
 printf("Hello World\n");
 return(0);
}


\end{lstlisting}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .