跳到内容

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

LaTeX Error: There's no line here to end..

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}

Enumitem.PNG

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}

Leavevmode.PNG

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}

Centerskip.PNG

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

LaTeX Basics

Mathematics

Figures and tables

References and Citations

Languages

Document structure

Formatting

Fonts

Presentations

Commands

Field specific

Class files

Advanced TeX/LaTeX