
我試圖在所有頁面上獲得與 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}
您必須在評論中填寫 lorem ispum 或其他內容才能產生第二頁!
但我有以下問題:
\pagestyle{headings}
也會在下一頁插入標題。我不要那個!- 下一頁的頁腳未正確呈現。它看起來像這樣:
在第一頁上它看起來像這樣:
為什麼?
答案1
若要刪除下一頁的標題,請使用
\setkomavar{nexthead}{}
對於第二個問題,使用\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
已被折舊。
但頁腳在兩個頁面上的位置和寬度仍然不同:
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}