2

I use \vspace{2\baselineskip} a lot and would like to create a new command for skipping a certain number of lines. Something like \skip{2} for instance instead of using \vspace. I know about the \newcommand stuff in the preamble of my tex file, but how can I use variables in my newcommand so that instead of a 2 in the above example I could put any number of lines to skip?

  • How about \newcommand\skiplines[1]{\vspace{#1\baselineskip}}? – Steven B. Segletes Dec 2 '15 at 15:40
  • 1
    if you find yourself using \vspace at all in a document you should be asking yourself what is wrong, and adjusting to a different document class setup which has the correct space in the first place without needing spacing within the document. What is the context that makes you use it "a lot" ? – David Carlisle Dec 2 '15 at 15:46
  • I'm a math teacher and I use latex to create worksheets for students and different parts of the paper need different blank spaces for response and what not. – ryan Dec 2 '15 at 15:52
  • @DavidCarlisle Regarding your comment about not using \vspace in theory, as it were, the old adage comes to mind: "In theory, theory and practice are the same. In practice, they are not." I am just happy that \vspace was not given the name \@vspace so as to avoid use by us practitioners. – Steven B. Segletes Dec 2 '15 at 16:06
  • 1
    making a blank answer space a given number of lines is perfectly reasonable (@StevenB.Segletes should post his comment as an answer:-) what is less reasonable (but often seen:-) is having one definition of (say) \question but then always over-riding its spacing by adding a baselineskip of space somewhere. In that case it's much better (and easier in the long run) simply to fix \question to have the right space. – David Carlisle Dec 2 '15 at 16:18
2

At its simplest, one can introduce \skiplines{} to add blank multiples of \baselineskip.

\documentclass[oneside]{amsart}
\newcommand\skiplines[1]{\vspace{#1\baselineskip}}
\begin{document}
This is a paragraph.

This is the normal blank space between paragraphs (i.e., none).\skiplines{4}

Here, I have added 4 blank lines to allow the reader to make notes on the 
printed paper.
\end{document}

enter image description here

As David noted in comments, however, except in unusual circumstances, one should not be routinely adding blank space manually. If there is a recurring need, the appropriate amount of space should be added as part of the document format definition (in the preamble, or in the document class itself), rather than in the document text.

Here, in the following MWE, four lines of \vspace are embedded in each \question and may have the number of blank lines varied as the optional argument to \question.

\documentclass[oneside]{amsart}
\newcommand\skiplines[1]{\vspace{#1\baselineskip}}
\newcommand\question[2][4]{\item #2\skiplines{#1}}
\begin{document}
\begin{enumerate}
\question[2]{Who is buried in Grant's tomb?}

\question{What is the meaning of life, the universe, and everything?}

\question{How much wood does a woodchuck chuck, if a woodchuck could chuck wood?}
\end{enumerate}
Back to your regularly scheduled document.
\end{document}

enter image description here

  • What is wrong with manually adding blank space depending on the question that I ask? I agree if I want all my blank spaces to be the exact same amount, but in my case I'm constantly using different amounts of blank space. – ryan Dec 2 '15 at 17:12
  • @ryan In your case, I agree completely. I was deferring to David insofar as one could, in advance, predict the amount of space needed. In your case, that may be impossible. – Steven B. Segletes Dec 2 '15 at 17:16
  • Okay, thanks. I see how both of your solutions would work in my case. Thanks for the help. – ryan Dec 2 '15 at 17:18
0

If you want to add space for answers or comments, you can define

\newcommand{\skiplines}[1]{%
  % end a paragraph
  \par
  % this space should be added to the current page
  \nopagebreak
  % the space should not be swallowed by a page break
  \vspace*{#1\baselineskip}%
}

Now \skiplines{3} will leave a vertical space worthy of three lines.

  • er, why use \vspace* when you've already specified \nopagebreak? – barbara beeton Dec 2 '15 at 20:06
  • @barbarabeeton Consistency; but I have the feeling that it's better like this anyway. – egreg Dec 2 '15 at 20:39

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.