Text Formatting\backmatter chapter gets absorbed by preceding chapter ??!

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
AleCes
Posts: 286
Joined: Sat Nov 13, 2010 9:54 pm

\backmatter chapter gets absorbed by preceding chapter ??!

Post by AleCes »

Stefan_K wrote:For such numbering fixes the chngcntr package is usually a good tool.

Stefan
I tried:
\usepackage{chngcntr}
...
\newcounter{section}
But I get the following error:
! LaTeX Error: Command \c@section already defined.
Or name \end... illegal, see p.192 of the manual.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

\backmatter chapter gets absorbed by preceding chapter ??!

Post by Stefan Kottwitz »

Don't use \newcounter, as the counters are already defined. Instead, use \counterwithin or \counterwithout, for binding or removing counters to chapters, that's the main purpose.

Btw. if you rely on a section counter being reset by a new unnumbered chapter, you could step the chapter counter, invisibly, by \refstepcounter{chapter} which also resets the section counter if numbered per chapter.

Stefan
LaTeX.org admin
AleCes
Posts: 286
Joined: Sat Nov 13, 2010 9:54 pm

\backmatter chapter gets absorbed by preceding chapter ??!

Post by AleCes »

With \counterwithin{section} I get the same error reported above.
With \refstepcounter{chapter} I get:
! Package chngcntr Error: L is not a counter.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

\backmatter chapter gets absorbed by preceding chapter ??!

Post by Stefan Kottwitz »

\counterwithin requires two arguments, such as \counterwithin{section}{chapter}.

Stefan
LaTeX.org admin
AleCes
Posts: 286
Joined: Sat Nov 13, 2010 9:54 pm

\backmatter chapter gets absorbed by preceding chapter ??!

Post by AleCes »

Stefan_K wrote:\counterwithin requires two arguments, such as \counterwithin{section}{chapter}.

Stefan
But this way I get section and subsection numbers preceded by the chapter, the very thing I'd excluded by default in the prologue:

Code: Select all

\usepackage{titlesec}
\setcounter{secnumdepth}{4}
\renewcommand*{\thesection}{\arabic{section}}
\renewcommand*{\thesubsubsection}{\alph{subsubsection}}
\titleformat{\subsection}[runin]{\normalfont\bfseries}{\thesubsection}{0.5em}{}[\quad]
\titleformat{\subsubsection}[runin]{\normalfont\bfseries}{\thesubsubsection)}{0.5em}{}[\qquad]
Post Reply