11

I'm creating a document where I want to leave white space of varying heights, e.g. for handwritten answers to questions.

It doesn't matter whether this empty space is bordered or not.

The key thing is that it needs to break across pages, so if I asked for a space of height 6in, but there was only 3in left on the page, I would get 3in on the first page and 3in on the next.

For instance I saw someone use this code here

\def\boxpar[#1]#2#3{{\setlength{\fboxsep}{-\fboxrule}\fbox{\parbox[][#2][t]{#1}{\mbox{}\\[-.125\baselineskip]\mbox{}~#3}}}}

\boxpar[\hsize]{6in}{}

which will create a bordered box 6in tall and the width of the page as required, but if there is not enough space on the first page it will move the whole thing to the next page.

James
  • 113

3 Answers3

9

Just produce paragraphs, that don't disappear. In order to specify any dimension, just make many of them.

\documentclass{article}
\usepackage{lipsum}

\newcommand{\answerspace}[2][n]{%
  \par\smallskip
  \begingroup
  \if#1r\hrule\fi
  \baselineskip=\dimexpr#2/100\relax
  \lineskip=0pt \parindent=0pt
  \count255=0
  \loop\ifnum\count255<100
    \advance\count255 by 1
    \leavevmode\vbox to\baselineskip{}
    \if#1r\vrule\hfill\vrule\fi\endgraf
  \repeat
  \if#1r\hrule\fi
  \smallskip
  \endgroup
}

\begin{document}
\lipsum[1]

\answerspace[r]{2in}

\lipsum[2]

\answerspace{6in}

\lipsum[3]
\end{document}

With \answerspace[r]{<length>} rules are made.

enter image description here

egreg
  • 1,121,712
7

Let try to answer the question using the package mdframed. (Github-version: https://github.com/marcodaniel/mdframed -- newer)

The provided command \boxpar has the following syntax:

\boxpar[<number of lines>]{Text}[<width of the box>]

You can the the number and the width are optional.

mdframed cant split across pages using a simple\vspace`. Therefor the loop is needed.

\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}

\newcounter{tempcount}
\NewDocumentCommand \boxpar {  O{3} m O{\linewidth} }{%
 \begin{mdframed}[align=center,innertopmargin=.4cm,userdefinedwidth=#3]
     \setcounter{tempcount}{0}
     \loop\ifnum\value{tempcount}<#1
        \rule{0pt}{\baselineskip}\\[2pt]      
       \stepcounter{tempcount}
     \repeat
     \ifx\relax#2\relax\else#2\fi
  \end{mdframed}%
}
\begin{document}
\lipsum[1]

\boxpar{}

\lipsum[2]

\boxpar[10]{}[8cm]


\boxpar[6]{3 Points}[8cm]
\end{document}

enter image description here

If you want to modify the style of the frame you can do this by options of mdframed

\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
\mdfdefinestyle{boxpar}{linewidth=2pt,backgroundcolor=gray!10,roundcorner=10pt,}
\usepackage{lipsum}

\newcounter{tempcount}
\NewDocumentCommand \boxpar {  O{3} m O{\linewidth} }{%
 \begin{mdframed}[align=center,innertopmargin=.4cm,userdefinedwidth=#3,style=boxpar]
     \setcounter{tempcount}{0}
     \loop\ifnum\value{tempcount}<#1
        \rule{0pt}{\baselineskip}\\[2pt]      
       \stepcounter{tempcount}
     \repeat
     \ifx\relax#2\relax\else#2\fi
  \end{mdframed}%
}
\begin{document}
\lipsum[1]

\boxpar{}

\lipsum[2]

\boxpar[10]{}[8cm]


\boxpar[6]{3 Points}[8cm]
\end{document}

If you want horizontal lines you can use:

\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
\mdfdefinestyle{boxpar}{linewidth=2pt,backgroundcolor=gray!10,roundcorner=10pt,}
\usepackage{lipsum}

\newcounter{tempcount}
\NewDocumentCommand \boxpar {  O{3} m O{\linewidth} }{%
 \begin{mdframed}[align=center,innertopmargin=.4cm,userdefinedwidth=#3,style=boxpar]
     \setcounter{tempcount}{1}
     \loop\ifnum\value{tempcount}<\numexpr#1+1\relax
 %       \rule{0pt}{\baselineskip}\\[2pt]      
       \the\value{tempcount}\rule{\linewidth}{.8pt}\\[2pt]
       \stepcounter{tempcount}
     \repeat
     \ifx\relax#2\relax\else#2\fi
  \end{mdframed}%
}
\begin{document}
\lipsum[1]

\boxpar{}

\lipsum[2]

\boxpar[10]{}[8cm]


\boxpar[6]{3 Points}[8cm]
\end{document}

enter image description here


You can also add a title:

\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
\mdfdefinestyle{boxpar}{linewidth=2pt,backgroundcolor=gray!10,roundcorner=10pt,frametitle=Room for your answer,frametitlerule=true}
\usepackage{lipsum}

\newcounter{tempcount}
\NewDocumentCommand \boxpar {  O{3} m O{\linewidth} }{%
 \begin{mdframed}[align=center,innertopmargin=.4cm,userdefinedwidth=#3,style=boxpar]
    \setcounter{tempcount}{0}
     \loop\ifnum\value{tempcount}<#1
        \rule{0pt}{\baselineskip}\\[2pt]      
       \stepcounter{tempcount}
     \repeat
     \ifx\relax#2\relax\else#2\fi
  \end{mdframed}%
}
\begin{document}
\lipsum[1]

\boxpar{}

\lipsum[2]

\boxpar[5]{}[8cm]


\boxpar[6]{3 Points}[8cm]
\end{document}

enter image description here

Marco Daniel
  • 95,681
  • Thanks for this answer as well, tried using mdframed earlier but struggled with it, so this is a helpful example for future reference! – James May 01 '13 at 11:25
  • @James: If you have any trouble you can contact the author ;-) -- me ;-) – Marco Daniel May 01 '13 at 11:32
6

enter image description here

Remove the \vrule\strut\hfill\vrule If you don't want the lines either side.

\documentclass{article}

\def\blanklines#1{%
\ifnum#1>0
\par\noindent\mbox{}\vrule\strut\hfill\vrule\par%
\expandafter\blanklines\expandafter{%
  \the\numexpr#1-1\expandafter\relax\expandafter}%
\fi
}

\begin{document}

stuff

more stuff\par more stuff\par more stuff\par more stuff\par more stuff\par


\blanklines{16}

more stuff\par more stuff\par more stuff\par more stuff\par more stuff\par

\blanklines{25}

more stuff\par more stuff\par more stuff\par more stuff\par more stuff\par

\end{document}
David Carlisle
  • 757,742