0

I'm using scrartcl document class with scrletter package in the preamble, for a letter with section capabilities. I want to add an appendices after my \end{letter} statement.

This is easy enough using appendix package, but the format of the footer is lost. In my letter I have formatted it per my answer here, but after making the \begin{appendices} ... environment, I get a single page number centered in the footer margin so the page style appears to have reset in the appendices environment.

How can I keep it consistent with the rest of my document/letter?

MWE:

\documentclass[a4paper,
headlines=8.1,
headheight=3cm,
%footlines=1.1,
%footheight=2cm,
parskip=full,
british]{scrartcl}

\usepackage[a4paper,
    %showframe,
rmargin=2cm,
marginparsep=0cm,
marginparwidth=0cm,
footskip=1cm,
lmargin=2cm,
bmargin=2cm,
tmargin=2cm]{geometry}

\usepackage[%
foldmarks=false,
fromalign=right,
fromrule=off,
refline=dateleft,
fromphone=false,
fromemail=true,
pagenumber=footright,
firstfoot=true,
fromlogo=false]{scrletter}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[en-GB]{datetime2}
\DTMlangsetup[en-GB]{ord=raise}

\usepackage[british]{babel}
%\usepackage{showframe}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% dummy text
\usepackage{blindtext}
\usepackage{lipsum}

\usepackage[pdflang=en-GB]{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=black,
    filecolor=magenta,
    urlcolor=blue,
    %pdftitle={Overleaf Example},
    %pdfpagemode=FullScreen,
}

\usepackage{appendix}

\setkomavar{firstfoot}{\thepage of \letterlastpage}
\renewcommand*\letterpagemark{\usekomafont{pagenumber}{\thepage of \letterlastpage}}

