我有一个文档,其中包含我收到的自定义类,该类基于该类book
并使用fancyhdr
包。在目录中,文档的最后一节缺少节号,附录标题也是如此。这些节的页码(在页脚中)也缺少节号,例如只有一个破折号和页码-53
。请参见下面的目录图像
这是我在这些页面的页脚中看到的输出(文档的其余部分在目录和页脚中都有正确的页码):
如何让章节编号显示在目录中以及这些页面的页脚中显示的页码中?
以下是主文件的相关部分.tex
:
\documentclass{byureview}
\begin{document}
\includepdf{titlepage.pdf}
\thispagestyle{empty}
\tableofcontents
\chapter{Chapter 1}
\includepdf{Chapter1.pdf}
% -------------- %
\chapter{Chapter 7}
% -------------- %
\section{List of awards or recognition for scholarship}
\label{sec:scholar_awards}
\input{scholar-awards}
\section{External review letters of scholarship and a copy of the waiver letter}
External review letters will be added by the department office.
\begin{appendices}
\chapter{Mechanical Engineering Departmental Rank and Status Policy}
\label{app:ME_AIR_policy}
\includepdf[pages=-]{ME_AIR_Policy_Nov29_2017_Approved}
\end{appendices}
\end{document}
以下是类定义文件的内容:
\LoadClass{book}
% ---- packages ------
\RequirePackage[margin=1in]{geometry}
\RequirePackage{booktabs} % better tables
\usepackage{titlesec} % allow clear page for sections/subsections
\usepackage{caption}
%\captionsetup[table]{skip=5pt} % better spacing of table
\captionsetup[figure]{font=small,labelfont={small,bf}} % make figure caption titles small and bold
\captionsetup[table]{skip=5pt,font=small,labelfont={small,bf}} % make table caption titles small and bold
\usepackage[parfill]{parskip} % no indent and line skip between paragraphs
\usepackage{pdfpages}
\usepackage[toc,page]{appendix}
\usepackage{soul}
\usepackage[auto]{chappg} % number pages within each chapter
\usepackage{fancyhdr}
\usepackage{color}
\definecolor{byublue}{RGB}{52, 90, 138}
\usepackage[stable]{footmisc}
%\usepackage[colorlinks,bookmarks,bookmarksnumbered,allcolors=byublue]{hyperref}
\usepackage[colorlinks=true,bookmarks,bookmarksnumbered,linkcolor=byublue,urlcolor=byublue,bookmarksopen=true,linktoc=all]{hyperref}
\usepackage[capitalise]{cleveref}
\usepackage{rotating}
\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage{pgfplots}
\usepackage{xcolor}
\definecolor{color1}{RGB}{16,43,78}
\definecolor{color2}{RGB}{28,66,106}
\definecolor{color3}{RGB}{112,139,184}
\definecolor{color4}{RGB}{199,214,238}
\definecolor{color5}{RGB}{205,194,175}
\definecolor{color6}{RGB}{228,210,188}
\definecolor{color7}{RGB}{255,230,202}
\definecolor{color8}{RGB}{255,241,226}
\usepackage{longtable}
% change chapter headers
\titleformat{\chapter}{\color{byublue}\bfseries\huge}{\thechapter.}{20pt}{\color{byublue}\bfseries\huge}%
[\thispagestyle{empty}\null\clearpage]
% section headers 1.A
\renewcommand\thesection{\thechapter.\Alph{section}}
% new page for each section/subsection
\newcommand{\sectionbreak}{\clearpage}
% makes paragraphs with a carriage return after the title
\newcommand{\myparagraph}[1]{\paragraph{#1}\mbox{}}
% page numbering per section
\renewcommand{\thepage}{\thechapter-\arabic{page}}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
% \rhead{}
% \lhead{}
\cfoot{\thepage}
\renewcommand\tableofcontents{%
\@starttoc{toc}%
}
% \makeatletter
% \patchcmd{\@sect}% <cmd>
% {\protected@edef}% <search>
% {\def\arg{#1}\def\arg@{section}%
% \ifx\arg\arg@\stepcounter{page}\fi%
% \protected@edef}% <replace>
% {}{}% <success><failure>
% \makeatother
% ----- custom commands -------
\newcommand{\cvpar}[2][1.0]{\vspace{#1em}\noindent \emph{#2}}
\newenvironment{cvlist}%
{\begin{list}{}{%
\setlength{\topsep}{0pt}
\setlength{\leftmargin}{15pt}}}
{\unskip\end{list}}
% define subsubsubsection
\titleclass{\subsubsubsection}{straight}[\subsection]
\newcounter{subsubsubsection}[subsubsection]
\renewcommand\thesubsubsubsection{\thesubsubsection.\arabic{subsubsubsection}}
\renewcommand\theparagraph{\thesubsubsubsection.\arabic{paragraph}} % optional; useful if paragraphs are to be numbered
\titleformat{\subsubsubsection}
{\normalfont\normalsize\bfseries}{\thesubsubsubsection}{1em}{}
\titlespacing*{\subsubsubsection}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{5}{\z@}%
{3.25ex \@plus1ex \@minus.2ex}%
{-1em}%
{\normalfont\normalsize\bfseries}}
\renewcommand\subparagraph{\@startsection{subparagraph}{6}{\parindent}%
{3.25ex \@plus1ex \@minus .2ex}%
{-1em}%
{\normalfont\normalsize\bfseries}}
\def\toclevel@subsubsubsection{4}
\def\toclevel@paragraph{5}
\def\toclevel@paragraph{6}
\def\l@subsubsubsection{\@dottedtocline{4}{7em}{4em}}
\def\l@paragraph{\@dottedtocline{5}{10em}{5em}}
\def\l@subparagraph{\@dottedtocline{6}{14em}{6em}}
\makeatother
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}
答案1
你可以尝试这个技巧:
\newcounter{oldchapter}
\let\myoldchapter=\chapter
\makeatletter
\def\chapter{\@ifstar{\ifnum\value{chapter}>0 \setcounter{oldchapter}{\numexpr\value{chapter}+1\relax}\fi\myoldchapter}{\ifnum\value{chapter}>0 \setcounter{oldchapter}{\numexpr\value{chapter}+1\relax}\fi\myoldchapter}}
\makeatother
\xdef\AfterApp{0}
\newenvironment{myappendices}{\cleardoublepage\setcounter{page}{1}\setcounter{oldchapter}{\numexpr\value{chapter}-\value{oldchapter}}\begin{appendices}\xdef\AfterApp{1}}{\end{appendices}}
\renewcommand{\thepage}{
\ifnum\value{oldchapter}=0 App\else\ifnum\value{chapter}=0 \theoldchapter\else\ifnum\AfterApp=0 \thechapter\else\Alph{chapter}\fi\fi\fi-\arabic{page}
}
只需在序言中添加这些行并注释掉您自己的行\renwecommand{\thepage}
...同时将appendices
环境更改为myappendices
检查是否有效,我们可以使用可选参数等改进章节的破解方法。(我不知道应该在附录开始而不是章节中显示什么,只是在那里使用了一个应用程序并将页面设置为 1)。
如果它有效我们可以改进它...