4

The following code gives a compilation error.

\documentclass{report}

\usepackage{changepage}

\begin{document}

\chapter{Text1}

\begin{adjustwidth}{1cm}{2cm}

\section{Text2}

Text3

\begin{quote}
Text4
\end{quote}

\end{adjustwidth}

\end{document}

The error says: "Something's wrong--perhaps a missing \item." in the line of \begin{quote}. The error disappears when I remove either of

  • the line \chapter{Text1}
  • the line \section{Text2}
  • the line Text3
  • the adjustwidth environment

How can this be?

2
  • 2
    Add \leavevemode before you set the section: \begin{adjustwidth}{1cm}{2cm} \leavevmode Jun 24, 2012 at 7:50
  • 1
    Thanks, that works. However, it introduces a blank line. Do you know how this can be avoided? Negative \vspace would not work, because I want to number the lines. Jun 24, 2012 at 10:50

1 Answer 1

4

The nesting fails. I don't know why but the following works:

The relevant part is:

\nointerlineskip\leavevmode

It's the classic 'a lot of stuff is implemented by LaTeX as a trivlist, even though this results in weird error messages' business. As a result, you need something to deal with the \par tokens correctly, which \leavevmode does. Here the complete MWE:

\documentclass{report}

\usepackage{changepage}

\begin{document}

\chapter{Text1}

\begin{adjustwidth}{1cm}{2cm}
\nointerlineskip\leavevmode
\section{Text2}

Text3

\begin{quote}
Text4
\end{quote}

\end{adjustwidth}

\end{document}

You must log in to answer this question.

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