0

How can I prevent question 3 from being pushed to the third page here? What causes this anomalous behavior?

\documentclass{article}


\usepackage[margin=1in]{geometry}
\usepackage{fullwidth}
\usepackage{lipsum}
\newcommand{\answerspace}[1]{\begin{fullwidth}[width=\textwidth,skipabove=0pt,skipbelow=10pt]\framebox[\textwidth]{\rule[-.3\baselineskip]{0pt}{#1}}\end{fullwidth}}%

\begin{document}
    \lipsum[1-5]
\begin{enumerate}
    \item What is 1+1?
\answerspace{3cm}
    \item What is 2+1?
\answerspace{5cm}
\item \lipsum[1]
\end{enumerate}
\end{document}
  • Do you rely on fullwidth? Package exsheets provides a command that does what you want. en.wikibooks.org/wiki/LaTeX/Teacher%27s_Corner#Exsheets – Johannes_B Oct 8 '17 at 6:18
  • Thanks @Johannes_B. I'm happy to get rid of fullwidth but exsheets seems overkill. – JPi Oct 8 '17 at 12:35
  • To be clear: I want the box to be full width. And yes, I know I can jump out of enumerate' and resume using enumitem` but since I could be three levels deep, this would be a serious pain. – JPi Oct 8 '17 at 14:07
0

Well, this works:

\documentclass{article}


\usepackage[margin=1in]{geometry}
\usepackage{enumitem}
\usepackage{lipsum}
\newcounter{indentlevel}
\newcommand{\answerspace}[1]{\setlength{\parindent}{-\value{indentlevel}\leftmargin}\par\framebox[\textwidth]{\rule[-.3\baselineskip]{0pt}{#1}}\par}%

\begin{document}
    \lipsum[1-5]
\begin{enumerate}[before*=\stepcounter{indentlevel},after*=\addtocounter{indentlevel}{-1}]
    \item What is 1+1?
\answerspace{3cm}
    \item What is 2+1?
\answerspace{5cm}
\item \lipsum[1]
\end{enumerate}
\end{document}

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.