Como ocultar a numeração dos capítulos no índice?

Como ocultar a numeração dos capítulos no índice?

Eu sei \setcounter{secnumdepth}{1}que permite definir a profundidade das numerações, mas preciso numerar apenas seções e subseções, não capítulos. Existe uma linha única para fazer isso? Já vi algumas respostas para problemas semelhantes, mas parecem muito complicadas para uma tarefa tão simples.

Responder1

O pacote muito sofisticado e sofisticado etocdo nosso colega usuário jfbu fornece os meios para isso.

Usando \etocsetlevel{level name}{level value}é possível mudar o nível da estrutura (por exemplocapítulo) para algum nível inferior (digamos, alémsubparágrafo) e, em seguida, restrinja o tocdepthcontador a algum valor acima.

\etocsetlevel{chapter}{6}e \setcounter{tocdepth}{4}fará o trabalho.

Isto afeta apenas a representação na ToC, e não na parte principal do documento.

Pode ser necessário um ajuste de espaçamento dentro do ToC, isto pode ser conseguido com os vários \cft....comandos do tocloftpacote (não usados ​​aqui)

Observe a diferença entre secnumdepthe tocdepthcontadores:

  • tocdepthdecide quais níveis são mostrados no toc (-1 até 6) de partaté subparagraph(para classes LaTeX padrão)
  • secnumdepthdecide quais níveis recebem números de seção no documento principal.

\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}

insira a descrição da imagem aqui

Editar

Se apenas os números dos capítulos devem ser removidos (no entanto, não para a seção 1.1 etc.), um truque é corrigir o \@chaptercomando:

\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} 

insira a descrição da imagem aqui

Responder2

Talvez você possa usar uma classe KOMA-Script:

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

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

insira a descrição da imagem aqui

Responder3

Uma solução com 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}

insira a descrição da imagem aqui

informação relacionada