# nexthead and nextfoot problem in multi-page letter with KOMA and srclttr2

I set up the following document where I think I was able to quite nicely put together a letter template for our company. However, what I can't seem to get to work are the nextfoot and nexthead komavars. Here is the *.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{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:sample@sampledomain.de}{sample@sampledomain.de}}
\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}

\setkomavar{date}{\today}
\setkomavar{fromname}{\myCompanyname}
\setkomavar{signature}{\myFirstname\ \myFamilyname}
\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:sample@sampledomain.de}{sample@sampledomain.de}}
\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}

\raggedright
{\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
\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{nextfoot}{\usekomavar{firstfoot}}

\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*{fromurl}\usekomavar{fromurl}\\
\Letter\,\myCompanyMail
}

% to visualize the position and the size of address and location:
\begin{document}
Sample Avenue 1\\
12345 Sampletown
}
\opening{Sehr geehrte Damen und Herren,}

\blindtext[3]

\closing{\raggedright Mit freundlichen Grüßen}
\end{letter}
\end{document}


There are two problems. First, the nextfoot just won't break after the rule even though firstfoot does quite nicely. The entire contents are kept on the exact same line no matter if I \linebreak, \vskip or \\ them.

The second problem is that once I remove the comment in line 118 \setkomavar{nexthead}{\usekomavar{firsthead}} in order to make the nexthead header to show I get the following error, which I don't quite understand:

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}


I sincerely tried to find a solution in the documentation, but as a latex noob I can't make any sense of most of the parts that touch my topic. That's also why there isn't a real MWE. I really struggle to configure everything properly using all the scrlttr2 properties. Hope it's still alright and someone can point me to the right direction!

• Are you really sure you want to do this? From a design perspective repeating all this information on every page (where it takes up a lot of real-estate) seems highly doubtful! – Paul Stanley Apr 11 '18 at 22:49
• Actually, it would be alright if I was just able to repeat the footer. The question regarding the repeating header is more about trying to understand the underlying concept a bit better, if possible – pdresselhaus Apr 12 '18 at 7:52
• Should the footer on next pages have the same width as on first page? And which one? By default the footer width of next pages is \textwidth. And should the footers have the same vertical positions? And which one? – esdd Apr 12 '18 at 9:24
• @esdd Ideally, I would like for the nextfoot to have the same width and position (vertically as well as horizontally) as the firstfoot. But (as @Paul Stanleys explains in his answer) I found the margins on the subsequent pages to be somewhat narrower than on the first page. To me it seems that none of the position commands like \@setplength{firstfootvpos}{260mm} work for the following pages. So I was not really sure, whether there is any room for adjustment there – pdresselhaus Apr 12 '18 at 10:04

The first page of KOMA-Script letters uses pagestyle empty by default and gets a complettly different layout as "next" pages. So the position of header, footer and letter body differs from the other pages.

But you can load package scrlayer-scrpage and add a new declared layer to layer pagestyle scrheadings. This layer can be put on the same place and with the same size like the footer on the first page. In the code below there are some additional changes like removing spurious spaces and inserting \\ after the footer line.

\setkomavar{firsthead}{% changed ->
\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 ->
\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
\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}%
}%
}%
}%
}

\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}

\clearpairofpagestyles


Code:

\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{graphicx}
\usepackage{bm}

\usepackage{blindtext}% only for dummy text
%% to visualize the position and the size of address and location:

\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:sample@sampledomain.de}{sample@sampledomain.de}}
\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}

\setkomavar{date}{\today}
\setkomavar{fromname}{\myCompanyname}
\setkomavar{signature}{\myFirstname\ \myFamilyname}
\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:sample@sampledomain.de}{sample@sampledomain.de}}
\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*{fromurl}\usekomavar{fromurl}\\
\Letter\,\myCompanyMail
}

\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 ->
\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
\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}%
}%
}%
}%
}

\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}

\clearpairofpagestyles

\begin{document}
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}

• Wow. That's super neat, thank you so much! I had a feeling that I needed scrlayer-scrpage but I just couldn't find any examples on that. Can you may be link some resources where I can read a bit about what you did here? – pdresselhaus Apr 12 '18 at 13:50

I can't track down the exact reason for the problem, but it was to do with the definition of firstfoot and the fact that the \textwidth on the second and subsequent pages is narrower than on page 1 (because it's set based on the margin of the text, not the address stuff). So it simply didn't fit. What is happening internally I can't say. As you observe: it's a complex class.

My solution has been to redesign the footer: I've had to go down to \scriptsize. I've eliminated the tables (which were just being used for formatting) and replaced them with simple parboxes. In doing so, I've got rid of the indent of the header lines, which I think looks better; but it's just a matter of taste and if you want them back just add a \quad before the relevant line. I've set them \raggedright to avoid hyphenation where I think it doesn't belong.

This left one tiny issue: the banking information (especially the IBAN number) is longer than the other stuff, and the break in the IBAN number was uncomfortable, so I enlarged that box very slightly and reduced another. It's not going to look balanced to the eye anyway because of the different length of the information in the boxes.

I haven't tackled the header issue, because (1) I think it's highly eccentric to have a complete address on every page and (2) It causes other problems, because you will need to move the text margin down to accommodate an overheight header. If I were you I'd design a different header, which is shorter.

Personally, I wouldn't put the other information on every page either, but that's up to you!

Finally, I'm not sure if you really need a firsthead at all. I think you could get the arrangement you want for the first page simply with the ordinary commands. But it's not wrong, I guess, if it works.

The remaining imperfection here is that the footer is placed on page 2 a little higher up the page than on page 1, as esdd points out in a comment above. I haven't tackled that, I'm afraid.

\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{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:sample@sampledomain.de}{sample@sampledomain.de}}
\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}

\setkomavar{date}{\today}
\setkomavar{fromname}{\myCompanyname}
\setkomavar{signature}{\myFirstname\ \myFamilyname}
\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:sample@sampledomain.de}{sample@sampledomain.de}}
\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}

\raggedright
{\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
\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{nextfoot}{\usekomavar{firstfoot}}

\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*{fromurl}\usekomavar{fromurl}\\
\Letter\,\myCompanyMail
}

% to visualize the position and the size of address and location:
\begin{document}
Sample Avenue 1\\
12345 Sampletown
}
\opening{Sehr geehrte Damen und Herren,}

\blindtext[3]

\closing{\raggedright Mit freundlichen Grüßen}
\end{letter}
\end{document}


• Seems this is the best solution one can come up with without using scrlayer-scrpage. Thank you very much for your input! – pdresselhaus Apr 12 '18 at 13:52