
scrlttr2 の最初のページと同じフッターをすべてのページに表示しようとしています。グーグルで検索した後、次のコードを見つけました。
\documentclass{scrlttr2}
\begin{document}
\firstfoot{\footnotesize%
\rule[3pt]{\textwidth}{.4pt} \\
\begin{tabular}[t]{l@{}}%
Super Man\\
Super Straße 30\\
12345 Super Town
\end{tabular}%
\hfill
\begin{tabular}[t]{l@{}}%
Telefon: +49123456789\\
[email protected]\\
\end{tabular}%
\hfill
\begin{tabular}[t]{l@{}}%
Bankverbindung: \\
IBAN: DEXX XXXX XXXX XXXX XX\\
BIC: XXXXXXXXXXXXX
\end{tabular}%
}%
\addtokomafont{pagefoot}{\normalfont}
\pagestyle{headings}
\nextfoot{\usekomavar{firstfoot}}
\begin{letter}{Addr}
\opening{}
% You have to fill enough text to get to the second page
\closing{}
\end{letter}
\end{document}
2 ページ目を生成するには、コメントに lorem ispum か何か他のものを入力する必要があります。
しかし、次のような問題があります。
\pagestyle{headings}
次のページにヘッダーも挿入されます。これは望ましくありません。- 次のページのフッターは正しくレンダリングされません。次のようになります。
最初のページでは次のようになります。
なぜ?
答え1
次のページのヘッダーを削除するには、
\setkomavar{nexthead}{}
2番目の問題では\parbox
内側のfirstfoot
\setkomavar{firstfoot}{\usekomafont{pageheadfoot}\usekomafont{pagefoot}%
\parbox[t]{\textwidth}{%
\rule[3pt]{\linewidth}{.4pt} \\
\begin{tabular}[t]{l@{}}%
Super Man\\
Super Straße 30\\
12345 Super Town
\end{tabular}%
\hfill
\begin{tabular}[t]{l@{}}%
Telefon: +49123456789\\
[email protected]\\
\end{tabular}%
\hfill
\begin{tabular}[t]{l@{}}%
Bankverbindung: \\
IBAN: DEXX XXXX XXXX XXXX XX\\
BIC: XXXXXXXXXXXXX
\end{tabular}%
}%
}%
firstfoot も変数であり、command は\firstfoot
非推奨であることに注意してください。
ただし、フッターの位置と幅は 2 つのページで異なります。
plain
パッケージ付きページスタイルscrlayer-scrpage
パッケージをロードしscrlayer-scrpage
、すべてのページでプレーン ページ スタイルを使用します。
次の例では、通常のplain
スタイルを使用しています。フットセップラインのみが少し上方にシフトされています。
\documentclass[
firstfoot=false,%<- no first foot
footheight=48pt
]{scrlttr2}
\usepackage{blindtext}% dummy text
\usepackage[footsepline,plainfootsepline]{scrlayer-scrpage}
\ModifyLayer[
addvoffset=-1ex
]{plain.scrheadings.foot.above.line}% shift the footsepline up
\addtokomafont{pagefoot}{\normalfont\footnotesize}
\clearpairofpagestyles
\cfoot*{
\begin{tabular}[t]{l@{}}%
Super Man\\
Super Straße 30\\
12345 Super Town
\end{tabular}%
\hfill
\begin{tabular}[t]{l@{}}%
Telefon: +49123456789\\
[email protected]\\
\end{tabular}%
\hfill
\begin{tabular}[t]{l@{}}%
Bankverbindung: \\
IBAN: DEXX XXXX XXXX XXXX XX\\
BIC: XXXXXXXXXXXXX
\end{tabular}%
}
\pagestyle{plain}
\usepackage{xpatch}
\xapptocmd\opening{\thispagestyle{plain}}{}{}% <- first pages will have pagestyle plain too
\begin{document}
\setkomavar{fromname}{Name}
\setkomavar{firsthead}{It is still possible to set a firsthead.}% <- firsthead still works
\begin{letter}{Addr}
\opening{}
\Blindtext
\closing{}
\end{letter}
\end{document}
ただし、フッターの垂直位置と幅を必要に応じて変更することもできます。以下は、通常のfirstfoot
設定に似た例です。
\documentclass[
firstfoot=false,%<- no first foot
footheight=48pt
]{scrlttr2}
\usepackage{blindtext}% dummy text
\usepackage[footsepline,plainfootsepline]{scrlayer-scrpage}
\KOMAoptions{footwidth=\useplength{firstfootwidth}}
\ForEachLayerOfPageStyle*{plain.scrheadings}{%
\ifstrstart{#1}{plain.scrheadings.foot}{%
\ModifyLayer[
voffset={\useplength{firstfootvpos}-1em}
]{#1}
}{}
}% shift the footer down
\ModifyLayer[
addvoffset=-1ex
]{plain.scrheadings.foot.above.line}% shift the footsepline up
\addtokomafont{pagefoot}{\normalfont\footnotesize}
\clearpairofpagestyles
\cfoot*{
\begin{tabular}[t]{l@{}}%
Super Man\\
Super Straße 30\\
12345 Super Town
\end{tabular}%
\hfill
\begin{tabular}[t]{l@{}}%
Telefon: +49123456789\\
[email protected]\\
\end{tabular}%
\hfill
\begin{tabular}[t]{l@{}}%
Bankverbindung: \\
IBAN: DEXX XXXX XXXX XXXX XX\\
BIC: XXXXXXXXXXXXX
\end{tabular}%
}
\pagestyle{plain}
\usepackage{xpatch}
\xapptocmd\opening{\thispagestyle{plain}}{}{}% <- first pages will have pagestyle plain too
\begin{document}
\setkomavar{fromname}{Name}
\setkomavar{firsthead}{It is still possible to set a firsthead.}% <- firsthead still works
\begin{letter}{Addr}
\opening{}
\Blindtext
\closing{}
\end{letter}
\end{document}