# Package scrlayer-scrpage breaks scrlttr2

I'm trying to change the standard footer of the scrlttr2 class from {page no.} to Page {page no.} of {total}. While searching for a way to do this, I found out that the current accepted method for KOMA classes is to use the scrlayer-scrpage package. However, loading that package raises the following error:

! Missing = inserted for \ifnum.
<to be read again>
\z@
l.7 \end{letter}


Here is the really minimal (non-)working example used to create this error:

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

\begin{document}
\begin{letter}{}
This is a MWE.
\end{letter}
\end{document}


Any suggestions? Are scrlttr2 and scrlayer-scrpage incompatible or could something be wrong with my package (versions)?

• Works for me. Could you please check if your distribution is up-to-date? – TeXnician Aug 29 '17 at 16:10

Your example does work with old KOMA-Script 3.22, current KOMA-Script release 3.23 or current KOMA-Script prerelease. Nevertheless, you do not need scrlayer-scrpage to change the page mark, you only need to redefine command \pagemark:

\documentclass{scrlttr2}
\usepackage{mwe}
\renewcommand*{\pagemark}{\usekomafont{pagenumber}{\thepage\ of
\letterlastpage}}
\setkomavar{firstfoot}{\centering \pagemark}
\begin{document}
\begin{letter}{You\\There}
\opening{Hello,}
\lipsum
\closing{Bye}
\end{letter}
\end{document}


Or if you prefer

\makeatletter