2

I use the KOMA script scrlttr2 and just want to display the same text (my page numbering/number) on all pages of my letter, of course including the first one.

I've found this answer and this somewhat old blog post. But both are awkwardly complicated and require me to define a heck of LaTex macros for just doing the same it automatically does beginning with page two (2).

How can I display the same text (page number) on the first page's footer as in the footer on the second/al other pages? In contrast to all other questions I'm not searching for the most elegant solution (that takes 100 lines), but I'd be fine with duplicating/hardcoding the footer again by repeating it. Even if it would take me to write “Page 1 of \letterlastpage”.

I basically use this example, taken from here:

\documentclass{scrlttr2}
\usepackage{scrlayer-scrpage}

\cfoot{Page \thepage\ of \letterlastpage}

\usepackage{lipsum}
\begin{document}
\begin{letter}{%
    Jerry Garcia\\
    710 Ashbury St\\
    San Francisco\\
    CA 94117
    }
    \opening{Dear Friend,}
    
  \lipsum\lipsum    

\end{letter}

\begin{letter}{%
    Jerry Garcia\\
    710 Ashbury St\\
    San Francisco\\
    CA 94117
    }
    \opening{Dear Friend,}

  \lipsum\lipsum    

\end{letter}

\end{document}

3 Answers 3

3

The layout of the first letter page is special. The page style of the first letter page is empty. It uses special elements for the address, location, header, footer etc.

You have to use variable firstfoot to add content in the footer of the first page. If you redefine \pagemark to get »Page ... of ...«, then you can use \centering\pagemark for firstfoot:

\renewcommand*\pagemark{%
  \usekomafont{pagenumber}{\pagename~\thepage~of~\letterlastpage}%
}
\setkomavar{firstfoot}{\centering\pagemark}

Example:

\documentclass{scrlttr2}

\renewcommand*\pagemark{%
  \usekomafont{pagenumber}{\pagename~\thepage~of~\letterlastpage}%
}
\setkomavar{firstfoot}{\centering\pagemark}

\usepackage{lipsum}
\begin{document}
\begin{letter}{Jerry Garcia\\710 Ashbury St\\San Francisco\\CA 94117}
\opening{Dear Friend,}
\lipsum\lipsum
\end{letter}

\begin{letter}{Jerry Garcia\\710 Ashbury St\\San Francisco\\CA 94117}
\opening{Dear Friend,}
\lipsum\lipsum
\end{letter}
\end{document}

enter image description here

Note that the footer on the fist page is lower than on the other pages. If it should be at the same position, then you can patch \opening to use page style plain on the first page:

