목차에서 섹션 번호 제거

목차에서 섹션 번호 제거

목차에서 섹션 번호를 제거하려면 어떻게 해야 합니까? 내 문서 클래스는 다음과 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

\makeatletterAstrinus의 조언에 따라 와 사이에 두 줄의 코드를 추가할 수 있습니다 \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}

\newpage다음에 a가 있는지 확인해야 합니다.\tableofcontents

여기에 이미지 설명을 입력하세요

관련 정보