從目錄中刪除節號

從目錄中刪除節號

如何從目錄中刪除章節編號?我的文檔類別是article

\documentclass[a4paper]{article}
\begin {document}
\tableofcontents
\section{one}
test text number one
\section{two}
test text number two
\end{document}

在此輸入影像描述

答案1

您可以使用該軟體包輕鬆做到這一點titlesec/titlestoc。它具有允許在目錄中對編號和未編號部分(如果您想要添加未編號部分)採用不同格式的命令:

\documentclass[a4paper]{article}
\usepackage{titletoc}

\begin {document}
\titlecontents{section}[0em]
{\vskip 0.5ex}%
{\scshape}% numbered sections formatting
{\itshape}% unnumbered sections formatting
{}%

\tableofcontents

\section{A First Section}
Test text number one. 

\section{Another Section}
Test text number two. 

\section*{An Unnumbered Section}
Test text number three. 
\addcontentsline{toc}{section}{An Unnumbered Section}
\end{document} 

在此輸入影像描述

答案2

\makeatletter按照 Astrinus 的建議,您可以在和之間添加兩行程式碼\makeatother,如下所示艾格格的回答,修改目錄中的條目。以下是您可以執行此操作的方法:

\documentclass[12pt, a4paper]{article}

\makeatletter
\let\latexl@section\l@section
\def\l@section#1#2{\begingroup\let\numberline\@gobble\latexl@section{#1}{#2}\endgroup}
\makeatother

\begin{document}
\tableofcontents
\newpage
\section{One}
test text number one
\section{Two}
test text number two
\end{document}

請注意,您應該確保 a\newpage之後存在\tableofcontents

在此輸入影像描述

相關內容