子部分名称作为右标题?

子部分名称作为右标题?

我怎样才能将每个小节的名称作为每页的右侧标题?

我正在使用下面的代码,但\rhead命令实际上将“thesubsection”放在了每个页面的顶部!

\usepackage{fancyhdr}

\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markboth{#1}{}} % set the \leftmark

\fancyhf{}

\fancyhead[L]{\leftmark} % 1. sectionname
\fancyfoot[C]{\thepage}
\fancypagestyle{plain}{%
  \fancyhf{}%
  \renewcommand{\headrulewidth}{0pt}%
}

\rhead{thesubsection}

\begin{document}
\end{document} 

答案1

请看看以下内容是否能解决您的目的:

\documentclass[14pt,a4paper,twoside]{article} % document class
\usepackage{fancyhdr}

\pagestyle{fancy}
\renewcommand{\subsectionmark}[1]{\markboth{#1}{}} % MAKE IT 'subsectionmark' INSTEAD OF 'sectionmark'

\fancyhf{}

\fancyhead[R]{\leftmark} %%%%%%%%%CHANGE 'L' TO 'R' HERE %%%%%%
\fancyfoot[C]{\thepage}
\fancypagestyle{plain}{%
    \fancyhf{}%
    \renewcommand{\headrulewidth}{0pt}%
}

%\rhead{\thesubsection} %%%COMMENT THIS LINE%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\section{OneSection}
    One two three
\subsection{MySubSection}

\end{document} 

在此处输入图片描述

编辑1:当需要在左侧标题上显示章节名称时 请查看以下是否有效(文档类别为“报告”):

\documentclass[a4paper,twoside]{report} % document class-
\usepackage{fancyhdr}

\pagestyle{fancy}
\renewcommand{\chaptername}{}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\subsectionmark}[1]{\markright{#1}{}}

\fancyhf{}

\fancyhead[L]{\leftmark}
\fancyhead[R]{\rightmark} % 1. sectionname
\fancyfoot[C]{\thepage}
\fancypagestyle{plain}{%
    \fancyhf{}%
    \renewcommand{\headrulewidth}{0pt}% 
}

%\rhead{\thesubsection}

\begin{document}
\chapter{ChapterOne}
\section{OneSection}
One two three. On first page of a chapter header doesn't appear by default.
\vfill
Two \newpage
\subsection{MySubSection}

\end{document} 

章节第一页 在此处输入图片描述

章节第二页 在此处输入图片描述

相关内容