我想在文件的主题行左侧添加一个小图标scrlttr2
。我已经在scrartcl
文件中实现了这个功能,但不知道如何在信件中实现。你能帮助我吗?
代码如下scrartcl.cls
:
\newcommand{\unquad}{\hskip-1.3em\relax}
\DeclareRobustCommand{\picturetodisplay}{\includegraphics{Bilder/Spiel_Start.jpg}}
\makeatletter
\def\@seccntformat#1{\unquad\unquad\picturetodisplay\quad}
\makeatother
有人知道这个主题的参考资料是怎么来的吗scrlttr2
?
平均能量损失
\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}
被黑的scrartcl
部分如下所示:
谢谢你迈克尔
答案1
\includegraphics[width=1cm]{example-image-a}
您只需在想要获取图标的位置添加即可。因为我没有您使用的图像,所以我只是使用了图像example-image-a.jpg
frpm 包 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}
\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}
以及生成的pdf:
答案2
您可以使用变量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}
结果:
关于您的 hack 的补充说明scrartcl
:如果您使用 KOMA-Script 类,请避免重新定义内部命令。您可以重新定义\sectionlinesformat
或可能\sectionformat
(取决于所需的结果)。