# Vertical spacing for writing answers

I couldn't find any answers to this issue, so I hope you LaTeX gurus can help me out.

I am formatting a study guide with the KOMA scrbook class. Throughout there are (enumerated) lists of discussion questions, and there needs to be vertical space to write down responses. (I imagine this is similar to writing tests, so somebody must have done this before and can tell me how...)

What I'm doing is pretty hacky, I just have manually-inserted \vskips between \items, like this:

\begin{enumerate}
\item Here is the first question.
\vskip 3cm % space to write an answer
\item Here is a second question.
\vskip 3cm
\item Hey look another question.
\vskip 3cm
\end{enumerate}


The problem is that when a pagebreak lands in the middle of such a list, the last question on the page ends up flush to the bottom, so it gets no writing space (except the bottom margin). Also, the spacing above the start of the list is spread out to try and compensate for the stretch.

What I want is

1. to force vertical space after every question, even at the bottom of a page
2. to keep vertical space above the beginning of a question section normal -- extra space can be either added to the bottom question on the page, or stretch applied equally just to the \items in the enumerated list
3. to do this without having to put manual commands at the pagebreaks, because
• this would be a pain to correct if the pagination changes while I edit, and
• this obviously goes against the spirit of LaTeX.

Thx in advance for help, I'm sure it will turn out to be easier than I realize!

Edit: as suggested, I will start reading the enumitem documentation, but meanwhile here is a complete LaTeX file that illustrates how Question 3 doesn't get its full space.

\documentclass{article}

\usepackage[showframe]{geometry}

\usepackage{enumitem}
\setlist[enumerate]{itemsep=8\baselineskip, after=\vspace{8\baselineskip}}

\begin{document}

Lorem ipsum dolor sit amet...

\vskip 8cm

...pronunciation e plu sommun paroles.

\section*{Discussion}
\begin{enumerate}
\item This is the first question
\item This is the second question; both of these should share the
extra stretch from Question 3
\item Here's the third question,
which should trigger a pagebreak so it can get its full allotment of vspace.
\item Question
\item Question
\item Question
\end{enumerate}

Lorem ipsum dolor sit amet...

\end{document}


Edit again: stackexchange is not letting me answer my own question for 8 hours, so here it is here instead...

So the enumitem package didn't help me; maybe it's possible to get it to do what I want, but what did work was to enclose each \item in a \parbox[t]{\linewidth}{item text goes here} (which LaTeX will not break), like this:

\documentclass{article}

\usepackage[showframe]{geometry}

\begin{document}

Lorem ipsum dolor sit amet...

\vskip 8cm

...pronunciation e plu sommun paroles.

