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

时间:2010-02-16 17:51:43

标签: latex

我在Latex上写了我的论文,并有一个模板。它除了一个以外的其他任何东西都能很好地工作。章节编号在每章的第一页上正确递增,但对于每章的连续页面,标题“第x章 - 这是一个章节标题”总是1作为章节编号。

以下是我认为与标题相关的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}

2 个答案:

答案 0 :(得分:1)

您是否尝试在使用fancyhdr包调用命令之前清除页眉和页脚?

类似的东西:

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{} % Clear Headers
\fancyfoot{} % Clear Footers
\lhead[\rm\thepage]{\fancyplain{}{\sl{\rightmark}}}
\rhead[\fancyplain{}{\sl{\leftmark}}]{\rm\thepage}
\chead{}\lfoot{}\rfoot{}\cfoot{}

答案 1 :(得分:1)

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

我在下面列出了我的标题代码部分。您将从我在该代码中的注释中看到仍有一个未解决的问题,但注释提供了一种解决方法。

%----------------------------------------------------------
\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中详细说明我的编码,请对此答案发表评论。