Blame docs/xhtml/manual/sec-section-num.html

Packit Service 76cb02
Packit Service 76cb02
Packit Service 76cb02
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Chapter and Section numbering</title><link rel="stylesheet" type="text/css" href="manual.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /><link rel="home" href="index.html" title="DocBook to LaTeX Publishing" /><link rel="up" href="ch03.html" title="Chapter 3. Using dblatex" /><link rel="prev" href="sec-covers.html" title="Book Covers" /><link rel="next" href="sec-figinclude.html" title="Figure Inclusion" /></head><body>

Chapter and Section numbering

Depth of Section numbering and Table Of Content

Dblatex relies on latex to automatically compute the

Packit Service 76cb02
chapter and section numbers. It also relies on latex to produce the headings
Packit Service 76cb02
with these numbers, and to produce the Table Of Content containing these
Packit Service 76cb02
entries.

Some specific sections like preface,

Packit Service 76cb02
colophon, or dedication are not numbered
Packit Service 76cb02
because they are displayed in front and back matters, but they can be listed in
Packit Service 76cb02
the TOC if the related parameters are set
Packit Service 76cb02
(dedication.tocdepth, preface.tocdepth, colophon.tocdepth).

More generally you can configure the depth of the chapter and section

Packit Service 76cb02
numbering with the parameter doc.section.depth, and the
Packit Service 76cb02
depth of the entries in the TOC with the parameter
Packit Service 76cb02
toc.section.depth

.
Packit Service 76cb02
Packit Service 76cb02

Note however that an unumbered section

Packit Service 76cb02
becomes an informal component, and therefore you can only link to such a section
Packit Service 76cb02
by using a specific xrefstyle because their label built with the
Packit Service 76cb02
automatic number does not exist anymore. The other drawback is that
Packit Service 76cb02
all the sections included in an unnumbered section or chapter are
Packit Service 76cb02
unnumbered.

Using the latex style for section numbering

A well customized latex style can be a powerfull yet versatile

Packit Service 76cb02
alternative to the use of section and/or TOC depth parameter. With some latex
Packit Service 76cb02
packages you can easily format the headings to remove the numbers, or transform them. See the section called “Customized LaTeX style” to know how to use your own latex
Packit Service 76cb02
style with dblatex.

The benefit of this method is that you can fully control how the titles

Packit Service 76cb02
must be displayed, you do not have to play with latex counters to have the right
Packit Service 76cb02
depth, and the sections do not lost their formal number label.

The following example shows how you can customize the chapter title by

Packit Service 76cb02
using the latex package titlesec, and shows how to remove the chapter label in
Packit Service 76cb02
the Table Of Content with the package titletoc. Look in particular in the
Packit Service 76cb02
listing where text is emphasized.

