Latex Multiple Linebreaks
LatexLine BreaksLatex Problem Overview
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?
Latex Solutions
Solution 1 - Latex
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]
.
Solution 2 - Latex
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.
Solution 3 - Latex
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
.
Solution 4 - Latex
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.
Solution 5 - Latex
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
Solution 6 - Latex
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
Solution 7 - Latex
I find that when I include a blank line in my source after the \\ then I also get a blank line in my output. Example:
It's time to recognize the income tax as another horrible policy mistake like banning beer, and to return to the tax policies that were correct in the Constitution in the first place. Our future depends on it.
\\
Wherefore the 16th Amendment must forthwith be repealed.
However you are correct that LaTeX only lets you do this once. For a more general solution allowing you to make as many blank lines as you want, use \null to make empty paragraphs. Example:
It's time to recognize the income tax as another horrible policy mistake like banning beer, and to return to the tax policies that were correct in the Constitution in the first place. Our future depends on it.
\null
\null
\null
Wherefore the 16th Amendment must forthwith be repealed.
Solution 8 - Latex
> \\\\
This works on pdfLatex. It creates 2 new lines for you.
Solution 9 - Latex
Maybe try inserting lines with only a space?
\ \\
\ \\
Solution 10 - Latex
This just worked for me:
I was trying to leave a space in the Apple Pages new LaTeX input area. I typed the following and it left a clean line.
\mbox{\phantom{0}}\\