views:

430

answers:

6

I use LaTeX to type up programming homeworks for classes. I need to do this:

my line of text blah blah blah

new line of text with blank line between 

I know I can use double slash to break lines \\, but LaTeX will only take the first line break (complains about more) and starts a new line, it produces this :

my line of text blah blah blah  
new line of text with blank line between 

How can I get that extra line break in there so I can have space between my lines of text?

+3  A: 

Insert some vertical space

blah blah blah \\
\vspace{1cm}

to scale to the font, use ex (the height of a lowercase "x") as the unit, and there are various predefined lengths related to the line spacing available, you might be particularly interested in baselineskip.

dmckee
+1  A: 

Do you want more space between paragraphs? Then you can change the parameter \parskip.

For example, try

\setlength{\parskip}{10pt plus 1pt minus 1pt}

This means that the space between paragraphs is usually 10pt, but can grow or shrink by up to 1pt. This means you give LaTeX the ability to change it up to one 1pt in order to achieve a better page layout. You can remove the plus and minus parts to make it always your specified length.

If you are trying to display source code, try the listings package or use verbatim. If you are trying to typeset pseudocode, try the algorithm package.

tkerwin
grow or shrink..?
rlb.usa
I updated it with a better explanation.
tkerwin
+3  A: 

You can use the setspace package which gives you spacing environments, e.g.:

\documentclass{article}
\usepackage{setspace}
\begin{document}
\doublespace
my line of text blah blah blah

new line of text with blank line between
\end{document}

Or use a verbatim environment to control the layout of your code precisely.

martin clayton
Right. If this is programming homework, i.e. source code, then use verbatim.
Steve
+3  A: 

Line break accepts an optional argument in brackets, a vertical length:

line 1
\\[4in]
line 2

To make this more scalable with respect to font size, you can use other lengths, such as \\[3\baselineskip], or \\[3ex].

Seth Johnson
A: 

For programs you are really better off with a verbatim or alltt environment, but if you want a blank line that LaTeX will not bitch about, try

my line of text blah blah blah\\
\mbox{ }\\  %% space followed by newline
new line of text with blank line between 
Norman Ramsey
A: 

While verbatim might be the best choice, you can also try the commands \smallskip , \medskip or guess what, \bigskip .

Quoting from this page:

These commands can only be used after a paragraph break (which is made by one completely blank line or by the command \par). These commands output flexible or rubber space, approximately 3pt, 6pt, and 12pt high respectively, but these commands will automatically compress or expand a bit, depending on the demands of the rest of the page

Adi