2

I want to add a small icon right left of the Subject line in a scrlttr2 file. I already managed this for a scrartcl file, but don't now how to do this in a letter. Can you help me?

The code from the scrartcl.cls is:

\newcommand{\unquad}{\hskip-1.3em\relax}
\DeclareRobustCommand{\picturetodisplay}{\includegraphics{Bilder/Spiel_Start.jpg}} 
\makeatletter
\def\@seccntformat#1{\unquad\unquad\picturetodisplay\quad}
\makeatother

Does anyone know, how the reference for the subject is called in scrlttr2?

MWE

\documentclass[a4paper, fontsize=10pt, DIV 14]{scrlttr2}
\KOMAoptions{%
    locfield=wide, %
    fromalign=left,%
    fontsize=10pt, %
    parskip=half   %
}
\LoadLetterOption{DINmtext}

\usepackage[utf8]{inputenc} 
\usepackage[ngerman]{babel} 
\usepackage[T1]{fontenc}
\usepackage[scaled=.92]{helvet}

%------------------- It's all about this part -----------------------
\newcommand{\unquad}{\hskip-1.3em\relax}
\DeclareRobustCommand{\picturetodisplay}{\includegraphics{Bilder/Spiel_Start.jpg}} % This is the icon I want to use
\makeatletter
\def\@seccntformat#1{\unquad\unquad\picturetodisplay\quad}
\makeatother
%-------------------------------------------------------------------

\usepackage{blindtext}


\setkomavar{subject}{$\leftarrow$ There should appear the icon \glqq Spiel\_Start.jpg\grqq{}}
\begin{document}
    \setkomavar{fromname}{Me}
    \begin{letter}{Jon Doe}
    \opening{Hey,}
    \blindtext


    \closing{Thank You. Over and out}

    \end{letter}

\end{document}

The hacked scrartcl sections look like this:

Hacked_sections

Thank you Michael

  • I mean somthing like the "seccountformat" in scrartcl – Michael Schmid Feb 25 at 11:05
2

You can simply add \includegraphics[width=1cm]{example-image-a} at the point where you want to get the icon. Because I do not have your used image I simply used image example-image-a.jpg frpm package MWE (which must be installed but not called!).

See the complete code (I deleted your code of the code snippet because it is not needed/used here):

\documentclass[a4paper, fontsize=10pt, DIV 14]{scrlttr2}
\KOMAoptions{%
    locfield=wide, %
    fromalign=left,%
    fontsize=10pt, %
    parskip=half   %
}
\LoadLetterOption{DINmtext}

\usepackage[utf8]{inputenc} 
\usepackage[ngerman]{babel} 
\usepackage[T1]{fontenc}
\usepackage[scaled=.92]{helvet}
\usepackage{graphicx}

\usepackage{blindtext}

\setkomavar{subject}{\includegraphics[width=1cm]{example-image-a}$\leftarrow$ There should appear the icon \glqq Spiel\_Start.jpg\grqq{}}


\begin{document}
    \setkomavar{fromname}{Me}
    \begin{letter}{Jon Doe}
    \opening{Hey,}
    \blindtext


    \closing{Thank You. Over and out}

    \end{letter}

\end{document}

and the resulting pdf:

resulting pdf

2

You could use variable subjectseparator:

\documentclass[a4paper, fontsize=10pt, DIV=14]{scrlttr2}% <- syntax changed: DIV=14
\KOMAoptions{%
    locfield=wide, %
    fromalign=left,%
    fontsize=10pt,%
    parskip=half,%
    subject=titled % <- added
}
\LoadLetterOption{DINmtext}

\usepackage[utf8]{inputenc} 
\usepackage[ngerman]{babel} 
\usepackage[T1]{fontenc}
\usepackage[scaled=.92]{helvet}
\usepackage{graphicx}

\usepackage{blindtext}

\setkomavar{subject}{$\leftarrow$ There should appear the icon \glqq Spiel\_Start.jpg\grqq{}}
\setkomavar{subjectseparator}[]{\makebox[0pt][r]{\includegraphics[width=1.5em]{example-image}\enskip}}% <- added


\begin{document}
\setkomavar{fromname}{Me}
\begin{letter}{Jon Doe}
\opening{Hey,}
\blindtext
\closing{Thank You. Over and out}
\end{letter}
\end{document}

Result:

screenshot

Additional remark regarding your scrartcl hack: if you use a KOMA-Script class, avoid the redefinition of an internal command. You could redefine \sectionlinesformat or maybe \sectionformat (depending on the desired result).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.