I'm trying to create a letter template and want every page to show the current page and the total number of pages. However, I cannot get koma script to display the custom \pagemark on the first page. It always starts on the second. At the same time, the header is to be shown only at the second page as the first page has a custom header.
MRE
\documentclass{scrlttr2}
\KOMAoption{paper}{a4}
\KOMAoption{firsthead}{yes}
\KOMAoption{firstfoot}{yes}
\usepackage{blindtext}
\pagestyle{myheadings}
\markright{\Ifkomavarempty{subject}{}{\centering\usekomavar{subject}}}
\renewcommand\pagemark{{\usekomafont{pagenumber}custom~pg~\thepage}}
\begin{document}
\setkomavar{fromname}{sender}
\setkomavar{fromaddress}{address}
\setkomavar{firsthead}{Custom firsthead}
% the following workaround doesn't work as intended
% because the bottom spacing of the 'firstfoot' is
% different from the regular footer distance
%%\setkomavar{firstfoot}{%
%%\centering\pagemark%
%%}
\setkomavar{date}{Date}
\setkomavar{subject}{Subject}
\begin{letter}{Addressee}
\opening{Hello}
World
\Blindtext
\closing{Cheers}
\end{letter}
\end{document}
The custom pagemark is shown on the second page but not the first:


xpatchcmdwas the command I didn't know I needed all my life. Marvellous! – bitmask Feb 02 '21 at 13:58