\section*{Discussion}
\begin{enumerate}
\item \parbox[t]{\linewidth}{This is the first question\vskip 8\baselineskip}
\item \parbox[t]{\linewidth}{This is the second question; both of these should
share the extra stretch from Question 3\vskip 8\baselineskip}
\item \parbox[t]{\linewidth}{Yay, I'm on the next page!.\vskip 8\baselineskip}
\item \parbox[t]{\linewidth}{Were any of questions 1-3 actually
questions?\vskip 8\baselineskip}
\end{enumerate}

Lorem ipsum dolor sit amet...

\end{document}

-
I suggest you to answer your own question, as soon as you can, and remove the last edit from here... –  karlkoeller Jan 18 at 7:16
And of course it would make more sense to wrap this 'solution' into a macro like \myitem: \newcommand{\myitem}[1]{\item \parbox[t]{\linewidth}{#1\vskip 8\baselineskip}}.... –  jon Jan 18 at 7:28
yes, \myitem is a good idea -- that would have saved me a little time -- and will save me time again if I want to tweak it! I will leave this tab open and try again to answer my own question in the morning. –  user2387508 Jan 18 at 7:36

Always post complete (minimal) documents as it takes a lot of guesswork out of composing suitable answers, but assuming a relatively straightforward document, perhaps this is what you mean:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}
\usepackage{enumitem}
\setlist[enumerate]{itemsep=8\baselineskip, after=\vspace{8\baselineskip}}
% cheap trick to 'require' \item to have '8\baselineskip':
\usepackage{etoolbox}  % \apptocmd
\usepackage{needspace} % \needspace
\apptocmd{\item}{\needspace{8\baselineskip}}{}{}

\begin{document}

\null\vfill
some text.

\begin{enumerate}
\item Q.

\item Q.

\item Q.

\end{enumerate}
% \newpage % <-- uncomment to compare
%
%
more text.

\end{document}


Remarks

Read the documentation for enumitem to see the other otions/possibilities it allows. \usepackage[showframe]{geometry} is just to help you visualize what is happening. I think using some multiple of \baselineskip is more advisable to the more rigid '3cm' you are asking for, but that is easily changed if you really need it to be 3 cm.

-
OK, thx both for pointer to enumitem. I will add a complete latex file to the original post that still illustrates the problem though, since Question 3 still doesn't get its full space. In this case I would want LaTeX to put only questions 1 and 2 on the first page, and share the stretch equally between questions 1 and 2 (not the text above). –  user2387508 Jan 18 at 5:43
OK I looked through the enumitem documentation, lots in there about horizontal spacing, but not nearly as much for vertical spacing. Is there some way when setting itemsep and after=\vspace..., to force those spaces to be unbreakable? Also I am trying to play around with beginpenalty, midpenalty, and endpenalty, but I can't seem to get those to make a difference –  user2387508 Jan 18 at 6:01
penalty is not the answer. When I use midpenalty=-9999, question 3 still gets shorted on vspace. When I use midpenalty=-10000, every question gets its own page. –  user2387508 Jan 18 at 6:09
Did you mean \apptocmd{\item}{\needspace{8\baselineskip}}{}{}? –  karlkoeller Jan 18 at 6:58
yes I have now tried the enumitem+apptocmd, that did work! I will post that as final answer tomorrow! THX –  user2387508 Jan 18 at 7:50

I'd define a command \answerspace to be appended to the question:

\documentclass{article}

\usepackage[showframe]{geometry}

\usepackage{enumitem}

\begin{document}

Lorem ipsum dolor sit amet...

\vskip 8cm

...pronunciation e plu sommun paroles.

\section*{Discussion}
\begin{enumerate}[before={\widowpenalty 10000 }]
\item This is the first question\nopagebreak
\item This is the second question; both of these should share the
\item Here's the third question,
which should trigger a pagebreak so it can get its full allotment of vspace.\answerspace
\end{enumerate}

Lorem ipsum dolor sit amet...

\end{document}


The command has an optional argument (default 8) to set the desired space. I added also a setting for \widowpenalty so as to leave at least two lines in the next space. If your questions are longer than two lines and you don't want them to be split across pages, use

before={\widowpenalties 1 10000 }


-

Here's an approach similar to what you've already hinted at in your posted question. The difference is that the environment is typeset as you would any other listed environment. But internally the definition of \item has been changed.

\documentclass{article}
\makeatletter
\def\ae@vspace{\par\vspace{2in}}
%% you'll redefine \item.  The first time it's used
%% you want to open a minipage.  But you need to re-redefine
%% \item because upon subsequent calls you want to close
%% the previous minipage.
\def\ae@item@i{%%
\let\item\ae@item@ii
\old@enum@item
\begin{minipage}[t]{\linewidth}}
\def\ae@item@ii{%%
\ae@vspace
\end{minipage}%%
\par
\old@enum@item
\begin{minipage}[t]{\linewidth}}
%% A new environment for handling and managing the spacing.
\newenvironment{myenum}
{\begin{enumerate}
\let\old@enum@item\item
\let\item\ae@item@i%%
{\ae@vspace\end{minipage}\end{enumerate}}

\makeatother
\usepackage[margin=0.5in]{geometry}
\usepackage{lipsum}
\begin{document}

\begin{myenum}
\item \lipsum[1]
\item \lipsum[2]
\item \lipsum[3]
\item \lipsum[4]
\item \lipsum[5]
\item \lipsum[6]
\item \lipsum[7]
\item \lipsum[8]
\item \lipsum[9]
\item \lipsum[10]
\item \lipsum[11]
\item \lipsum[12]
\end{myenum}

\end{document}

-

As discussed above, I'm finally back to "answer my own question"; sorry to the new responders, I haven't had time to investigate your solutions as well -- I'm sure they will be useful down the line!

So the enumitem package didn't help me; maybe it's possible to get it to do what I want, but what did work was to enclose each \item in a \parbox[t]{\linewidth}{item text goes here} (which LaTeX will not break), like this:

\documentclass{article}

\usepackage[showframe]{geometry}

\begin{document}

Lorem ipsum dolor sit amet...

\vskip 8cm

...pronunciation e plu sommun paroles.

\section*{Discussion}
\begin{enumerate}
\item \parbox[t]{\linewidth}{This is the first question\vskip 8\baselineskip}
\item \parbox[t]{\linewidth}{This is the second question; both of these should
share the extra stretch from Question 3\vskip 8\baselineskip}
\item \parbox[t]{\linewidth}{Yay, I'm on the next page!.\vskip 8\baselineskip}
\item \parbox[t]{\linewidth}{Were any of questions 1-3 actually
questions?\vskip 8\baselineskip}
\end{enumerate}

Lorem ipsum dolor sit amet...

\end{document}

-