목차에서 장 번호 매기기를 숨기는 방법은 무엇입니까?

목차에서 장 번호 매기기를 숨기는 방법은 무엇입니까?

번호 매기기의 깊이를 설정할 수 있다는 것을 알고 있지만 \setcounter{secnumdepth}{1}장이 아닌 섹션과 하위 섹션에만 번호를 매겨야 합니다. 이 작업을 수행하는 단일 라이너가 있습니까? 유사한 문제에 대한 몇 가지 답변을 보았지만 이러한 간단한 작업에 비해 지나치게 복잡해 보입니다.

답변1

etoc동료 사용자인 jfbu의 매우 화려하고 정교한 패키지가 이를 위한 수단을 제공합니다.

를 사용하면 \etocsetlevel{level name}{level value}구조 수준을 이동할 수 있습니다(예:) 더 낮은 수준(예: 그 이상)으로하위 단락) 그런 다음 카운터 tocdepth를 위의 값으로 제한합니다.

\etocsetlevel{chapter}{6}그리고 \setcounter{tocdepth}{4}그 일을 할 것입니다.

이는 문서의 주요 부분이 아닌 ToC의 표현에만 영향을 미칩니다.

ToC 내의 간격 조정이 필요할 수 있습니다. 이는 패키지 \cft....의 다양한 명령을 사용하여 수행할 수 있습니다 tocloft(여기에서는 사용되지 않음).

secnumdepth와 카운터 의 차이점에 유의하세요 tocdepth.

  • tocdepthtoc(-1부터 6까지)에서 partto subparagraph(표준 LaTeX 클래스의 경우) 에 표시되는 레벨을 결정합니다.
  • secnumdepth주 문서에서 섹션 번호를 얻을 수준을 결정합니다.

\documentclass{book}
\usepackage{etoc}       
\setcounter{secnumdepth}{4}% Show down to subsubsection
\begin{document}    

\setcounter{tocdepth}{4} %for main TOC, only show chapter/section
\etocsetlevel{part}{6} % push away the chapters
\etocsetlevel{chapter}{6}  % push away the chapters, beyond toc depth (4 )
\tableofcontents
\chapter{this is chapter heading}    
  \section{this is section heading}
  \subsection{this is subsection heading}
  \subsubsection{this is subsubsection heading}
  \subsubsection{this is another subsubsection heading}
  \chapter{another chapter}
  \section{this is yet another section} 
\end{document}

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

편집하다

장의 번호만 제거해야 하는 경우(단, 섹션 1.1 등은 제외) 한 가지 방법은 명령을 패치하는 것입니다 \@chapter.

\documentclass{book}
\usepackage{tocloft}
\setcounter{secnumdepth}{4}% Show down to subsubsection

\setlength{\cftchapindent}{-20pt}% Just some value...

\usepackage{xpatch}

\makeatletter
\xpatchcmd{\@chapter}{\addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}}{%
                      \addcontentsline{toc}{chapter}{\protect\numberline{}#1}}{\typeout{Success}}{\typeout{Failed!}}
\makeatother

\begin{document}    

\tableofcontents

%\renewcommand{\thechapter}{\arabic{chapter}}
\chapter{First chapter}
  \section{First section}
  \subsection{First subsection}
  \subsubsection{Even more in the basement}
  \chapter{Another chapter}
  \section{this is yet another section} 
\end{document} 

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

답변2

KOMA-Script 클래스를 사용할 수도 있습니다.

\documentclass[emulatestandardclasses]{scrbook}
\renewcommand\addchaptertocentry[2]{\addtocentrydefault{chapter}{}{#2}}

\usepackage{blindtext}% dummy text
\begin{document}
\tableofcontents
\Blinddocument
\Blinddocument
\end{document}

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

답변3

다음을 갖춘 솔루션 titletoc:

    \documentclass[11pt, a4paper]{book}

    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage{fourier}
    \usepackage{microtype}

    \usepackage{titletoc}%

      \titlecontents{chapter}[0em]{\lsstyle\smallskip\bfseries}%\vspace{1cm}%
      {}%
      {\itshape\bfseries}%numberless%
      {\hfill\contentspage}[\medskip]%
    %
     \titlecontents{section}[4.25em]{\smallskip}%
      {\contentslabel[\thecontentslabel]{2em}}%numbered
      {\hspace*{-1em}}%numberless
      {\hfill\contentspage}[\smallskip]%
    %
     \titlecontents{subsection}[7em]{}%
      {\contentslabel[\thecontentslabel]{2.75em}}%numbered
      {\hspace*{-1em}}%numberless
      {\hfill\contentspage}[\smallskip]

    \begin{document}
    \tableofcontents

    \chapter*{INTRODUCTION}
    \addcontentsline{toc}{chapter}{INTRODUCTION}

    \chapter{A NICE FIRST CHAPTER}

    \section{An Introductory Section}
    \newpage
    \section{Another Section}
    \subsection{A Boring Subsection }

    \end{document}

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

관련 정보