0

Can you tell me why the sub-enumerate environment isn't horizontally aligned after using \restoregeometry?

\documentclass{article}
\usepackage{geometry, lipsum}

\begin{document}
\begin{enumerate}
\item 
\newgeometry{} \restoregeometry
\item \lipsum[1]
\begin{enumerate}
\item \lipsum[2] %Why is the right hand side of this paragraph not horizontally aligned with the rest of the text?
\end{enumerate}
\item \lipsum[3]
\end{enumerate}
\end{document}

enumerate non-alignment

  • both commands are intended to be used at the top level, if you use it mid-list nothing good is likely to happen. – David Carlisle Apr 21 '17 at 19:33
  • 1
    I think the reason is that the \leftmargini etc. values are used before the new level of enumeration starts and inserting new geometry layout does update the \leftmargini values, but enumerate does not reevaluate those registers – user31729 Apr 21 '17 at 20:10
1

\newgeometry resets \linewidth to the default \textwidth. You can reset is to the correct value for the list like this.

\documentclass{article}
\usepackage{geometry}
\usepackage{lipsum}

\begin{document}
\begin{enumerate}
\item aa
 \newgeometry{} \restoregeometry
 \advance\linewidth -\rightmargin
 \advance\linewidth -\leftmargin
\item \lipsum[1]
\begin{enumerate}
\item \lipsum[2] %Why is the right hand side of this paragraph not horizontally aligned with the rest of the text?
\end{enumerate}
\item \lipsum[3]
\end{enumerate}
\end{document}

But on the whole it would be better not to use \newgeometry in the middle of an environment. It doesn't expect this.

0

I have found a solution:

\documentclass{article}
\usepackage{geometry, lipsum}

\begin{document}
\begin{enumerate}
\item 
\end{enumerate}
\newgeometry{} \restoregeometry
\begin{enumerate} \setcounter{enumi}{1}
\item \lipsum[1]
\begin{enumerate}
\item \lipsum[2]
\end{enumerate}
\item \lipsum[3]
\end{enumerate}
\end{document}

enter image description here

  • If you would use the enumitem package, you could even apply the resume key such that you don't need to store the enumi counter. If you have a second level list, your approach is error-prone, I think – user31729 Apr 21 '17 at 19:51

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.