LaTeX Error: There's no line here to end
If you use a line-breaking command such as \\
or \newline
at a time when LaTeX is not expecting it, you will generate the error shown below:
main.tex, line 12
See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.8 \\ Your command was ignored. Type I <command> <return> to replace it with another command, or <return> to continue without it.
Common Causes
Using a linebreak \\ when it is not appropriate:
One common cause of this error is if a line-break command such as \\
or \newline
is used inappropriately. If LaTeX encounters a line-break command when it is not building a paragraph, it will generate an error. An example of this mistake is shown below:
\\ We have put a line-break in the wrong place
In the above example, a line-break has been inserted with no text before it. LaTeX doesn't know what to do since it cannot break the line which doesn't exist, so it returns an error.
Putting a line-break after a list environment:
This error can also appear if you attempt to place a line-break after a list environment as shown below
\begin{itemize}
\item This is a list item
\item This is another list item
\end{itemize}\newline
LaTeX does not see this list as a paragraph, but rather as a separate grouping of objects, and as such it does not find a line to break. If you would like there to be more space beneath all of your lists, it is best to redefine the itemize
in your preamble or class file, however for a one time case, this error can be avoided by writing \leavevmode
in front of the line-break command as shown below:
\begin{itemize}
\item This is a list item
\item This is another list item
\end{itemize}\leavevmode\newline
Trying to write a list item label on a line of its own:
Another common reason for this error to occur is if you are trying to write a list with labels using the description
environment, and you would like the label to be on a line of its own. An example how a mistake would be made here is shown below:
\begin{description}
\item[This is our label] \\
We would like this text to be on its own line.
\end{description}
This will generate an error, as LaTeX sees the label entry as an argument of the \item
command, and not as part of a paragraph of text. If you would like to have the labels in your list be on separate lines to the list entries, you would have to redefine the description
environment. The easiest way to do this is by using the enumitem
package, and including \setlist[description]{style=nextline}
in your preamble as shown below:
% In your preamble
\usepackage{enumitem}
\setlist[description]{style=nextline}
% In the main body of your document
\begin{description}
\item[This is our label]
We would like this text to be on its own line.
\end{description}
This will give the desired result, by making all labels appear on a separate line to the list entry.
If you would prefer to simply have only one label be on a separate line, you can do this by using the \leavevmode
command, as shown below:
\begin{description}
\item[This is a label] \leavevmode \\
This text will appear on its own line
\item[This is another label] This text will be on the same line as the label.
\end{description}
This is because LaTeX encounters such errors when it is trying to skip lines in vertical mode. The \leavevmode
command causes the compiler to temporarily leave vertical mode, so the error is avoided.
Creating whitespace when using the center, flushleft or flushright environments:
Another cause of this error appearing is when you have tried to include multiple line-breaks by writing
\\\\
\\\newline
\newline\newline
- etc.
while in the center
, flushleft
or flushright
environments as shown below
\begin{center}
We would like there to be a one line gap between this line \\\\
and this line
\end{center}
This is not allowed in LaTeX, and will generate an error. The correct way to include multiple line-breaks here is to write \\[length]
where length
is the distance you would like between the lines. An example is shown below:
\begin{center}
We would like there to be a one line gap between this line \\[2\baselineskip]
and this line
\end{center}
Here, the \\[2\baselineskip]
command tells latex to skip two lines at that point. The different measurement options for the distances you can input in the length
option are listed here.
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Using the Overleaf project menu
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Using the History feature
- Debugging Compilation timeout errors
- How-to guides
- Guide to Overleaf’s premium features
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Matrices
- Fractions and Binomials
- Aligning equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
- Using the Symbol Palette in Overleaf
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management with bibtex
- Bibliography management with natbib
- Bibliography management with biblatex
- Bibtex bibliography styles
- Natbib bibliography styles
- Natbib citation styles
- Biblatex bibliography styles
- Biblatex citation styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- Multilingual typesetting on Overleaf using babel and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections, equations and floats
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typesetting exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class