
article
由于我使用的几个包和格式限制,我被迫使用文档类:。
有些章节和小节的名称很长,因此标题中没有足够的空间来显示所有内容。
我只使用:section-->subsection-->subsubsection,没有“chapter”。
我希望标题仅显示subsection
姓名和数字,而不显示sections
。我该怎么做?
当我使用时,\fancyhf{}
所有内容都会从标题中消失。
我也尝试了在这个网站上找到的解决方案
\documentclass[oneside,a4paper]{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\slshape }
\fancyfoot[R]{Page \thepage\ of \pageref{LastPage}}
...但它什么都没显示。我认为问题可能是文档类别与他们那里的不一样,但我无法改变这一点。
感谢您的帮助!
答案1
您需要重新定义填充标记的命令:
\documentclass{article}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand\sectionmark[1]{} %section doesn't set a mark
\makeatletter
\renewcommand\subsectionmark[1]{% but subsection should
\markright{\MakeUppercase{\ifnum\c@secnumdepth >\m@ne \thesubsection \quad \fi #1}}}
\makeatother
\begin{document}
\section{abc}\subsection{subsection}
\lipsum
\end{document}