In a letter-class document that had no previous errors I am suddenly getting the error message:
"There's no line here to end" \opening{text}
I've used this file many times and today it starts giving this error. How do I troubleshoot this?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityIn a letter-class document that had no previous errors I am suddenly getting the error message:
"There's no line here to end" \opening{text}
I've used this file many times and today it starts giving this error. How do I troubleshoot this?
Check for \newline
or \\
commands and what comes before. For instance don't write \\\\
to get one further empty line. Possible reasons and solutions are given here in the TeX FAQ: No line here to end.
To complement this: sometimes you really wish to break a line but LaTeX doesn't allow it because you are in vertical mode. In such cases \leavevmode
directly before \newline
or \\
helps. Some people use a quick fix and insert some empty space like in ~\\
to repair that.
\leavevmode\`
? And between \leavevmode
and \\
there is no space right? What about the other fixes, do you have to remove the space above/below for them?
I have had exactly the same problem with one difference: the source file wasn't mine, I received it by email. It worked for the sender, but I got the "There's no line here to end" error associated with an \opening{}
command in my machine.
Matching the code against a letter class intro in a blog, Geek Thoughts, I found a difference: the lacking of a second argument for \begin{letter}
. Once provided, everything worked fine for me.
Hope it helps.
Empty lines above and below the opening caused the error. Removing the empty lines solved it.
The error observed when using the 'centre' environment in the Title section of the poster (package baposter). Solution: put the title into the minipage environment.
For me, none of the other answers so far worked. I was using the scrlttr2
class and it turned out that I had unused from***
parameters in the KOMAoptions
command.
Probably, this produced empty lines being broken, thereby producing an error exactly at the \opening{...}
line.
Removing the unused from***
options did the trick for me.
Time and again I get this error after a \vspace
, it might also be worth looking for them:
\vspace{1cm} \\
→ \vspace{1cm}
Stefan Kottwitz already mentioned looking for \\
or \newline
. Here is a real-world example that took me awhile to track down. Let's say you have a template setup with some commands separated by new lines \\
.
\fancyhead[LE,RO]{\insertvarA\\\insertvarB\vfill} % from fancyhdr package
If the value of \insertvarA
is an empty string, then the following \\
will cause an error, because TeX will not switch to horizontal mode (it will stay in vertical mode).
Stefan's solution works. Just force TeX out of vertical mode regardless of \insertvarA
's string.
\fancyhead[LE,RO]{\insertvarA\leavevmode\\\insertvarB\vfill} % from fancyhdr package
I had the same massage appearing, too.
In my case the problem was in the graphic files I included in the latex file. One can draw in Inkscape and then convert the pictures to latex files. This way whenever you write something between $ $ in the graphic file, it can be converted to latex type math text and included in the latex file as nice math pictures. The problem occurs if you add another paragraph in the text box in the Inkscape file. Then the conversion gets slightly wrong, i.e. after including it in a latex file and compiling it the picture will look correct, but the program will give you the error :
! Latex Error: There is no line here to end.
The problem is that the line indicated by the Latex compiler is nowhere near the picture that is causing the problems, so you have to find it on your own (I found it moving \end{document} up and down the latex file and checking the compilation messages). Deleting the paragraph in the text box in the graphic file solves the problem.