# strange “! LaTeX Error: There's no line here to end” error

I wrote a book in Lualatex. No problem with compilation but now I want to recompile and I get this:

[2<./graphics/ccbygran-eps-converted-to.pdf>]

LaTeX Warning: Reference fig:diagrama-arbre-0' on page 3 undefined on input li
ne 28.

) [3] [4]

! 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.206 \tableofcontents

?


It seems that I have a extra line, but if you see previous compiled version (I have not touched anything since then except putting \RequirePackage{luatex85} in the very beginning of the main document), you see that the error is after page 4 (which corresponds to file drets d'autor).

So, I have no clue why I have this error. Before answer, try to compile to code, please.

• Try to clean aux files and compile again. – Sigur Sep 28 '16 at 13:46
• Usually the error is due to misusing \\ for "leaving a blank line" – egreg Sep 28 '16 at 13:48
• it is unlikely to be related to a luatex update, using \\  when there is no line has always been an error. Look for a \\  at the start of a paragraph. (probably in your table of contents, so you could delete the .toc file and let latex re-create it) – David Carlisle Sep 28 '16 at 17:46
• @Sigur: same error without .aux files – somenxavier Sep 29 '16 at 18:01
• How can I search \\ in all my files? grep -r --color "\\" gives me error. And more important, how to know which gives me error. And why before I have not errot and now I have – somenxavier Sep 29 '16 at 18:10

This is one of those cases where building a minimal working example (MWE) would have let you easily isolate the source of the error.

Now, just giving us a link to a GitHub repo with a bunch of files isn't very nice, but seeing as I didn't have anything better to do this morning, the following reproduces the problem:

\documentclass[a4paper,11pt]{book}
\usepackage{titlesec}
\usepackage{xcolor}
\titleformat
{\chapter} % command
[hang] % shape
{\huge} % format
{1ex} % sep
{
\centering
\\  %%%%%%%%%%%%% <- remove this
} % before-code
[
\vspace{5cm}
] % after-code

\begin{document}
\tableofcontents
\end{document}


And the cause is that you have the \\ after \centering. Remove that, and it works fine. Note that you should use \itshape, not \it.

Here is a version which places the number and chapter name on separate lines:

\documentclass[a4paper,11pt]{book}
\usepackage{titlesec}
\usepackage{xcolor}
\titleformat
{\chapter} % command
[hang] % shape
{\huge} % format
{0ex} % sep %% changed to 0
\centering~\\[1ex]
} % before-code
[
\vspace{1cm}
] % after-code

\begin{document}
\tableofcontents
\chapter{Funky}
Lorem ipsum.
\end{document}

• But really, when you get an error you don't understand, isolate the cause by making an MWE, and if that doesn't help you solve it, then come ask with the MWE, please don't just dump your entire project in our lap. – Torbjørn T. Oct 28 '16 at 15:45
• Someways it's impossible to do a minimal example because you don't know what fails here. By this reason I asked help. Thanks anyway. – somenxavier Oct 28 '16 at 16:59
• @somenxavier -- you need to put something on that line so it's not empty. \phantom{x} would work. so would  (note the space between the $ signs. obviously, what you put on the line should be invisible. – barbara beeton Oct 28 '16 at 19:13 • @somenxavier -- \phantom indeed doesn't work, but \hspace*{1cm} does. (when i posted the earlier comment, i wasn't able to test; i've just tested. not sure why \phantom doesn't work; conceptually it should. tracing shows that it's hanging up while trying to expand \color, but that's as far as i've gotten, and am not inclined to dig deeper.) – barbara beeton Oct 30 '16 at 12:47 • @somenxavier $ \$` works as well, but see the edit to my answer. – Torbjørn T. Nov 8 '16 at 19:17