gpt4 book ai didi

latex - 除第一页外,页眉上的章节编号错误

转载 作者:行者123 更新时间:2023-12-02 02:34:49 24 4
gpt4 key购买 nike

我正在用 Latex 撰写论文并有一个模板。它适用于除一个之外的所有其他事物。章节编号在每一章的第一页上正确递增,但对于每一章的连续页面,标题为“第 x 章 - 这是章节标题”的章节编号始终为 1。

以下是我认为与 header 相关的 CLS 文件中的代码示例:

\newcommand\btypeout[1]{\bhrule\typeout{\space #1}\bhrule}
\def\today{\ifcase\month\or
January\or February\or March\or April\or May\or June\or
July\or August\or September\or October\or November\or December\fi
\space \number\year}
\usepackage{setspace}
\onehalfspacing
\setlength{\parindent}{0pt}
\setlength{\parskip}{2.0ex plus0.5ex minus0.2ex}
\usepackage{vmargin}
\setmarginsrb { 1.5in} % left margin
{ 0.6in} % top margin
{ 1.0in} % right margin
{ 0.8in} % bottom margin
{ 20pt} % head height
{0.25in} % head sep
{ 9pt} % foot height
{ 0.3in} % foot sep
\raggedbottom
\setlength{\topskip}{1\topskip \@plus 5\p@}
\doublehyphendemerits=10000 % No consecutive line hyphens.
\brokenpenalty=10000 % No broken words across columns/pages.
\widowpenalty=9999 % Almost no widows at bottom of page.
\clubpenalty=9999 % Almost no orphans at top of page.
\interfootnotelinepenalty=9999 % Almost never break footnotes.
\usepackage{fancyhdr}
\lhead[\rm\thepage]{\fancyplain{}{\sl{\rightmark}}}
\rhead[\fancyplain{}{\sl{\leftmark}}]{\rm\thepage}
\chead{}\lfoot{}\rfoot{}\cfoot{}
\pagestyle{fancy}

%% Chapter Heading ---------------
\renewcommand{\chaptermark}[1]{\btypeout{\thechapter\space #1}\markboth{\@chapapp\ \thechapter\ #1}{\@chapapp\ \thechapter\ #1}}

%%--------------------------------------------------
\renewcommand{\sectionmark}[1]{}
\renewcommand{\subsectionmark}[1]{}
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}

最佳答案

虽然我没有使用与您相同的模板,但我对类似问题的解决方案涉及三个包:sectsty、fancyhdr 和 partpg(我重写了 chappg 以提供与 chappg 对章节相同的效果)。

我列出了标题代码的以下部分。从我对该代码的评论中,您会看到还有一个 Unresolved 问题,但评论提供了一种解决方法。

%----------------------------------------------------------
\usepackage{sectsty} % Fancy section Headers.
\usepackage{fancyhdr} % Headers and footers.
\usepackage[auto]{partpg} % Modified version of chappg to provide part-pageno type page numbering.
\usepackage{appendix} % Multiple appendix sections in multi part document.
\usepackage[style=altlist,toc=true]{glossary} % Enhanced glossary commands.
%----------------------------------------------------------
\makeglossary
% There is a conflict between partpg and makeglos.
% To generate the glossary, run makeglos AFTER removing the next line.
\renewcommand{\partpgsep}{.}
\renewcommand{\glossaryname}{Glossary}
\setlength{\headheight}{13.6pt}
\pagestyle{fancy}%
{% Ensure appendices in different parts restart numbering at A each time
\renewcommand{\restoreapp}{}

\fancypagestyle{plain}{% Redefine style to use the relevant elements on the part pages
\fancyhfoffset[LE,RO]{\marginparsep+\marginparwidth}
\renewcommand{\headrulewidth}{0.1pt}
\renewcommand{\footrulewidth}{0.1pt}
\fancyhead[LE,RO]{\leftmark}
\fancyfoot[LE,RO]{\thepage}}%

\makeatletter% Redefine cleardoublepage so blank pages at the end of chapters have desired header.
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\pagestyle{plain}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother

\fancyhead{}
\fancyfoot{}
%----------------------------------------------------------
\begin{document}
\end{document}
%----------------------------------------------------------

如果这让您前进,并且您想了解我在 partpg 中的编码的详细信息,请对此答案发表评论。

关于latex - 除第一页外,页眉上的章节编号错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2275052/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com