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}{}
\KOMAoptions{addrfield=false}% or \KOMAoption{addrfield}{false}
\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}
\xpretocmd{\letter}{\IfArgIsEmpty{#2}{\KOMAoptions{addrfield=false}}{}}{}{\PatchFailed}
\begin{document}
\begin{letter}{}
%\setkomavar{toname}{Bar}
%\setkomavar{toaddress}{Bar Address}
\opening{}
\closing{}
\end{letter}
\begin{letter}{Foo\\Foo Address}
\opening{}
\closing{}
\end{letter}
\end{document}
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
.
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