# How can I print “page # of ##” with the total page number in KOMA (scrlttr2)?

This questions explains how you can show the total page number of your document in the footer on each page, i.e. show a “page # of ##” instead of the default “page # of #”.

However, even though someone asked for that in the comments, it does not explain how to do that in a KOMA class. It has been suggested to ask a new question.

I use scrlttr2 for a letter, so I'd like to do the same. So how can I do it there?

• Why does the class matter? Your example simply uses \usepackage{lastpage} which should work with ´scrlttr2 as well. – Ingmar Jan 7 at 19:44
• Yeah, sorry, saw that too (I intitially voted to close it as a dupe), but the answer I got here also helps a lot as it is more detailled. – rugk Jan 7 at 23:37
• This is not a dupe, because scrlttr2 provides its own solution. Additionally there could be more than one letter in a scrlttr2 document. – esdd Jan 8 at 14:38
• @esdd Thanks yeah, given the nice answer, it is indeed different. And yeah, actually I use multiple letters in there with mailmerge. – rugk Jan 8 at 15:03

You can simple (without additional packages) redefine \pagemark to your needs:

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


Example:

\documentclass{scrlttr2}
\usepackage{blindtext}% only for dummy text

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

\begin{document}
\begin{letter}{Foo}
\opening{Hello,}
\Blindtext[10]
\end{letter}

\begin{letter}{Bar}
\opening{Hello,}
\Blindtext[15]
\end{letter}

\end{document}


The scrlttr2 class offers specific commands for modifying headers and footers, through the scrlayer-scrpage package. The mwe below is a starting point. Note that there is no need to use the lastpage package, as the class provides the internal \lastletterpage counter.

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

\cefoot{Page \thepage\ of \letterlastpage}
\cofoot{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}

• Thanks a lot! I'd add after reading the doc on this to use \cfoot instead of \cefoot and \cofoot` unless you want different versions on unnumbered and numbered pages. – rugk Jan 7 at 23:45