1

I'm working on a technical document in which each page has an image followed by a list of information/actions in an itemize or enumerate environment. I'd like to make sure that the page is cleared after each such list, without inserting manual \clearpage commands. What's the best way to redefine the itemize/enumerate environments so that they run \clearpage? One difficulty is that there can be nested lists, and I only want to clear the page after the outermost list ends.

For example:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=\textwidth]{image1.png}
\begin{enumerate}
    \item First item
    \item Second item
        \begin{enumerate}
        \item Sub-list 1
        \item Sub-list 2
        \end{enumerate}
    \item Third item
\end{enumerate}

\includegraphics[width=\textwidth]{image2.png}
...

Actually, the pics are included using figure commands with the [t] flag. The issue I'm having is if the list is very short, then the next list starts on the same page, rather than following on from the image on the next page.

  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Seamus Aug 22 '16 at 11:00
1

I would use the enumitem package and and create a new list type, writing something like this in the preamble (supposing you'll have at most 3 levels):

\usepackage{enumitem}
\newlist{info}{enumerate}{3}
\setlist[info,1]{after=\clearpage}

This way, each first level info list ends up in a \clearpage. In the arguments of \setlist, of course, you can add other specifications as to formatting labels, list layout, &c.

  • Thanks for that. I'm sure it would do exactly what I asked for. Unfortunately, I wasn't quite as clear with my question: I wanted to do this without using a different environment. I'm actually writing the document in markdown, using pandoc to convert it to LaTeX before compiling, and it seems easier to work with the LaTeX template than to change how pandoc outputs lists. – Hugh Mc Namara Aug 22 '16 at 15:52
  • 2
    Then use enumerate and write \setlist[enumerate,1]{after=\clearpage}. I defined a new list type so that ordinary enumerate environments are not changed. Or even simply write for each such list: \begin{enumerate}[after=\clearpage]. – Bernard Aug 22 '16 at 16:03
  • Thanks @Bernard, using \setlist is the best option I've found. As a bonus it gives me more control over spacing around the lists, which I was also looking for. – Hugh Mc Namara Aug 24 '16 at 11:09
1

I managed to find the answer to this myself, and somebody else might find this useful. Since I didn't want to change the environment used (as in @Bernard's answer) a change to how enumerate worked was needed. In the latex source I found how the environment is defined, and this was my solution:

\makeatletter
\newcommand\myendenum{%
    \ifnum \@enumdepth > 1%
        \endlist%
    \else%
        \endlist\clearpage%
    \fi}
\let\endenumerate\myendenum
\makeatother

The check on \@enumdepth makes sure that sub-lists don't break. My first guess was to compare with 0, but 1 worked as I wanted.

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.