我设置了以下文档,我认为我可以很好地为我们的公司整理一份信函模板。但是,我似乎无法使用和nextfoot
。nexthead
komavars
以下是*.tex
:
\documentclass[
DIN,
a4paper,
pagenumber=false,
parskip=half,
fontsize=11pt,
fromalign=right,
fromphone=true,
fromemail=true,
fromrule=false,
foldmarks=true,
footsepline=false
]{scrlttr2}
\RequirePackage[ngerman]{babel}
\RequirePackage{lmodern}
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
\RequirePackage{marvosym}
\RequirePackage{blindtext}
\RequirePackage{xcolor}
\RequirePackage{transparent}
\RequirePackage[hidelinks]{hyperref}
\RequirePackage{graphicx}
\RequirePackage{bm}
\usepackage{blindtext}
\newcommand*{\myfont}{\fontfamily{cmss}\selectfont}
\makeatletter
\@setplength{lochpos}{5.25em}
\@setplength{locvpos}{9em}
\@setplength{locwidth}{12em}
\@setplength{locheight}{15em}
\@setplength{firstfootvpos}{260mm}
\makeatother
\newcommand{\myFirstname}{Samplename}
\newcommand{\myFamilyname}{Samplefamilyname}
\newcommand{\myStreet}{Sample Street 30}
\newcommand{\myTown}{12345 Sampletown}
\newcommand{\myPosition}{Sampleposition}
\newcommand{\myCompanyname}{Sample Company UG}
\newcommand{\myCompanyMail}{\href{mailto:[email protected]}{[email protected]}}
\newcommand{\myCourt}{Gerichtsstand: Amtsgericht Sampletown}
\newcommand{\myRegisterEntry}{Geschäftsregister: HRB 12345678}
\newcommand{\myUstIdNr}{Ust.-ID-Nr.: DE 87654321}
\newcommand{\myCEOstring}{Geschäftsführer:}
\newcommand{\myCEOone}{Sample Name1}
\newcommand{\myCEOtwo}{Sample Name2}
\newcommand{\myCEOthree}{Sample Name3}
\newcommand{\myCEOlist}{\myCEOone, \myCEOtwo, \myCEOthree}
\newcommand{\myCEOs}{\myCEOstring\ \myCEOlist}
\newcommand{\myFromAddrSingle}{\myStreet, \myTown}
\setkomavar{date}{\today}
\setkomavar{fromname}{\myCompanyname}
\setkomavar{signature}{\myFirstname\ \myFamilyname}
\setkomavar{fromaddress}{\myStreet,\\\myTown}
\setkomavar{backaddress}{\myfont\myCompanyname \,\, $\bm\cdot$ \, \myStreet \,\, $\bm\cdot$ \, \myTown}
\setkomavar{place}{Sometown}
\setkomavar{fromphone}[\Mobilefone\,]{+49\,-\,(0)\,123\,-45\,67\,89\,00}
\setkomavar{fromemail}[\Letter\,]{\href{mailto:[email protected]}{[email protected]}}
\setkomavar{fromurl}[\Mundus\,]{\href{https://www.sampledomain.de}{www.sampledomain.de}}
\setkomavar{fromlogo}{\includegraphics[width=5cm,draft]{Banner.png}}
\setkomavar{frombank}{Sample Company UG \\ Samplebank \smallskip\\ IBAN: DE12 3456 7890 0012 3456 78 \\ BIC: ABCDEFG1XYZ}
\renewcommand*\familydefault{\sfdefault}
\setkomavar{subject}{A rather longish dummy sample subject}
\setkomavar{firsthead}{
\raggedright
\raisebox{0pt}[\useplength{backaddrheight}][\depth]
{\textbf{\usekomavar{fromname}} (haftungsbeschränkt) i.Gr.} \\ \medskip
\scriptsize
\myUstIdNr \\
\myRegisterEntry \\
\myCourt \\
\myCEOs \\
\raggedleft
\vskip -5.8em
\usekomavar{fromlogo}
}
\setkomavar{firstfoot}{
\texttransparent{0.6}{
\rule{\textwidth}{.4pt}}
\texttransparent{0.6}{
\parbox[t]{0.3\textwidth}{\footnotesize
\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\textbf{Geschäftsinformation:}} \smallskip \\
\usekomavar{fromname}\\ \smallskip
\myFromAddrSingle \\
\myCEOstring\ \myCEOone,\\ \smallskip
\myCEOtwo, \myCEOthree
\end{tabular}}
\hfill{}
\parbox[t]{0.3\textwidth}{\footnotesize
\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\textbf{Rechtliche Informationen:}} \smallskip \\
\myUstIdNr\\
\myRegisterEntry\\
\myCourt\\
\end{tabular}}
\hfill{}
\parbox[t]{0.3\textwidth}{\footnotesize
\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\textbf{\usekomavar*{frombank}:}} \smallskip \\
\usekomavar{frombank}
\end{tabular}}
}
}
%\setkomavar{nexthead}{\usekomavar{firsthead}}
\setkomavar{nextfoot}{\usekomavar{firstfoot}}
\pagestyle{myheadings}
\setkomavar{location}{
\raggedright
\footnotesize
\textbf{Ansprechpartner:}\\ \medskip
\myFirstname\ \myFamilyname \\
\myPosition \\ \smallskip
\usekomavar*{fromphone}\usekomavar{fromphone}\\
\usekomavar*{fromemail}\usekomavar{fromemail}\\ \bigskip
\textbf{Geschäftskontakt:}\\ \medskip
\usekomavar{fromaddress} \\ \smallskip
\usekomavar*{fromurl}\usekomavar{fromurl}\\
\Letter\,\myCompanyMail
}
% to visualize the position and the size of address and location:
%\LoadLetterOption{visualize}
%\showfields{address,location}
\begin{document}
\begin{letter}{\textbf{Sample Addressee}\\
Sample Avenue 1\\
12345 Sampletown
}
\opening{Sehr geehrte Damen und Herren,}
\blindtext[3]
\closing{\raggedright Mit freundlichen Grüßen}
\end{letter}
\end{document}
有两个问题。首先,虽然运行得很好,但nextfoot
just 不会在 之后中断。无论是 I还是them ,所有内容都保持在同一行上。rule
firstfoot
\linebreak
\vskip
\\
第二个问题是,一旦我删除第 118 行的注释\setkomavar{nexthead}{\usekomavar{firsthead}}
以使nexthead
标题显示,我就会收到以下错误,我不太明白:
LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.153 \end{letter}
我真诚地尝试找到解决方案文档,但作为乳胶新手,我无法理解与我的主题相关的大部分部分。这也是为什么没有真正的MWE
。我真的很难使用所有属性正确配置所有内容scrlttr2
。希望它仍然没问题,有人可以给我指出正确的方向!
答案1
KOMA-Script 信件的第一页empty
默认使用页面样式,布局与“下一页”完全不同。因此页眉、页脚和信件正文的位置与其他页面不同。
但是您可以加载包scrlayer-scrpage
并向 pagestyle 层添加一个新声明的层scrheadings
。此层可以放在与第一页页脚相同的位置,大小也相同。在下面的代码中,还有一些额外的更改,例如删除虚假空格并\\
在页脚行后插入。
\setkomavar{firsthead}{% changed ->
\usekomafont{pageheadfoot}%
\parbox{\useplength{firstheadwidth}}{%
\begin{tabular}[b]{@{}l}
\textbf{\normalsize\usekomavar{fromname}} (haftungsbeschränkt) i.Gr. \\ \medskip
\myUstIdNr \\
\myRegisterEntry \\
\myCourt \\
\myCEOs
\end{tabular}%
\hfill
\usekomavar{fromlogo}%
}%
}
% header and footer first page:
\setkomavar{firstfoot}{% changed ->
\usekomafont{pageheadfoot}%
\parbox{\useplength{firstfootwidth}}{%
\texttransparent{0.6}{%
\rule{\linewidth}{.4pt}\\
\parbox[t]{0.31\linewidth}{%
\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\textbf{Geschäftsinformation:}}\\ \smallskip
\usekomavar{fromname}\\ \smallskip
\myFromAddrSingle \\
\myCEOstring\ \myCEOone,\\ \smallskip
\myCEOtwo, \myCEOthree
\end{tabular}%
}%
\hfill
\parbox[t]{0.31\linewidth}{%
\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\textbf{Rechtliche Informationen:}}\\ \smallskip
\myUstIdNr\\
\myRegisterEntry\\
\myCourt
\end{tabular}%
}%
\hfill
\parbox[t]{0.31\linewidth}{%
\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\textbf{\usekomavar*{frombank}:}} \smallskip \\
\usekomavar{frombank}
\end{tabular}%
}%
}%
}%
}
\setkomafont{pageheadfoot}{\scriptsize}
% header and footer next pages using page style scrheadings:
\usepackage{scrlayer-scrpage}% <- sets pagestyle scrheadings automatically
\DeclareNewLayer[
foreground,
textarea,
voffset=\useplength{firstfootvpos},
hoffset=\dimexpr.5\paperwidth-.5\useplength{firstfootwidth}\relax,
width=\useplength{firstfootwidth},
mode=picture,
contents=\putUL{\raisebox{\dimexpr-\height}{\usekomavar{firstfoot}}}
]{likefirstpage.foot}
\AddLayersToPageStyle{scrheadings}{likefirstpage.foot}
\clearpairofpagestyles
\chead*{\pagemark}
代码:
\documentclass[
DIN,
a4paper,
pagenumber=false,
parskip=half,
fontsize=11pt,
fromalign=right,
fromphone=true,
fromemail=true,
fromrule=false,
foldmarks=true,
footsepline=false
]{scrlttr2}
\usepackage[ngerman]{babel}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{marvosym}
\usepackage{blindtext}
\usepackage{xcolor}
\usepackage{transparent}
\usepackage[hidelinks]{hyperref}
\usepackage{graphicx}
\usepackage{bm}
\usepackage{blindtext}% only for dummy text
%% to visualize the position and the size of address and location:
%\LoadLetterOption{visualize}
%\showfields{address,location,head,foot}
\makeatletter
\@setplength{lochpos}{5.25em}
\@setplength{locvpos}{9em}
\@setplength{locwidth}{12em}
\@setplength{locheight}{15em}
\@setplength{firstfootvpos}{260mm}
\makeatother
\renewcommand*\raggedsignature{\raggedright}% <- added
\newcommand{\myFirstname}{Samplename}
\newcommand{\myFamilyname}{Samplefamilyname}
\newcommand{\myStreet}{Sample Street 30}
\newcommand{\myTown}{12345 Sampletown}
\newcommand{\myPosition}{Sampleposition}
\newcommand{\myCompanyname}{Sample Company UG}
\newcommand{\myCompanyMail}{\href{mailto:[email protected]}{[email protected]}}
\newcommand{\myCourt}{Gerichtsstand: Amtsgericht Sampletown}
\newcommand{\myRegisterEntry}{Geschäftsregister: HRB 12345678}
\newcommand{\myUstIdNr}{Ust.-ID-Nr.: DE 87654321}
\newcommand{\myCEOstring}{Geschäftsführer:}
\newcommand{\myCEOone}{Sample Name1}
\newcommand{\myCEOtwo}{Sample Name2}
\newcommand{\myCEOthree}{Sample Name3}
\newcommand{\myCEOlist}{\myCEOone, \myCEOtwo, \myCEOthree}
\newcommand{\myCEOs}{\myCEOstring\ \myCEOlist}
\newcommand{\myFromAddrSingle}{\myStreet, \myTown}
\setkomavar{date}{\today}
\setkomavar{fromname}{\myCompanyname}
\setkomavar{signature}{\myFirstname\ \myFamilyname}
\setkomavar{fromaddress}{\myStreet,\\\myTown}
\setkomavar{backaddress}{\myCompanyname \,\, $\bm\cdot$ \, \myStreet \,\, $\bm\cdot$ \, \myTown}
\setkomavar{place}{Sometown}
\setkomavar{fromphone}[\Mobilefone\,]{+49\,-\,(0)\,123\,-45\,67\,89\,00}
\setkomavar{fromemail}[\Letter\,]{\href{mailto:[email protected]}{[email protected]}}
\setkomavar{fromurl}[\Mundus\,]{\href{https://www.sampledomain.de}{www.sampledomain.de}}
\setkomavar{fromlogo}{\includegraphics[width=5cm,height=5.8em]{example-image}}
\setkomavar{frombank}{Sample Company UG \\ Samplebank \smallskip\\ IBAN: DE12 3456 7890 0012 3456 78 \\ BIC: ABCDEFG1XYZ}
\renewcommand*\familydefault{\sfdefault}
\setkomavar{location}{% changed ->
\vfill
\raggedright
\footnotesize
\textbf{Ansprechpartner:}\\ \medskip
\myFirstname\ \myFamilyname \\
\myPosition \\ \smallskip
\usekomavar*{fromphone}\usekomavar{fromphone}\\
\usekomavar*{fromemail}\usekomavar{fromemail}\\ \bigskip
\textbf{Geschäftskontakt:}\\ \medskip
\usekomavar{fromaddress} \\ \smallskip
\usekomavar*{fromurl}\usekomavar{fromurl}\\
\Letter\,\myCompanyMail
}
\setkomavar{firsthead}{% changed ->
\usekomafont{pageheadfoot}%
\parbox{\useplength{firstheadwidth}}{%
\begin{tabular}[b]{@{}l}
\textbf{\normalsize\usekomavar{fromname}} (haftungsbeschränkt) i.Gr. \\ \medskip
\myUstIdNr \\
\myRegisterEntry \\
\myCourt \\
\myCEOs
\end{tabular}%
\hfill
\usekomavar{fromlogo}%
}%
}
% header and footer first page:
\setkomavar{firstfoot}{% changed ->
\usekomafont{pageheadfoot}%
\parbox{\useplength{firstfootwidth}}{%
\texttransparent{0.6}{%
\rule{\linewidth}{.4pt}\\
\parbox[t]{0.31\linewidth}{%
\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\textbf{Geschäftsinformation:}}\\ \smallskip
\usekomavar{fromname}\\ \smallskip
\myFromAddrSingle \\
\myCEOstring\ \myCEOone,\\ \smallskip
\myCEOtwo, \myCEOthree
\end{tabular}%
}%
\hfill
\parbox[t]{0.31\linewidth}{%
\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\textbf{Rechtliche Informationen:}}\\ \smallskip
\myUstIdNr\\
\myRegisterEntry\\
\myCourt
\end{tabular}%
}%
\hfill
\parbox[t]{0.31\linewidth}{%
\begin{tabular}[t]{l@{}}
\multicolumn{1}{@{}l@{}}{\textbf{\usekomavar*{frombank}:}} \smallskip \\
\usekomavar{frombank}
\end{tabular}%
}%
}%
}%
}
\setkomafont{pageheadfoot}{\scriptsize}
% header and footer next pages using page style scrheadings:
\usepackage{scrlayer-scrpage}% <- sets pagestyle scrheadings automatically
\DeclareNewLayer[
foreground,
textarea,
voffset=\useplength{firstfootvpos},
hoffset=\dimexpr.5\paperwidth-.5\useplength{firstfootwidth}\relax,
width=\useplength{firstfootwidth},
mode=picture,
contents=\putUL{\raisebox{\dimexpr-\height}{\usekomavar{firstfoot}}}
]{likefirstpage.foot}
\AddLayersToPageStyle{scrheadings}{likefirstpage.foot}
\clearpairofpagestyles
\chead*{\pagemark}
\begin{document}
\begin{letter}{\textbf{Sample Addressee}\\
Sample Avenue 1\\
12345 Sampletown
}
\setkomavar{subject}{A rather longish dummy sample subject}
\opening{Sehr geehrte Damen und Herren,}
\blindtext[3]
\closing{Mit freundlichen Grüßen}% <- changed
\end{letter}
\end{document}
答案2
我无法找出问题的确切原因,但它与 的定义firstfoot
以及第二页及后续页面的 比第一页窄的事实\textwidth
有关(因为它是根据文本的边距而不是地址内容设置的)。所以它根本不合适。我无法说出内部发生了什么。正如您所观察到的:这是一个复杂的类。
我的解决方案是重新设计页脚:我不得不转到\scriptsize
。我删除了表格(它们只是用于格式化),并用简单的替换它们parboxes
。这样做,我摆脱了标题行的缩进,我认为这样看起来更好;但这只是个人喜好问题,如果你想要它们回来,只需\quad
在相关行前添加一个。我设置它们是\raggedright
为了避免在我认为不属于的地方使用连字符。
这留下了一个小问题:银行信息(尤其是 IBAN 号码)比其他信息长,而且 IBAN 号码的中断让人不舒服,所以我稍微放大了那个框,并缩小了另一个框。无论如何,由于框中信息的长度不同,它看起来并不平衡。
我还没有解决页眉问题,因为 (1) 我认为在每一页上都写上完整的地址非常奇怪,并且 (2) 这会导致其他问题,因为您需要向下移动文本边距以适应过高的页眉。如果我是你,我会设计一个不同的页眉,更短一些。
就我个人而言,我也不会在每一页上都放其他信息,但这取决于你!
最后,我不确定你是否真的需要一个 firsthead。我认为你可以用普通命令简单地获得你想要的第一页的排列。但我想,如果它有效的话,那就没错。
这里剩下的缺陷是页脚在第 2 页的位置比第 1 页的位置略高,正如 esdd 在上面的评论中指出的那样。恐怕我还没有解决这个问题。
\documentclass[
DIN,
a4paper,
pagenumber=false,
parskip=half,
fontsize=11pt,
fromalign=right,
fromphone=true,
fromemail=true,
fromrule=false,
foldmarks=true,
footsepline=false
]{scrlttr2}
\RequirePackage[ngerman]{babel}
\RequirePackage{lmodern}
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
\RequirePackage{marvosym}
\RequirePackage{blindtext}
\RequirePackage{xcolor}
\RequirePackage{transparent}
\RequirePackage[hidelinks]{hyperref}
\RequirePackage{graphicx}
\RequirePackage{bm}
\usepackage{blindtext}
\newcommand*{\myfont}{\fontfamily{cmss}\selectfont}
\makeatletter
\@setplength{lochpos}{5.25em}
\@setplength{locvpos}{9em}
\@setplength{locwidth}{12em}
\@setplength{locheight}{15em}
\@setplength{firstfootvpos}{260mm}
\makeatother
\newcommand{\myFirstname}{Samplename}
\newcommand{\myFamilyname}{Samplefamilyname}
\newcommand{\myStreet}{Sample Street 30}
\newcommand{\myTown}{12345 Sampletown}
\newcommand{\myPosition}{Sampleposition}
\newcommand{\myCompanyname}{Sample Company UG}
\newcommand{\myCompanyMail}{\href{mailto:[email protected]}{[email protected]}}
\newcommand{\myCourt}{Gerichtsstand: Amtsgericht Sampletown}
\newcommand{\myRegisterEntry}{Geschäftsregister: HRB 12345678}
\newcommand{\myUstIdNr}{Ust.-ID-Nr.: DE 87654321}
\newcommand{\myCEOstring}{Geschäftsführer:}
\newcommand{\myCEOone}{Sample Name1}
\newcommand{\myCEOtwo}{Sample Name2}
\newcommand{\myCEOthree}{Sample Name3}
\newcommand{\myCEOlist}{\myCEOone, \myCEOtwo, \myCEOthree}
\newcommand{\myCEOs}{\myCEOstring\ \myCEOlist}
\newcommand{\myFromAddrSingle}{\myStreet, \myTown}
\setkomavar{date}{\today}
\setkomavar{fromname}{\myCompanyname}
\setkomavar{signature}{\myFirstname\ \myFamilyname}
\setkomavar{fromaddress}{\myStreet,\\\myTown}
\setkomavar{backaddress}{\myfont\myCompanyname \,\, $\bm\cdot$ \, \myStreet \,\, $\bm\cdot$ \, \myTown}
\setkomavar{place}{Sometown}
\setkomavar{fromphone}[\Mobilefone\,]{+49\,-\,(0)\,123\,-45\,67\,89\,00}
\setkomavar{fromemail}[\Letter\,]{\href{mailto:[email protected]}{[email protected]}}
\setkomavar{fromurl}[\Mundus\,]{\href{https://www.sampledomain.de}{www.sampledomain.de}}
\setkomavar{fromlogo}{\includegraphics[width=5cm,height=2cm,draft]{Banner.png}}
\setkomavar{frombank}{Sample Company UG \\ Samplebank \smallskip\\ IBAN: DE12 3456 7890 0012 3456 78 \\ BIC: ABCDEFG1XYZ}
\renewcommand*\familydefault{\sfdefault}
\setkomavar{subject}{A rather longish dummy sample subject}
\setkomavar{firsthead}{%
\raggedright
\raisebox{0pt}[\useplength{backaddrheight}][\depth]
{\textbf{\usekomavar{fromname}} (haftungsbeschränkt) i.Gr.} \\ \medskip
\scriptsize
\myUstIdNr \\
\myRegisterEntry \\
\myCourt \\
\myCEOs \\
\raggedleft
\vskip -5.8em
\usekomavar{fromlogo}%
}
\setkomavar{firstfoot}{
\parbox{\textwidth}{%
\texttransparent{0.6}{%
\rule{\textwidth}{.4pt}}
\sffamily\upshape\scriptsize
\texttransparent{0.6}{
\parbox[t]{0.3\textwidth}{\raggedright
\textbf{Geschäftsinformation:} \smallskip \\
\usekomavar{fromname}\\ \smallskip
\myFromAddrSingle \\
\myCEOstring\ \myCEOone,\\ \smallskip
\myCEOtwo, \myCEOthree}
\hfill{}
\parbox[t]{0.29\textwidth}{\raggedright
\textbf{Rechtliche Informationen:} \smallskip \\
\myUstIdNr\\
\myRegisterEntry\\
\myCourt\\}
\hfill{}
\parbox[t]{0.33\textwidth}{
\textbf{\usekomavar*{frombank}:} \smallskip \\
\usekomavar{frombank}}
}}
}
%\setkomavar{nexthead}{\usekomavar{firsthead}}
\setkomavar{nextfoot}{\usekomavar{firstfoot}}
\pagestyle{myheadings}
\setkomavar{location}{
\raggedright
\footnotesize
\textbf{Ansprechpartner:}\\ \medskip
\myFirstname\ \myFamilyname \\
\myPosition \\ \smallskip
\usekomavar*{fromphone}\usekomavar{fromphone}\\
\usekomavar*{fromemail}\usekomavar{fromemail}\\ \bigskip
\textbf{Geschäftskontakt:}\\ \medskip
\usekomavar{fromaddress} \\ \smallskip
\usekomavar*{fromurl}\usekomavar{fromurl}\\
\Letter\,\myCompanyMail
}
% to visualize the position and the size of address and location:
%\LoadLetterOption{visualize}
%\showfields{address,location}
\begin{document}
\begin{letter}{\textbf{Sample Addressee}\\
Sample Avenue 1\\
12345 Sampletown
}
\opening{Sehr geehrte Damen und Herren,}
\blindtext[3]
\closing{\raggedright Mit freundlichen Grüßen}
\end{letter}
\end{document}