\newcommand{\originalopening}{}
\let\originalopening\opening
\renewcommand{\opening}[1]{\originalopening{#1}\thispagestyle{plain}}
\KOMAoptions{firstfoot=false}% disable first footer

or with package xpatch:

\usepackage{xpatch}
\xpatchcmd{\opening}{\thispagestyle{empty}}{\thispagestyle{plain}}{}{\PatchFailed}
\KOMAoptions{firstfoot=false}% disable first footer

Note that you can still use variable firsthead to define a header of the first letter page.

Example:

\documentclass{scrlttr2}

\renewcommand*\pagemark{%
  \usekomafont{pagenumber}{\pagename~\thepage~of~\letterlastpage}%
}

\usepackage{xpatch}
\xpatchcmd{\opening}{\thispagestyle{empty}}{\thispagestyle{plain}}{}{\PatchFailed}
\KOMAoptions{firstfoot=false}% disable first footer

\usepackage{lipsum}
\begin{document}
\begin{letter}{Jerry Garcia\\710 Ashbury St\\San Francisco\\CA 94117}
\opening{Dear Friend,}
\lipsum\lipsum
\end{letter}

\begin{letter}{Jerry Garcia\\710 Ashbury St\\San Francisco\\CA 94117}
\opening{Dear Friend,}
\lipsum\lipsum
\end{letter}
\end{document}

enter image description here

2
  • Do you know of an equivalent to firstfoot in the old standard latex letter class? Thank you!
    – James
    Commented Feb 14, 2023 at 15:57
  • AFAIK there is no equivalent to firstfoot in the standard class letter. But you can load a package like fancyhdr or scrlayer-scrpage to change page header and footer using \pagestyle and \thispagestyle.
    – esdd
    Commented Mar 15, 2023 at 8:20
1

The footer on the first page of a letter is empty by default.

You will need to define your own first-page footer using the firstfoot variable and set its position from the top of the page with the firstfootvpos variable.

Switch the footer on with the firstfoot=true option.

The subsequent footers (done with \cfoot from the scrlayer-scrpage package in your code example; it works OK) can also be set within scrlttr2 by using its nextfoot variable.

Also, since there is no letterhead in the example, and no reference, I've taken the liberty of moving the to-address and the letter body further up the page a bit, to use some of the space.

first page footer

first page

MWE

\documentclass[firstfoot=true,
enlargefirstpage=true,
firsthead=false,
]{scrlttr2}
%%\usepackage{scrlayer-scrpage}
%\cfoot{Page \thepage\ of \letterlastpage}

\setplength{toaddrvpos}{\footskip}
\setplength{refvpos}{3.5\footskip}
\pagestyle{myheadings}
%\markboth{}{}
\setplength{firstfootvpos}{\pageheight-1.5\footskip}\setkomavar{firstfoot}{%
\parbox[t]{\linewidth}{%
\centering \textit{Page \thepage\ of \letterlastpage}%
}%
}
\setkomavar{nextfoot}{%
\parbox[t]{\linewidth}{%
\centering \textit{Page \thepage\ of \letterlastpage}%
}%
}
\usepackage{lipsum}
\begin{document}
\begin{letter}{%
    Jerry Garcia\\
    710 Ashbury St\\
    San Francisco\\
    CA 94117
    }
    \opening{Dear Friend,}
    
  \lipsum\lipsum    

\end{letter}

\begin{letter}{%
    Jerry Garcia\\
    710 Ashbury St\\
    San Francisco\\
    CA 94117
    }
    \opening{Dear Friend,}

  \lipsum\lipsum    

\end{letter}

\end{document}
0

By combining multiple answers (linked in the code), I've found a solution that just uses the internal scrlttr2 parameter, i.e. mostly \pagemark.

Also you have one place to define the page number style there.

\documentclass[enlargefirstpage=true]{scrlttr2}
\usepackage{scrlayer-scrpage}

% better page numbers with total number
% https://tex.stackexchange.com/a/578072/98645
\renewcommand*\pagemark{%
  \usekomafont{pagenumber}{\pagename~\thepage~of~\letterlastpage}%
  %\usekomafont{pagenumber}{-~\thepage~von~\letterlastpage~-}% different style example
}
% also show page number on first page
% https://tex.stackexchange.com/a/578050/98645
\markboth{}{}
\setkomavar{firstfoot}{%
    \parbox[t]{\linewidth}{%
        \centering \pagemark%
    }%
}

\usepackage{lipsum}
\begin{document}
\begin{letter}{%
    Jerry Garcia\\
    710 Ashbury St\\
    San Francisco\\
    CA 94117
    }
    \opening{Dear Friend,}

  \lipsum\lipsum    

\end{letter}

\begin{letter}{%
    Jerry Garcia\\
    710 Ashbury St\\
    San Francisco\\
    CA 94117
    }
    \opening{Dear Friend,}

  \lipsum\lipsum    

\end{letter}

\end{document}
1
  • 1
    With package scrlayer-scrpage page style scrheadings is used for pages 2 ff automatically. I would suggest to load this package with one of the options manualmark (manuell marks for the header) or automark (marks for the header will be set automatically). \markboth{}{} can be removed from the preamble.
    – esdd
    Commented Jan 8, 2021 at 15:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .