
Estou usando a classe book
e para cada capítulo, seção, subseção, etc. a numeração começa assim:
Capítulo 1
Seção 1.1
Seção 1.2
Seção 1.3. . .
Eu gostaria de ter algo assim:
Capítulo 1
Seção 1.0
Seção 1.1
Seção 1.2
Alguma sugestão? Muito obrigado por sua ajuda.
Responder1
Você pode redefinir \thesection
para que emita o número atual menos um.
\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}
Responder2
\chapter
calls \@chapter
, o que faz \refstepcounter
(no mainmatter
modo) - isso significa que qualquer contador na lista de redefinição do contador de capítulos é zerado, isso é verdade para o section
contador, é claro.
Ou \@chapter
é redefinido ou pode-se adicionar algum código adicional, que define o contador da seção -1
após a conclusão do refstepping.
Observação: isso faznãodefina os subsection
contadores para -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}
Aqui está uma versão que se estende até \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}
Responder3
Você poderia fazer algo assim para cada seção:
\setcounter{section}{-1}
Nota: escrevi originalmente \setcounter{section}{0}
ao responder.