我想写一封带有 KOMA 徽标的信件,放在第一页的右上角。(见附图。)
我在 Win10 上的 TeXLive 中使用 LuaLaTeX。
到目前为止,我的努力setkomavar{firsthead}
并setkomavar{fromlogo}
没有产生任何效果。
使用documentclass{scrartcl}
和scrletter
,我能够使用 firsthead 设置徽标,但我将其上移的尝试失败了。
一位 MWE 表示:
\documentclass[
a4paper,
11pt,
backaddress=off,
pagenumber=no,
fromalign=locationright,
enlargefirstpage=false,
foldmarks=off]{scrlttr2}
\usepackage[margin=2cm]{geometry}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{mwe}
%\makeatletter
% \@setplength{firstheadvpos}{-20mm} % doesn't seem to move logo up
% \@addtoplength[-]{firstheadvpos}{40mm} % also seems to do nothing
%\makeatother
\setkomavar{fromaddress}{Santa Claus\\ North Pole H0H 0H0\\ Canada}
% \setkomavar{firsthead}{\hfill\includegraphics[height=3cm]{example-image}}
\setkomavar{fromlogo}{\includegraphics[width=3cm]{example-image}}
\begin{document}
\begin{letter}{Colin Rowat \\ South Pole}
\opening{Dear Colin,}
\lipsum
\closing{Ho Ho Ho,}
\end{letter}
\end{document}
答案1
您可以添加fromlogo=true
选项然后
\setkomavar{fromlogo}{\smash{\raisebox{1cm}{\includegraphics[width=3cm]{example-image}}}}
将徽标向上移动:
\documentclass[
a4paper,
11pt,
backaddress=off,
pagenumber=no,
fromalign=locationright,
fromlogo=true,% <- added
enlargefirstpage=false,
foldmarks=off
]{scrlttr2}
\usepackage[margin=2cm]{geometry}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{mwe}
\setkomavar{fromaddress}{Santa Claus\\ North Pole H0H 0H0\\ Canada}
\setkomavar{fromlogo}{\smash{\raisebox{1cm}{\includegraphics[width=3cm]{example-image}}}}
\begin{document}
\begin{letter}{Colin Rowat \\ South Pole}
\opening{Dear Colin,}
\lipsum
\closing{Ho Ho Ho,}
\end{letter}
\end{document}
或者您可以删除fromalign
选项并添加
\setkomavar{fromaddress}{Santa Claus\\ North Pole H0H 0H0\\ Canada}
\setkomavar{fromlogo}{\includegraphics[width=3cm]{example-image}}
\setkomavar{location}{\raggedleft\usekomavar{fromaddress}}
\setkomavar{firsthead}{\hfill\usekomavar{fromlogo}}
\documentclass[
a4paper,
11pt,
backaddress=off,
pagenumber=no,
%fromalign=locationright,% <- removed
enlargefirstpage=false,
foldmarks=off
]{scrlttr2}
\usepackage[margin=2cm]{geometry}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{mwe}
\setkomavar{fromaddress}{Santa Claus\\ North Pole H0H 0H0\\ Canada}
\setkomavar{fromlogo}{\includegraphics[width=3cm]{example-image}}
\setkomavar{location}{\raggedleft\usekomavar{fromaddress}}
\setkomavar{firsthead}{\hfill\usekomavar{fromlogo}}
\begin{document}
\begin{letter}{Colin Rowat \\ South Pole}
\opening{Dear Colin,}
\lipsum
\closing{Ho Ho Ho,}
\end{letter}
\end{document}