# 'Undefined control sequence \setkomavar'

I ran into the error:

'Undefined control sequence
l.12 \setkomavar{subject}{Regarding: Code 123.456}'


My document preamble looks like this:

\documentclass{letter}
\usepackage{hyperref}
\usepackage[english]{babel}

\signature{M.Y. Name}

\begin{document}

\begin{letter}{Recipient \\ I know where your bed sleeps \\ I know where your house lives}

\setkomavar{subject}{Regarding: Code 123.456}

\end{letter}

\end{document}


What went wrong?

• \setkomavar is defined for the KOMA-Script classes, such as scrlettr. It's not a common command for all LaTeX classes. – egreg Jul 2 '13 at 15:04
• \setkomavar is only defined in the scrlttr2 class. (scrlettr would be deprecated anyway). – clemens Jul 16 '13 at 9:16
• You might find the etoolbox package of interest if you want commands generally equivalent to \setkomavar. See especially '§ 3.1.1 Macro Definitions'. – jon Jul 16 '13 at 14:06

As egreg already mentioned in his comment the command \setkomavar is part of the letter class scrlttr2 (thanks cgnieder) of the so called Koma-Script (see here). The most important Koma-Script classes are
• scrartcl (alternative to article)
• scrreprt (alternative to report)
• scrbook (alternative to book)
• scrlttr2 (alternative to letter)
In general the Koma commands are not defined in every documentclass. An example how to use the letter class can be found here (Wikipedia).
• This is not precise enough: \setkomavar is not defined for all KOMA classes but only for scrlttr2! – clemens Jul 15 '13 at 9:43