\setkomavar{myref}[Internal \#]{Testref1234}
\setkomavar{date}[Date]{\today}
\setkomavar{yourref}[Your \#]{Testref5678}
\setkomavar{fromname}{A N Other}
\setkomavar{signature}{A N Other}
\renewcommand*{\raggedsignature}{\raggedright}
\setkomavar{fromaddress}{%
    Building Number\\
    Street\\
    State\\
    ZIP Code%
}

\setkomavar{backaddress}{}
\setkomavar{subject}[]{\underline{Testing letter}}
\setkomavar{subjectseparator}[]{}

\begin{document}
    \begin{letter}{%
            A. Person\\
            Someplace\\
            ZIP CODE%
        }
        \opening{test}
        \lipsum[1-4]
        
        \blindtext
        
        \lipsum[1-4]\footnote{\blindtext}
        \closing{cheers}
    \end{letter}
\begin{appendices}
    %\pagestyle{plain}
    %\tableofcontents
    \appendixpageoff
    \appendixtitleoff
    \appendixheaderoff
    \appendixpagename
    
    % here I would put \section{} statements for each thing I want in the appendix
\end{appendices}
\end{document}
2
  • Off topic: option headlines=8.1 is overwritten by headheight=3cm. Package inputenc with option utf8 is only needed with really outdated TeX distributions.
    – esdd
    Commented Mar 2, 2022 at 8:35
  • In the MWE different page styles are used inside and outside the letter environment. Additionally inside the letter environment \pagemark is set to \letterpagemark and outside the environment the original definition of \pagemark is used. \letterlastpage only works inside a letter.
    – esdd
    Commented Mar 2, 2022 at 8:53

1 Answer 1

2

Use \appendix (without package appendix) inside the letter environment:

\documentclass[
  headheight=3cm,
  parskip=full,
  british
]{scrartcl}

\usepackage[
margin=2cm,
marginparsep=0cm,
marginparwidth=0cm,
footskip=1cm,
]{geometry}
%\usepackage{showframe}

\usepackage[%
  foldmarks=false,
  fromalign=right,
  fromrule=off,
  refline=dateleft,
  fromphone=false,
  fromemail=true,
  backaddress=false,
  subject=underlined,
  pagenumber=footright
]{scrletter}% <- loads package scrlayer-scrpage automatically

\usepackage[T1]{fontenc}
\usepackage[en-GB]{datetime2}
\DTMlangsetup[en-GB]{ord=raise}
\usepackage{babel}

\usepackage{lipsum}% dummy text

\usepackage[pdflang=en-GB]{hyperref}
\hypersetup{
  colorlinks=true,
  linkcolor=black,
  filecolor=magenta,
  urlcolor=blue
}

\renewcommand*\pagemark{\usekomafont{pagenumber}{\thepage\ of \letterlastpage}}% <- changed
\let\letterpagemark\pagemark% <- changed
\setkomavar{firstfoot}{\raggedleft\pagemark}% <- added

\setkomavar{myref}[Internal \#]{Testref1234}
\setkomavar{date}[Date]{\today}
\setkomavar{yourref}[Your \#]{Testref5678}
\setkomavar{fromname}{A N Other}
\setkomavar{signature}{A N Other}
\renewcommand*{\raggedsignature}{\raggedright}
\setkomavar{fromaddress}{Building Number\\Street\\State\\ZIP Code}
\setkomavar{subject}{Testing letter}

\begin{document}
\begin{letter}{A. Person\\Someplace\\ZIP CODE}
\opening{test}
\lipsum[1-9]\footnote{\lipsum[2]}
\closing{cheers}
\clearpage
\appendix% <- changed and moved in the letter environment
\tableofcontents
\section{An appendix section}
\lipsum
\section{Another appendix section}
\lipsum
\end{letter}
\end{document}

enter image description here

If \appendix should be outside letter environment, you can not use \letterlastpage, because it refers to the last page a letter inside the letter environment.

\documentclass[
  headheight=3cm,
  parskip=full,
  british
]{scrartcl}

\usepackage[
margin=2cm,
marginparsep=0cm,
marginparwidth=0cm,
footskip=1cm,
]{geometry}
%\usepackage{showframe}

\usepackage[%
  foldmarks=false,
  fromalign=right,
  fromrule=off,
  refline=dateleft,
  fromphone=false,
  fromemail=true,
  backaddress=false,
  subject=underlined,
  pagenumber=footright
]{scrletter}% <- loads package scrlayer-scrpage automatically

\usepackage[T1]{fontenc}
\usepackage[en-GB]{datetime2}
\DTMlangsetup[en-GB]{ord=raise}
\usepackage{babel}

\usepackage{lipsum}% dummy text

\usepackage[pdflang=en-GB]{hyperref}
\hypersetup{
  colorlinks=true,
  linkcolor=black,
  filecolor=magenta,
  urlcolor=blue
}

\renewcommand\pagemark{{\usekomafont{pagenumber}{\thepage\ of \pageref{LastPage}}}}% <- changed
\let\letterpagemark\pagemark
\AddToHook{shipout/lastpage}{\label{LastPage}}% <- added
\setkomavar{firstfoot}{\raggedleft\pagemark}

\setkomavar{myref}[Internal \#]{Testref1234}
\setkomavar{date}[Date]{\today}
\setkomavar{yourref}[Your \#]{Testref5678}
\setkomavar{fromname}{A N Other}
\setkomavar{signature}{A N Other}
\renewcommand*{\raggedsignature}{\raggedright}
\setkomavar{fromaddress}{Building Number\\Street\\State\\ZIP Code}
\setkomavar{subject}{Testing letter}

\begin{document}
\begin{letter}{A. Person\\Someplace\\ZIP CODE}
\opening{test}
\lipsum[1-9]\footnote{\lipsum[2]}
\closing{cheers}
\end{letter}
\appendix
\tableofcontents
\section{An appendix section}
\lipsum
\section{Another appendix section}
\lipsum
\end{document}

You must log in to answer this question.

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