[Tex/LaTex] Strange “There’s no line here to end” error

errorspreamble

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?

Best Answer

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}