如何重新开始每个附录的页码

如何重新开始每个附录的页码

我想更改每个附录的起始编号,使用下面的代码,我保留上一节的编号。例如,我想有 A1/9、A2/9,当我开始新的附录时,页码会重新开始,如 B1/9、B2/9。我该怎么做?

\documentclass[
   numbers=noenddot
]{scrreprt}
\usepackage{lastpage}
\usepackage{etoolbox}
\usepackage{lastpage}
\usepackage{fancyhdr} 
\usepackage{lipsum}


%%%% Chapter Stylus

\RedeclareSectionCommands[
  font=\normalsize
]{section,subsection,subsubsection}

\RedeclareSectionCommands[
  font=\Large,beforeskip=0pt
]{chapter}

\usepackage{xpatch}
\xpatchcmd\chapterformat{\autodot}{.}{}{\PatchFailed}

\DeclareTOCStyleEntry[
  entrynumberformat=\entrynumberwithdot
]{chapter}{chapter}
\newcommand*\entrynumberwithdot[1]{\def\autodot{.}#1}


%%%%%% Foot and Header


\pagestyle{fancy} 
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}

\lhead{\fontsize{6pt}{6pt}\selectfont {IMAGE 1 \\   \quad IMAGE 2 } }

\rhead{IMAGE 3}

\fancyfoot[R]{\thepage / \pageref{LastPage}}
\fancypagestyle{plain}{}
\begin{document}

\chapter{Introduction}

\lipsum

\chapter{Methodology}

\lipsum

\appendix
\fancyfoot[R]{\thechapter\thepage / \pageref{LastPage}}
\chapter*{Appendix}
\addcontentsline{toc}{chapter}{Appendix}
\renewcommand{\thechapter}{\Alph{chapter}}


\chapter{Data}

\lipsum

\chapter{Tables}

\lipsum

\end{document}

答案1

这将添加一个新的计数器relpage,以便\fancyfoot可以使用\therelpage而不是\thepage。请注意,它会重置为 0 而不是 1,因此\numexpr

\documentclass[
   numbers=noenddot
]{scrreprt}
\usepackage{lastpage}
\usepackage{etoolbox}
%\usepackage{lastpage}% redundant
\usepackage{fancyhdr} 
\usepackage{lipsum}


%%%% Chapter Stylus

\RedeclareSectionCommands[
  font=\normalsize
]{section,subsection,subsubsection}

\RedeclareSectionCommands[
  font=\Large,beforeskip=0pt
]{chapter}

\usepackage{xpatch}
\xpatchcmd\chapterformat{\autodot}{.}{}{\PatchFailed}

\DeclareTOCStyleEntry[
  entrynumberformat=\entrynumberwithdot
]{chapter}{chapter}
\newcommand*\entrynumberwithdot[1]{\def\autodot{.}#1}


%%%%%% Foot and Header


\pagestyle{fancy} 
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}

\lhead{\fontsize{6pt}{6pt}\selectfont {IMAGE 1 \\   \quad IMAGE 2 } }

\rhead{IMAGE 3}

\fancyfoot[R]{\thepage / \pageref{LastPage}}
\fancypagestyle{plain}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{relpage}[chapter]
\renewcommand{\therelpage}{\thechapter\the\numexpr\value{relpage}+1\relax}
\AddToHook{shipout/after}{\stepcounter{relpage}}

\begin{document}

\chapter{Introduction}

\lipsum

\chapter{Methodology}

\lipsum

\appendix
\chapter*{Appendix}
\addcontentsline{toc}{chapter}{Appendix}%
\fancyfoot[R]{\therelpage / \pageref{LastPage}}%

\chapter{Data}

\lipsum

\chapter{Tables}

\lipsum

\end{document}

相关内容