我正在写论文。我想在页眉右侧添加页码,在页眉左侧写上章节名称。我使用了以下命令,但不起作用。
\documentclass[letterpaper,12pt,titlepage,oneside,final]{article}
\usepackage{fancyhdr}
\fancyhead{} % Clears all page headers and footers
\pagestyle{fancy}
\lhead{}
\rhead{\thepage}
\cfoot{center of the footer!}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\begin{document}
\lhead{\emph{chapter1}}
\input{chapter1/introduction}
\lhead{\emph{chapter1}}
\input{chapter2/name}
\lhead{\emph{chapter3}}
\input{chapter3/name2}
\lhead{\emph{chapter3}}
\input{chapter4/name3}
\end{document}
答案1
如果我正确理解了这个问题,以下就是您正在寻找的内容。
\documentclass[letterpaper,12pt,titlepage,oneside,final]{report}
\usepackage{fancyhdr}
\usepackage{blindtext}
\fancyhead{} % Clears all page headers and footers
\setlength{\headheight}{15pt}
\pagestyle{fancy}
\fancyhead[r]{\thepage}
\fancyhead[l]{\fancyplain{\fancy}{\slshape\leftmark}}
\fancyfoot[c]{center of the footer!}
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyhead[r]{\thepage}
\fancyfoot[c]{center of the footer}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\renewcommand{\chaptermark}[1]{\markboth{\itshape\chaptername~\thechapter}{}}
\begin{document}
\chapter{Wombat}
\blindtext[5]
\section{tabmow}
\blindtext[5]
\chapter{Capybara}
\blindtext[5]
\section{arabypac}
\blindtext[5]
\chapter*{Mara}
\markboth{Mara}{}
\blindtext[5]
\section{aram}
\blindtext[5]
\end{document}