为什么部分名称显示两次?
\documentclass[12pt]{report}
\usepackage{enumitem}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\sectionmark}{}
\renewcommand{\chaptermark}[1]{\markboth{}{}}
\renewcommand{\footrulewidth}{0.5pt}
\renewcommand{\headrulewidth}{0.5pt}
\fancyfoot[L]{\textit{NITK Surathkal}}
\fancyfoot[R]{\textit{Electrical Dept.}}
\fancyfoot[C]{\textit{\thepage}}
\begin{document}
\pagenumbering{arabic}
\chapter{Introduction}
Inro
\section{Objective}
The \section{Thesis Outline}
\end{document}
答案1
\sectionmark
在标准类中定义(例如report.cls
)中定义为具有一争论。
省略它,\section
代码调用\sectionmark{foo}
如下:
\sectionmark% does nothing if being defined as `\renewcommand{\sectionmark}{}`
foo
即孤立参数foo
出现在输入流中,即它被排版(在大多数情况下,在极少数情况下它可能是执行的另一个宏)
\documentclass[12pt]{report}
\usepackage{enumitem}
\usepackage{fancyhdr}
\pagestyle{fancy}
\makeatletter
\renewcommand{\sectionmark}[1]{}%
% or
%\let\sectionmark\@gobble%
\makeatother
\renewcommand{\chaptermark}[1]{\markboth{}{}}
\renewcommand{\footrulewidth}{0.5pt}
\renewcommand{\headrulewidth}{0.5pt}
\fancyfoot[L]{\textit{NITK Surathkal}}
\fancyfoot[R]{\textit{Electrical Dept.}}
\fancyfoot[C]{\textit{\thepage}}
\begin{document}
\pagenumbering{arabic}
\chapter{Introduction} Intro
\section{Objective}
The \section{Thesis Outline}
\end{document}
答案2
的重新定义\sectionmark
是错误的。但是,由于您似乎只是重新定义\sectionmark
并\chaptermark
删除标题,因此有一个更简单的解决方案:在重新定义它们之前清除所有字段。
我还添加了在章节起始页中使用相同样式的代码(但省略了顶部规则)。
\documentclass[12pt]{report}
\usepackage{enumitem}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\footrulewidth}{0.5pt}
\renewcommand{\headrulewidth}{0.5pt}
\fancyhf{} % clear all fields
\fancyfoot[L]{\textit{NITK Surathkal}}
\fancyfoot[R]{\textit{Electrical Dept.}}
\fancyfoot[C]{\textit{\thepage}}
% add the following if you want a uniform style also
% for the chapter starting pages
\fancypagestyle{plain}
\renewcommand{\footrulewidth}{0.5pt}%
\renewcommand{\headrulewidth}{0pt}% no rule at the top
\fancyhf{}% clear all fields
\fancyfoot[L]{\textit{NITK Surathkal}}%
\fancyfoot[R]{\textit{Electrical Dept.}}%
\fancyfoot[C]{\textit{\thepage}}%
}
\begin{document}
\pagenumbering{arabic}
\chapter{Introduction}
Intro
\section{Objective}
\section{Thesis Outline}
\end{document}