
Estoy usando la clase book
y para cada capítulo, sección, subsección, etc. la numeración comienza de esta manera:
Capítulo 1
Sección 1.1
Sección 1.2
Sección 1.3. . .
Me gustaría tener en su lugar algo como esto:
Capítulo 1
Sección 1.0
Sección 1.1
Sección 1.2
¿Alguna sugerencia? Muchas gracias por tu ayuda.
Respuesta1
Puede redefinir \thesection
para que emita el número actual menos uno.
\documentclass{book}
\makeatletter
\renewcommand{\thesection}{%
\thechapter.\@arabic{\numexpr\c@section-1}%
}
\makeatother
\begin{document}
\tableofcontents
\chapter{First chapter}
\section{First section}
\section{Second section}
\section{Third section}
\chapter{Second chapter}
\section{First section}
\section{Second section}
\section{Third section}
\end{document}
Respuesta2
\chapter
llama \@chapter
, lo cual lo hace \refstepcounter
(en mainmatter
modo): esto significa que cualquier contador en la lista de reinicio del contador de capítulos se reinicia a cero, esto es cierto para el section
contador, por supuesto.
O \@chapter
se redefine o se puede agregar algún código adicional, que establezca el contador de sección -1
después de que se haya realizado el paso a paso.
Tenga en cuenta: Esto nonoestablezca los subsection
contadores en -1, etc.
\documentclass{book}
\usepackage{xpatch}
\makeatletter
\AtBeginDocument{%
\xpatchcmd{\@chapter}{%
\refstepcounter{chapter}%
}{%
\refstepcounter{chapter}%
\setcounter{section}{-1}%
}{\typeout{Success}}{}
}
\makeatother
\begin{document}
\tableofcontents
\chapter{First chapter}
\section{First section}
\section{Second section}
\section{Third section}
\chapter{Second chapter}
\section{First section}
\section{Second section}
\section{Third section}
\end{document}
Aquí hay una versión que se reduce a \subparagraph
:
\documentclass{book}
\usepackage{xpatch}
\makeatletter
\xpatchcmd{\@sect}{%
\refstepcounter{#1}%
}{%
\refstepcounter{#1}%
% Now use the \@elt - trick to set all depending counters to -1 (well even that one that shouldn't, most likely :-()
\def\@elt##1{\setcounter{##1}{-1}}
\csname cl@#1\endcsname%
}{}{}
\AtBeginDocument{%
\xpatchcmd{\@chapter}{%
\refstepcounter{chapter}%
}{%
\refstepcounter{chapter}%
\setcounter{section}{-1}%
}{\typeout{Success}}{\typeout{Failed!}}
}
\makeatother
\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{5}
\begin{document}
\tableofcontents
\chapter{First chapter}
\section{First section}
\subsection{First subsection}
\subsubsection{First subsubsection}
\paragraph{First paragraph}
\subparagraph{First subparagraph}
\section{Second section}
\subsection{First subsection}
\subsubsection{First subsubsection}
\paragraph{First paragraph}
\subparagraph{First subparagraph}
\section{Third section}
\chapter{Second chapter}
\section{First section}
\section{Second section}
\section{Third section}
\end{document}
Respuesta3
Podrías hacer algo como esto para cada sección:
\setcounter{section}{-1}
Nota: escribí originalmente \setcounter{section}{0}
al responder.