8

I am starting my adventure with LaTeX.

I have following code on my preamble:

\usepackage{graphicx}
\usepackage{setspace}
\onehalfspacing
\usepackage{indentfirst}
\usepackage{titlesec}

On third and fifth line I have: LaTeX Error: There's no line here to end
Why?

  • 4
    I get no error. – egreg Jan 02 '13 at 20:17
  • Welcome to TeX.sx! More information on this site can be seen in the faq and the Unofficial TeX-SX FAQ http://meta.tex.stackexchange.com/q/1144/19384 as well as the markdown help http://tex.stackexchange.com/editing-help. Welcome to the community! – Peter Jansson Jan 02 '13 at 20:24
  • I divinate you have a non printable char there after onehalfspacing (or whatever the third line is), that latex interprets as something it would like to print and thus dislikes being in the preamble and which got lost in copying here. – Max Jan 02 '13 at 20:26
  • 9
    99 times out of a hundred that error is caused by mis-using \\ are you sure that the error comes from the code you showed. (It is always best to post a complete small document that reproduces the error) – David Carlisle Jan 02 '13 at 20:36
  • Ok, I started to comment parts of my tex document and line '\ [3cm]' is causing problem. Is this wrong syntax to make some space? – Michał Herman Jan 02 '13 at 21:34
  • 2
    @MichałHerman: It depends on where it's used. Inside tabular or array, then it's fine. Elsewhere, not so much... See #4 in Documents with typical LaTeX errors, or the UK TeX FAQ entry No line here to end. – Werner Jan 02 '13 at 22:21
  • @MichałHerman, delete the empty space after the double backslash. \\[3cm] – Sigur Jan 02 '13 at 22:29
  • 2
    @MichałHerman white space before the optional argument is always allowed (except in ams alignments) – David Carlisle Jan 02 '13 at 23:50
  • 2
    @MichałHerman Remember that paragraphs are ended by leaving a blank line in the input file; if you really need a vertical spacing, use \bigskip after the blank line; but I've typeset several books and almost never felt a compelling reason to use it. Never use \\ for ending paragraphs. – egreg Jan 03 '13 at 00:03

1 Answers1

9

Using \\ at the start of a paragraph (when there is no line to end) is the most common cause of this error. The way to add space between paragraphs is to use \vspace{3cm}

However even \vspace should not normally be needed. You should try to avoid having explicit spacing in the document, it makes the document source very hard to re-use for different page or font sizes and it is usually an indication that the markup is too oriented towards visual rather than logical markup. Sometimes, at the very end of the document editing process you need to assert manual control to optimise the page breaking and insert a space here and there but otherwise any vertical spacing should really be hidden in the definition of structural commands such as \section or \begin{figure}

David Carlisle
  • 757,742