# A missing address in a letter causes a “There's no line here to end.” error

Consider the following LaTeX file:

\documentclass[12pt]{scrlttr2}
\begin{document}
\begin{letter}{}
\opening{}
\closing{}
\end{letter}
\end{document}


I get the error

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


Why does this error happen, exactly? It goes away if I add something, anything, to the address field, i.e. the second arg of \begin{letter}. For example \phantom{} makes the error go away.

I'm looking for a detailed analysis, which I hope I will learn something from.

• If the address field should be empty use option addrfield=false: \begin{letter}[addrfield=false]{}. If all letters in the document should have empty address fields, then you could use \documentclass[addrfield=false]{scrlttr2} or \KOMAoptions{addrfield=false}. – esdd Jan 27 at 17:58
• @esdd Thanks. That's very helpful. I didn't know there was such an option. – Faheem Mitha Jan 28 at 8:23

the error comes from \\  if there is no text before it ("no line to end") so presumably this class is using \\  after the address. \mbox{} probably the simplest thing that is an invisible text

\errorcontextlines=100


then your document produces the error

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

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...

\GenericError  ...
\endgroup
\\->\ifhmode \unskip \else \@nolnerr
\fi \par \@ifstar {\nobreak \@xcentercr...
<argument> ...font {toname}{\usekomavar {toname}\\

\\@savevbox ...4#5#6->\begingroup \vbox to #2{#1#3
}\if@savevbox@warning \@sa...

\rlap  #1->\hb@xt@ \z@ {#1
\hss }
<argument> ...MessageBreak \string \specialmail }}
}
\vb@t@z ...x \z@ \vbox to\z@ {\color@begingroup #1
\color@endgroup \vss }\set...

\@locfield \ifdim \useplen...
l.5   \opening{}

?


Within the error stack you see the call

\usekomavar {toname}\\


which is adding \\  after toname which will fail if that is empty.

The reason for the error message are explained in the other answers, so my answer is a bit off topic.

To avoid the error message you have to use option addressfield=false. For a single letter this option can be set for the letter environment itself

\begin{letter}[addrfield=false]{}


or using\KOMAoptions or \KOMAOption before \opening:

\begin{letter}{}
\opening{}


If all letters in the document should have empty address fields, then you can set addrfield=false while loading the class

\documentclass[addrfield=false]{scrlttr2}


or using \KOMAoptions or \KOMAOption in the preamble.

You could also patch the letter environment to set addrfield=false automatically if the argument is empty (ie. no space etc.):

\documentclass[12pt]{scrlttr2}
\usepackage{xpatch}

\begin{document}
\begin{letter}{}
%\setkomavar{toname}{Bar}

But then there will be no address field even if the variables toname and toaddress are not empty. Note that these variables can be set in the preamble, outside the letter environment or between \begin{letter}{} and \opening.