Sé \setcounter{secnumdepth}{1}
que te permite establecer la profundidad de las numeraciones, pero tengo que numerar solo secciones y subsecciones, no capítulos. ¿Hay una sola línea para hacer esto? He visto algunas respuestas a problemas similares, pero parecen demasiado complicadas para una tarea tan sencilla.
Respuesta1
El paquete muy elegante y sofisticado etoc
de nuestro compañero usuario jfbu proporciona los medios para ello.
Mediante el uso\etocsetlevel{level name}{level value}
es posible cambiar el nivel de la estructura (p. ej.capítulo) a algún nivel inferior (digamos, más allásubpárrafo) y luego restringir el tocdepth
contador a algún valor superior.
\etocsetlevel{chapter}{6}
y \setcounter{tocdepth}{4}
hará el trabajo.
Esto afecta sólo a la representación en el ToC, no en la parte principal del documento.
Podría ser necesario un ajuste de los espacios dentro del ToC, esto se puede lograr con los distintos \cft....
comandos del tocloft
paquete (no utilizados aquí).
Tenga en cuenta la diferencia entre secnumdepth
y tocdepth
contadores:
tocdepth
decide qué niveles se muestran en el toc (-1 hasta 6) desdepart
hastasubparagraph
(para clases estándar de LaTeX)secnumdepth
decide qué niveles obtienen números de sección en el 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
Si solo se deben eliminar los números de los capítulos (sin embargo, no para la sección 1.1, etc.), un truco consiste en parchear el \@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}
Respuesta2
Quizás puedas usar una clase KOMA-Script:
\documentclass[emulatestandardclasses]{scrbook}
\renewcommand\addchaptertocentry[2]{\addtocentrydefault{chapter}{}{#2}}
\usepackage{blindtext}% dummy text
\begin{document}
\tableofcontents
\Blinddocument
\Blinddocument
\end{document}
Respuesta3
Una solución con 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}