如何为不同的章节编排页面编号 1a 1b 1c,2a 2b 2c 等等?

如何为不同的章节编排页面编号 1a 1b 1c,2a 2b 2c 等等?

我希望每个部分的页码都用字母“a、b、c...”编号,到达新部分后重置为“a”,并设置相应的部分编号(正常为 1、2、3、4...)。大多数情况下,我的部分只有一页,因此我不希望有字母,只希望有数字,但有些部分有 5 页以上,我需要有字母。

编辑(回答评论中的一些问题):所有部分都从新页面开始。部分将有 5-10 页。目前页面为 1、2、3a、3b、3c、4、5a、5b、6a、6b、6c...6j、7、8、10a、10b...等等,但子页面的确切数量可能会发生变化。

你知道该如何实现吗?提前致谢!

答案1

以下过程自动设置页脚中按节的页码,同时要求单页节仅在页脚中显示其节号:

在此处输入图片描述

\documentclass{article}

% \usepackage{alphalph}
\usepackage{fancyhdr,refcount}
\pagestyle{fancy}
\fancyhf{}% Clear header/footer
\fancyfoot[C]{% Update center footer
  \thesection% Print section number
  \ifnum\getpagerefnumber{section-\thesection-lastpage}=1 \else
    \alph{page}% \alphalph{page}% Print page number
  \fi}


\let\oldsection\section
\renewcommand{\section}{%
  \label{section-\thesection-lastpage}% Label last page of section
  \clearpage% Move to next page
  \setcounter{page}{1}% Reset page counter
  \oldsection}

\usepackage{lipsum}% Just for this example

\begin{document}

\section{A section}
\lipsum[1-4]

\section{Another section}
\lipsum[1-30]

\section{Yet another section}
\lipsum[1-4]

\section{Final section}
\lipsum[1-20]

\end{document}

该方法背后的理念是\label在每个 的末尾设置一个\section(实际上,在下一个 的开始之前\section),然后以page当时的值作为条件。在处理页码可能变化无常的发货例程时,需要使用此\label-方法。\ref

如果每节超过 26 页,请考虑使用alphalph包裹

答案2

因为所有内容都与章节相关。我可以将页脚设置为章节号 + 页码(按字母顺序排列),并在每个章节之后重置页码计数器。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\cfoot{\thesection\thepage}



\begin{document}

\pagenumbering{alph}
\section{First}

blah blah
\newpage
blah blah 

\newpage
\setcounter{page}{0} %reset counter, but only one page so set to zero so no letter beside
\section{Second}


blah blah
\newpage

\setcounter{page}{1}
\section{Third}
blah
\newpage
blah

\end{document}

相关内容