2

I am brand new to LaTeX, and I am quite frustrated at my inability to use the \vspace command after the first line without this weird indent on the first line.

Here is my first attempt at creating vspace after the first and second lines:

\documentclass[arpaper,12pt]{article}
\setlength{\parindent}{0pt}
\begin{document}
\vspace{6pt}test 1\\\vspace{12pt}test 2\\test 3\\test 4\\
\end{document}

This does not apply the 6pt vspace that I am trying to create. This next code produces the vspace that I want but also does this frustrating little indent on only the first line:

\documentclass[arpaper,12pt]{article}
\setlength{\parindent}{0pt}
\begin{document}
\
\vspace{6pt}test 1\\\vspace{12pt}test 2\\test 3\\test 4\\
\end{document}

What exactly does the single \ do in this case that is allowing the vspace to work when it didn't before, and why is it also producing the small indent on that line?

1

Your \ on a line by itself is a space, which is the indent. Here, I instead use \leavevmode, so that the \vspace takes hold, without an associated indent.

\vspace acts differently in vertical and horizontal modes, which can make for confusion. Paraphrasing egreg (Lengths and when to use them), if \vspace is given in mid paragraph it produces a vertical space between the line where it happens to be set and the following, so it is best used between paragraphs.

In your case, you are hoping to use it in horizontal mode, thus the \leavevmode.

\documentclass[arpaper,12pt]{article}
\setlength{\parindent}{0pt}
\begin{document}
\leavevmode
\vspace{6pt}test 1\\\vspace{12pt}test 2\\test 3\\test 4\\
\end{document}

An alternate, perhaps better, syntax:

\documentclass[arpaper,12pt]{article}
\setlength{\parindent}{0pt}
\begin{document}
\leavevmode
test 1\\[6pt]test 2\\[12pt]test 3\\test 4\\
\end{document}
| improve this answer | |

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.