Fancyhdr 页脚在无章节开始的页面上不起作用

Fancyhdr 页脚在无章节开始的页面上不起作用

我习惯fancyhdr在每一页上放置文字和页码:

\usepackage{fancyheadings}

\fancypagestyle{plain}{
\fancyhf{}
\lhead{section \bfseries \thesection}
\chead{CS04-708 Main Project, 2011}
\cfoot[{\vspace*{0.2cm}Department of Production Engineering, GEC - Thrissur \\ \thepage }]{\vspace*{0.2cm}Department of     Production Engineering, GEC - Thrissur \\ \thepage }
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.5pt}
}

我只在章节开始的页面上获得了所需的页脚(请记住,章节开始的页面的默认页面样式是纯色的),其余页面只有数字(我猜这是默认样式)。我一直在 Google 上寻找解决方法,但无济于事。

编辑

CLS 文件

\ProvidesClass{mainreport}[]

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
\ProcessOptions

\LoadClass[12pt,oneside]{report}

\RequirePackage{graphicx}
\RequirePackage{amsfonts}
\RequirePackage{multicol}


% The list of packages needed for creating an advanced report class.

\RequirePackage{amsmath}
\RequirePackage{setspace}
\RequirePackage{textcase}
\RequirePackage[  bottom = 2.50cm]{geometry}
\usepackage{fancyhdr}
\pagestyle{plain}
\fancypagestyle{plain}{
    \fancyhf{}
    \lfoot{Department of Production Engineering, GEC - Thrissur }
    \rfoot{\thepage}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
}




% Macro for List of Symbols
\def\listofsymbols{\input{symbols} \clearpage}
\def\addsymbol #1: #2#3{$#1$ \> \parbox{5in}{#2 \dotfill \pageref{#3}}\\}
\def\newsymbol#1{\label{#1}} 

\pagenumbering{roman}

\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}


% for setting up alternative directory paths to graphics files,
% remember to comment in "graphics" package
%
\graphicspath{{./eps/}{./tiff/}{./jpg/}{./fig/}{./dia/}{./gnuplot/}{./png/}}


%------------
\usepackage{geometry}
\geometry{verbose,a4paper,tmargin=25.4mm,bmargin=31.75mm,lmargin=38.1mm,rmargin=31.75mm}

%To generate list of abbreviations
\usepackage{nomencl}
\makenomenclature


\renewcommand{\section}{\@startsection
{section}%                   % the name
{1}%                         % the level
{0mm}%                       % the indent
{-\baselineskip}%            % the before skip
{0.5\baselineskip}%          % the after skip
{\fontsize{12pt}{14.4pt}\selectfont \bf  \MakeTextUppercase}} % the style

\renewcommand\contentsname{\fontsize{14pt}{16.8pt}\selectfont \bf  \centering  \MakeTextUppercase{ Table of Contents}}
\renewcommand\listfigurename{\fontsize{14pt}{16.8pt}\selectfont \bf  \centering  \MakeTextUppercase{ List of Figures}}
\renewcommand\listtablename{\fontsize{14pt}{16.8pt}\selectfont \bf  \centering  \MakeTextUppercase{List of Tables }}
\renewcommand\nomname{\fontsize{14pt}{16.8pt}\selectfont \bf  \centering  \MakeTextUppercase{List of Abbreviations }}
\renewcommand\abstractname{\fontsize{14pt}{16.8pt}\selectfont \bf  \centering  \MakeTextUppercase{Abstract }}
\renewcommand\bibname{\fontsize{14pt}{16.8pt}\selectfont \bf  \centering  \MakeTextUppercase{Abstract }}

%\renewcommand\listsymbolsname{\fontsize{14pt}{16.8pt}\selectfont \bf  \centering  \MakeTextUppercase{Bibliography }}

\newcommand{\chhead}{\fontsize{14pt}{16.8pt}\selectfont \centerline}
\makeatletter
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
    %\ifnum \c@secnumdepth >\m@ne
    %    \huge\bfseries \@chapapp\space \thechapter
    %    \par\nobreak
    %    \vskip 20\p@
    %\fi
    \interlinepenalty\@M
    {\centering  \fontsize{14}{16.82} \selectfont  \bf \bfseries \thechapter .  \MakeTextUppercase{#1}\par\nobreak }
    \vskip 40\p@
  }}

  \makeatother

以及 TEX 文件

\newcommand{\projecttitle}{fImpact of Valve timing in Engine Performance}
\newcommand{\projectauthors}{{\normalsize \bf {Arvind.S.A}}}

