[Tex/LaTex] Including a signature image in scrlttr2

koma-scriptletters

Hi there: I have a letter template using scrlttr2 and I am trying to insert a signature image. I was using the code posted here texblog and it sort of works. It throws an undefined sequence error, but, if you force the compilation through to the end, it actually produces a document that looks like what it is supposed to. What can I do to improve this? MWE is below. Thank you.

\documentclass[fontsize=12pt, UScommercial9,paper=letter]{scrlttr2}
\usepackage[space]{grffile} %This is necessary because the fromlogo is on a     drive with spaces in its path name
\KOMAoptions{fromlogo=on}
\usepackage{blindtext}
\usepackage{graphicx}
\setkomavar{fromlogo}{\includegraphics[width=3cm]{example-image-golden}} %In my code, this is a link to my company's logo

\renewcommand{\raggedsignature}{\raggedright} % make the signature ragged right
\setkomavar{subject}{Test}

\begin{document}
\begin{letter}{Address\\
City\\
Province
}

\opening{To Whom It May Concern}  

\blindtext

\closing{Yours truly,\\
\fromsig{\includegraphics[scale=0.5]{example-image-golden}}\\ %In my code this is a link to my signature file
\fromname{My name}
} %eg. Regards

\end{letter}
\end{document}

Best Answer

The answer is that this section of the code:

\closing{Yours truly,\\
\fromsig{\includegraphics[scale=0.5]{example-image-golden}}\\ %In my code this is a link to my signature file
\fromname{My name}
} %eg. Regards

actually implies the letter class, not the KOMA-script. I was mixing classes.
This works:

%insert the following in the preamble
\setkomavar{signature}{\includegraphics[width=3cm]{example-image-golden}\\Your name} 
%write the signature as follows 
\closing{Yours truly}