下面的代码生成了一个章节标题,这正是我想要的,但它也包含章节编号。因为它在页眉中,而页眉也包含页码,这会让读者感到困惑。如何在保留章节标题的同时删除章节编号?
\documentclass[11pt,a4paper,twoside]{article}
\usepackage[latin1]{inputenc}
\usepackage[centering]{geometry}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{tocloft}
%for alternating title with author and page number
\fancyhf{}
\renewcommand\headrulewidth{0pt}
\fancyhead[CO]{\nouppercase\leftmark}
\fancyhead[CE]{\hdrtitle}
\fancyhead[LE,RO]{\thepage}
\pagestyle{fancy}
\title{MY TITLE}
\author{MY NAME}
\makeatletter
\let\hdrtitle\@title
\makeatother
\begin{document}
\tableofcontents
\section{Part A}
\lipsum[1-5]
\subsection{Part A1}
\lipsum[1-5]
\section{Part B}
\lipsum[1-5]
\end{document}
答案1
重新定义\sectionmark
以抑制章节编号:
\renewcommand\sectionmark[1]{\markboth{#1}{}}
完整示例:
\documentclass[11pt,a4paper,twoside]{article}
\usepackage[latin1]{inputenc}
\usepackage[centering]{geometry}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{tocloft}
%for alternating title with author and page number
\fancyhf{}
\renewcommand\headrulewidth{0pt}
\fancyhead[CO]{\nouppercase\leftmark}
\fancyhead[CE]{\hdrtitle}
\fancyhead[LE,RO]{\thepage}
\pagestyle{fancy}
\renewcommand\sectionmark[1]{\markboth{#1}{}}
\title{MY TITLE}
\author{MY NAME}
\makeatletter
\let\hdrtitle\@title
\makeatother
\begin{document}
\tableofcontents
\section{Part A}
\lipsum[1-5]
\subsection{Part A1}
\lipsum[1-5]
\section{Part B}
\lipsum[1-5]
\end{document}