# How to create whitespace in LaTeX?

I'm trying to create a LaTeX document with several blocks of source code included. Between these blocks of code I want to add in a few lines of whitespace. I have tried using \\ however this didn't work.

Here is what I have at the moment...

\lstset{language=Java, caption=ClassA.java}
\begin{lstlisting}
% My code
\end{lstlisting}

\\ % This is where I want to make some whitespace

\lstset{language=Java, caption=ClassB.java}
\begin{lstlisting}
% My code
\end{lstlisting}

-

## migrated from stackoverflow.comOct 30 '11 at 23:30

This question came from our site for professional and enthusiast programmers.

Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. –  Werner Oct 30 '11 at 23:36

\vspace{2cm} is usually good for these sorts of things; it will insert 2cm of vertical space. In certain situations (I forget exactly when) you need to use the starred version, \vspace*{2cm}. Obviously, adjust the length as necessary.

-
The *-version will insert space that doesn't disappear at page breaks. –  egreg Oct 30 '11 at 23:36

Try either \smallskip, \medskip or \bigskip. Or use \vspace.

-

\\ ends a line. If there is no line preceding it, you cannot end it either.

A simple hack for this (in situations where you cannot use \vspace, is to print one space character and then the new line: \ \\.

-