\documentclass{mainreport}
\usepackage{lipsum}
\linespread{1.5}
\begin{document}
\addcontentsline{toc}{chapter}{Abstract}
\chapter*{Abstract}
\lipsum[1]
\tableofcontents
\newpage
\addcontentsline{toc}{chapter}{List of abbreviations}
\input{abbreviation}
\pagenumbering{arabic}
\chapter{First}
\lipsum[1-3]
\chapter{seond}
\lipsum[1-3]

%\bibliographystyle{amsplain}
%\bibliography{master}

\end{document}

我谢谢你的麻烦。

答案1

你使用的课程有很多缺陷。最主要的是非常设置无编号章节的方法错误。

以下是修订版本:

\ProvidesClass{mainreport}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
\ProcessOptions

\LoadClass[12pt,oneside]{report}

\RequirePackage{graphicx}
\RequirePackage{amsfonts}
\RequirePackage{multicol}


% The list of packages needed for creating an advanced report class.

\RequirePackage{amsmath}
\RequirePackage{setspace}
\RequirePackage{textcase}

% Macro for List of Symbols
\def\listofsymbols{\input{symbols} \clearpage}
\def\addsymbol #1: #2#3{$#1$ \> \parbox{5in}{#2 \dotfill \pageref{#3}}\\}
\def\newsymbol#1{\label{#1}} 

\pagenumbering{roman}

\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}


% for setting up alternative directory paths to graphics files,
% remember to comment in "graphics" package
%
\graphicspath{{./eps/}{./tiff/}{./jpg/}{./fig/}{./dia/}{./gnuplot/}{./png/}}


%------------
\usepackage{geometry}
\geometry{verbose,a4paper,tmargin=25.4mm,bmargin=31.75mm,lmargin=38.1mm,rmargin=31.75mm}
\usepackage{fancyhdr}
\pagestyle{fancy}
    \fancyhf{}
    \lfoot{Department of Production Engineering, GEC - Thrissur }
    \rfoot{\thepage}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
\fancypagestyle{plain}{
    \fancyhf{}
    \lfoot{Department of Production Engineering, GEC - Thrissur }
    \rfoot{\thepage}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
}




%To generate list of abbreviations
\usepackage{nomencl}
\makenomenclature


\renewcommand{\section}{\@startsection
{section}%                   % the name
{1}%                         % the level
{0mm}%                       % the indent
{-\baselineskip}%            % the before skip
{0.5\baselineskip}%          % the after skip
{\fontsize{12pt}{14.4pt}\selectfont \bfseries  \MakeTextUppercase}} % the style


\DeclareRobustCommand{\chhead}{\fontsize{14pt}{16.8pt}\bfseries\centering}
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \normalfont\centering
    %\ifnum \c@secnumdepth >\m@ne
    %    \huge\bfseries \@chapapp\space \thechapter
    %    \par\nobreak
    %    \vskip 20\p@
    %\fi
    \interlinepenalty\@M
    {\chhead\thechapter. \MakeTextUppercase{#1}\par\nobreak }
    \vskip 40\p@
  }}
\def\@makeschapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \normalfont\centering
    %\ifnum \c@secnumdepth >\m@ne
    %    \huge\bfseries \@chapapp\space \thechapter
    %    \par\nobreak
    %    \vskip 20\p@
    %\fi
    \interlinepenalty\@M
    {\chhead\MakeTextUppercase{#1}\par\nobreak }
    \vskip 40\p@
  }}

现在,如果您想在文档中添加页眉,请使用

\lhead{section \bfseries \thesection}
\chead{CS04-708 Main Project, 2011}

我不知道这个类是否由贵公司提供。如果是,它不应该设置显式页脚,而是依赖于文档中定义的宏。

答案2

如果没有完整的 MWE,我们只能猜测您的问题。以下代码对我有用:

% Book Class (This is a LaTeX2e document)  ***********************
% ----------------------------------------------------------------
\documentclass[12pt]{book}
\usepackage{lipsum}%provides dummy text
\usepackage{fancyhdr}
\usepackage[margin=1in,showframe]{geometry} % to show frames and control page layout
% ----------------------------------------------------------------
\fancypagestyle{plain}{% 
\fancyhf{} 
\lfoot{Department of Production Engineering, GEC - Thrissur } 
\rfoot{\thepage} 
\renewcommand{\headrulewidth}{0pt} 
\renewcommand{\footrulewidth}{0pt} 
}
%
\pagestyle{plain}
%
\begin{document}
\chapter{First}
\lipsum[1-8]
%
\end{document}

章节页脚:

在此处输入图片描述

第二页的页脚:

在此处输入图片描述

为了获得准确的诊断,请考虑添加完整的(非)工作 MWE。

相关内容