
我本質上想做的是刪除目錄之外的所有部分的編號(主要是標題和主體),以便各部分在那裡編號,但我的左側標題僅顯示該部分的名稱,而不是其編號。我該怎麼辦?
這是我的程式碼:
\documentclass[a4paper,english,oneside]{article}
\usepackage{fancyhdr}
\usepackage[top=1in,left=1in,right=1in,bottom=1in]{geometry}
\pagestyle{fancy}
\begin{document}
\tableofcontents
\newpage
\section{Section}
\end{document}
如果對我提出問題的方式有任何問題或建議,如果您能提及,我將不勝感激。
答案1
您可以在序言中使用以下內容從標題和主文件中刪除部分枚舉顯示:
\makeatletter
\renewcommand{\@seccntformat}[1]{}
\AtBeginDocument{\renewcommand{\sectionmark}[1]{\markright{\MakeUppercase{#1}}}}
\makeatother
第一個更新了文件內章節標題的格式設定方式。每個sec
tional 單元都有其編號(或c
ou nt
er)以及隨後到標題文字format
的間隙\@seccntformat
。這適用於所有發出的截面單位的預設格式\@startsection
。
第二個更新\sectionmark
為僅設定部分標題並完全避免對\thesection
(部分計數器表示)的任何引用。我們將這個重新定義推遲到可以\AtBeginDocument
選擇\pagestyle
重新定義它為止。人們必須對其他部門層級做類似的事情(例如\subsection
,...)。
\documentclass{article}
\makeatletter
\renewcommand{\@seccntformat}[1]{}
\AtBeginDocument{\renewcommand{\sectionmark}[1]{\markright{\MakeUppercase{#1}}}}
\makeatother
\pagestyle{headings}
\usepackage{lipsum}% Just for this example
\sloppy% Just for this example
\begin{document}
\tableofcontents
\section{A section}
\lipsum[1-20]
\section{Another section}
\lipsum[1-20]
\section{Yet another section}
\lipsum[1-20]
\section{A final section}
\lipsum[1-20]
\end{document}
以上工作在預設文件設定下進行。其他可能影響截面結構的包可能需要更多調整。