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 etoc
do 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 tocdepth
contador 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 tocloft
pacote (não usados aqui)
Observe a diferença entre secnumdepth
e tocdepth
contadores:
tocdepth
decide quais níveis são mostrados no toc (-1 até 6) depart
atésubparagraph
(para classes LaTeX padrão)secnumdepth
decide 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}
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 \@chapter
comando:
\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}
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}
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}