Packit Service 76cb02
\usepackage{titlesec}
Packit Service 76cb02
Packit Service 76cb02
%% Example 1: Redefines the heading to remove the chapter label
Packit Service 76cb02
%% The 2nd parameter only contains \filcenter without any label
Packit Service 76cb02
\titleformat{\chapter}[block]
Packit Service 76cb02
{\filcenter\huge}{\filcenter}{20pt}{\Huge}
Packit Service 76cb02
Packit Service 76cb02
%% Example 2: Put the chapter number in word
Packit Service 76cb02
%% The title of the first chapter is then displayed like this:
Packit Service 76cb02
%% "Chapter One <chapter title>"
Packit Service 76cb02
\newcommand\makeletterof[1]{%
Packit Service 76cb02
\ifthenelse{\equal{#1}{1}}{ONE}{%
Packit Service 76cb02
\ifthenelse{\equal{#1}{2}}{TWO}{%
Packit Service 76cb02
\ifthenelse{\equal{#1}{3}}{THREE}{%
Packit Service 76cb02
\ifthenelse{\equal{#1}{4}}{FOUR}{%
Packit Service 76cb02
\ifthenelse{\equal{#1}{5}}{FIVE}{%
Packit Service 76cb02
\ifthenelse{\equal{#1}{6}}{SIX}{%
Packit Service 76cb02
\ifthenelse{\equal{#1}{7}}{SEVEN}{%
Packit Service 76cb02
\ifthenelse{\equal{#1}{8}}{EIGHT}{%
Packit Service 76cb02
\ifthenelse{\equal{#1}{9}}{NINE}{%
Packit Service 76cb02
\ifthenelse{\equal{#1}{10}}{TEN}{%
Packit Service 76cb02
\ifthenelse{\equal{#1}{11}}{ELEVEN}{%
Packit Service 76cb02
\ifthenelse{\equal{#1}{12}}{TWELVE}{%
Packit Service 76cb02
#1}}}}}}}}}}}}}
Packit Service 76cb02
Packit Service 76cb02
\titleformat{\chapter}[block]
Packit Service 76cb02
{\filcenter\ttfamily\huge}%
Packit Service 76cb02
{\filcenter\MakeUppercase{\chaptertitlename} \makeletterof{\thechapter}}{20pt}{\Huge}
Packit Service 76cb02
Packit Service 76cb02
Packit Service 76cb02
%% Make TOC entries for chapters without label
Packit Service 76cb02
\usepackage{titletoc}
Packit Service 76cb02
Packit Service 76cb02
\titlecontents{chapter} %
Packit Service 76cb02
[1.5em] % 
Packit Service 76cb02
{\addvspace{1em plus 0pt}\bfseries} %
Packit Service 76cb02
{\hspace{-1.3em}} % no number, remove room reserved for it 
Packit Service 76cb02
{\hspace{-1.3em}} %
Packit Service 76cb02
{\hfill \contentspage} %
Packit Service 76cb02
[\addvspace {0pt}]
Packit Service 76cb02

Using the label attribute

If you need to mix numbered and not numbered chapters, the numbering depth

Packit Service 76cb02
parameters will not help. The latex style will not easily detect that for
Packit Service 76cb02
some chapters the number should be displayed and for others it should not.
Packit Service 76cb02

To mix numbered and unnumbered chapters you can use a label with an

Packit Service 76cb02
empty string for the chapters that must not be numbered, as shown by the example
Packit Service 76cb02
below.

Packit Service 76cb02
<chapter id="intro" label=""><title>Introduction</title>
Packit Service 76cb02
  <!-- This chapter must be displayed with no number, like a preface -->
Packit Service 76cb02
</chapter>
Packit Service 76cb02
<chapter id="before" label=""><title>Pre-requisite</title>
Packit Service 76cb02
  <!-- This chapter must be displayed with no number, like a preface -->
Packit Service 76cb02
</chapter>
Packit Service 76cb02
<chapter id="chap1"><title>First chapter</title>
Packit Service 76cb02
  <!-- First numbered chapter -->
Packit Service 76cb02
</chapter>
Packit Service 76cb02
...
Packit Service 76cb02
<chapter id="after" label=""><title>Conclusion</title>
Packit Service 76cb02
  <!-- This chapter must be displayed with no number, like a colophon -->
Packit Service 76cb02
</chapter>
Packit Service 76cb02
...
Packit Service 76cb02

You can also set a label to a specific integer to force a section

Packit Service 76cb02
counter. In this case there is no more automatic numbering. The automatic
Packit Service 76cb02
numbering then applies to the following sections that increment the counter
Packit Service 76cb02
set for this section if there is no label.

Packit Service 76cb02
<chapter id="intro" label="2"><title>Introduction</title>
Packit Service 76cb02
  <!-- This chapter is forced to have number 2 (it should be 1) -->
Packit Service 76cb02
  <section id="s1" label="3"><title>Section 2.3</title>
Packit Service 76cb02
    <!-- This section is forced to have number 3 (it should be 1) -->
Packit Service 76cb02
    <section id="s11" label="4"><title>Section 2.3.4</title>
Packit Service 76cb02
      <!-- This section is forced to have number 4 (it should be 1) -->
Packit Service 76cb02
    </section>
Packit Service 76cb02
  </section>
Packit Service 76cb02
</chapter>
Packit Service 76cb02
Packit Service 76cb02
   Figure Inclusion
Packit Service 76cb02
  </body></html>