I see \newpagestyle
used with \sethead
and \setfoot
, for example here, but I cannot find any information on what those arguments for \sethead
and \setfoot
mean.
[Tex/LaTex] What are the parameters of \newpagestyle
pagestyle
Related Solutions
The class scrletter
is an undocumented wrapper-class. It loads class scrartcl
with font size 12pt
and package scrletter
.
\pagemark
is already defined by the KOMA-Script scrartcl
. Therefore package scrletter
defines \letterpagemark
for the letters in the document. If the format of the page numbers in the letters should be the same as in the other part of the document, use
\let\letterpagemark\pagemark
before environment letter
.
\documentclass[
%12pt,% default
headheight=30pt,headinclude,
firsthead=false,firstfoot=false,
foldmarks=false,
%foldmarks=blmtP,% disabled by foldmarks=false
%fromalign=center,% disabled by firsthead=false
%fromphone,fromemail,% disabled by firsthead=false
%version=last,
backaddress=false,
subject=titled,
twoside=semi,
cleardoublepage=current
]{scrletter}
%\usepackage{scrlayer-scrpage}% load by package scrletter
\usepackage{lipsum}% only for dummy text
\usepackage[T1]{fontenc}
\clearpairofpagestyles
\ohead{\jobname.tex\hspace{0.5cm}\usekomavar{date}}
\cfoot{\pagemark}
\renewcommand*{\pagemark}{{\usekomafont{pagenumber}{\thepage\ of \pageref{LastPage}}}}
\let\letterpagemark\pagemark
\AddToHook{shipout/lastpage}{\label{LastPage}}% replaces package lastpage
\renewcommand*{\letterpagestyle}{scrheadings}% page style for the next pages of the letter
\AddToHook{cmd/opening/after}{\thispagestyle{\letterpagestyle}}% use the same page style on first letter page
\setkomavar{date}{19th February, 2022}% do not change \today
\begin{document}
\begin{letter}{Name}
\opening{Dear Name,}
\thispagestyle{scrheadings}
\lipsum
\end{letter}
\lipsum
\end{document}
Note:
\renewcommand*{\letterpagestyle}{scrheadings}% page style for the next pages of the letter
\AddToHook{cmd/opening/after}{\thispagestyle{\letterpagestyle}}% use the same page style on first letter page
can be replaced by
\renewcommand*\letterpagestyle{}% do not change the page style for the letter
\AddToHook{cmd/opening/after}{\thispagestyle{scrheadings}}% use scrheadings on first letter page
The result would be the same.
Without additional packages (except lastpage
to capture the last page number):
\documentclass[12pt, openany]{book}
\usepackage{lastpage}% for last page
\pagestyle{myheadings}
\markboth{}{header part 1~header part 2~\textendash~header part 3}
\makeatletter
\def \@evenhead {\thepage\ of \pageref{LastPage} \hfil \slshape \leftmark } % added <<<<
\def \@oddhead {{\slshape \rightmark }\hfil \thepage\ of \pageref{LastPage}} % added <<<<
\makeatother
\usepackage{kantlipsum}% only for dummy text
\begin{document}
\kant[1-15]
\end{document}
The popular package fancyhdr
offers more versatility to control the headers and footers.
\documentclass[12pt, openany]{book}
\usepackage{lastpage}% for last page
\usepackage{fancyhdr}% added <<<<<<<<
\fancyhf{} % clear header and footer
\renewcommand{\headrulewidth}{0pt}% suppress line after header
\fancyhead[LO]{\slshape header part 1~header part 2~\textendash~header part 3}% Left Odd pages
\fancyhead[LE,RO]{\thepage\ of \pageref{LastPage}} % Left Even and Right Odd pages
\pagestyle{fancy} % choose the style
\usepackage{kantlipsum}% only for dummy text
\begin{document}
\kant[1-15]
\end{document}
Best Answer
Here is an example page (odd page 3) which should explain the six parameters: