Debian Codegraph @

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

raw
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><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.79.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><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter and Section numbering</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-covers.html">Prev</a> </td><th width="60%" align="center">Chapter 3. Using dblatex</th><td width="20%" align="right"> <a accesskey="n" href="sec-figinclude.html">Next</a></td></tr></table><hr /></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-section-num"></a>Chapter and Section numbering</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="sec-section-num.html#idp999">Depth of Section numbering and Table Of Content</a></span></dt><dt><span class="section"><a href="sec-section-num.html#idp1014">Using the latex style for section numbering</a></span></dt><dt><span class="section"><a href="sec-section-num.html#idp1026">Using the <code class="sgmltag-element">label</code> attribute</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="idp999"></a>Depth of Section numbering and Table Of Content</h3></div></div></div><p><span class="command"><strong>Dblatex</strong></span> relies on latex to automatically compute the
3 chapter and section numbers. It also relies on latex to produce the headings
4 with these numbers, and to produce the Table Of Content containing these
5 entries.</p><p>Some specific sections like <code class="sgmltag-element">preface</code>,
6 <code class="sgmltag-element">colophon</code>, or <code class="sgmltag-element">dedication</code> are not numbered
7 because they are displayed in front and back matters, but they can be listed in
8 the TOC if the related parameters are set
9 (<em class="parameter"><code>dedication.tocdepth</code></em>, <em class="parameter"><code>preface.tocdepth</code></em>, <em class="parameter"><code>colophon.tocdepth</code></em>).</p><p>More generally you can configure the depth of the chapter and section
10 numbering with the parameter <em class="parameter"><code>doc.section.depth</code></em>, and the
11 depth of the entries in the TOC with the parameter
12 <em class="parameter"><code>toc.section.depth</code></em></p>.
13
14 <p>Note however that an unumbered section
15 becomes an informal component, and therefore you can only link to such a section
16 by using a specific xrefstyle because their label built with the
17 automatic number does not exist anymore. The other drawback is that
18 all the sections included in an unnumbered section or chapter are
19 unnumbered.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="idp1014"></a>Using the latex style for section numbering</h3></div></div></div><p>A well customized latex style can be a powerfull yet versatile
20 alternative to the use of section and/or TOC depth parameter. With some latex
21 packages you can easily format the headings to remove the numbers, or transform them. See <a class="xref" href="sec-custom-latex.html" title="Customized LaTeX style">the section called “Customized LaTeX style”</a> to know how to use your own latex
22 style with <span class="command"><strong>dblatex</strong></span>.</p><p>The benefit of this method is that you can fully control how the titles
23 must be displayed, you do not have to play with latex counters to have the right
24 depth, and the sections do not lost their formal number label.</p><p>The following example shows how you can customize the chapter title by
25 using the latex package titlesec, and shows how to remove the chapter label in
26 the Table Of Content with the package titletoc. Look in particular in the
27 listing where text is emphasized.</p><pre class="programlisting">
28 \usepackage{titlesec}
29
30 %% Example 1: Redefines the heading to remove the chapter label
31 %% The 2nd parameter only contains \filcenter without any label
32 \titleformat{\chapter}[block]
33 {\filcenter\huge}{<span class="bold"><strong>\filcenter</strong></span>}{20pt}{\Huge}
34
35 %% Example 2: Put the chapter number in word
36 %% The title of the first chapter is then displayed like this:
37 %% "Chapter One &lt;chapter title&gt;"
38 \newcommand\makeletterof[1]{%
39 \ifthenelse{\equal{#1}{1}}{ONE}{%
40 \ifthenelse{\equal{#1}{2}}{TWO}{%
41 \ifthenelse{\equal{#1}{3}}{THREE}{%
42 \ifthenelse{\equal{#1}{4}}{FOUR}{%
43 \ifthenelse{\equal{#1}{5}}{FIVE}{%
44 \ifthenelse{\equal{#1}{6}}{SIX}{%
45 \ifthenelse{\equal{#1}{7}}{SEVEN}{%
46 \ifthenelse{\equal{#1}{8}}{EIGHT}{%
47 \ifthenelse{\equal{#1}{9}}{NINE}{%
48 \ifthenelse{\equal{#1}{10}}{TEN}{%
49 \ifthenelse{\equal{#1}{11}}{ELEVEN}{%
50 \ifthenelse{\equal{#1}{12}}{TWELVE}{%
51 #1}}}}}}}}}}}}}
52
53 \titleformat{\chapter}[block]
54 {\filcenter\ttfamily\huge}%
55 {<span class="bold"><strong>\filcenter\MakeUppercase{\chaptertitlename} \makeletterof{\thechapter}</strong></span>}{20pt}{\Huge}
56
57
58 %% Make TOC entries for chapters without label
59 \usepackage{titletoc}
60
61 \titlecontents{chapter} %
62 [1.5em] %
63 {\addvspace{1em plus 0pt}\bfseries} %
64 {<span class="bold"><strong>\hspace{-1.3em}</strong></span>} % no number, remove room reserved for it
65 {\hspace{-1.3em}} %
66 {\hfill \contentspage} %
67 [\addvspace {0pt}]
68 </pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="idp1026"></a>Using the <code class="sgmltag-element">label</code> attribute</h3></div></div></div><p>If you need to mix numbered and not numbered chapters, the numbering depth
69 parameters will not help. The latex style will not easily detect that for
70 some chapters the number should be displayed and for others it should not.
71 </p><p>To mix numbered and unnumbered chapters you can use a label with an
72 empty string for the chapters that must not be numbered, as shown by the example
73 below.</p><pre class="programlisting">
74 &lt;chapter id="intro" <span class="bold"><strong>label=""</strong></span>&gt;&lt;title&gt;Introduction&lt;/title&gt;
75 &lt;!-- This chapter must be displayed with no number, like a preface --&gt;
76 &lt;/chapter&gt;
77 &lt;chapter id="before" <span class="bold"><strong>label=""</strong></span>&gt;&lt;title&gt;Pre-requisite&lt;/title&gt;
78 &lt;!-- This chapter must be displayed with no number, like a preface --&gt;
79 &lt;/chapter&gt;
80 &lt;chapter id="chap1"&gt;&lt;title&gt;First chapter&lt;/title&gt;
81 &lt;!-- First numbered chapter --&gt;
82 &lt;/chapter&gt;
83 ...
84 &lt;chapter id="after" <span class="bold"><strong>label=""</strong></span>&gt;&lt;title&gt;Conclusion&lt;/title&gt;
85 &lt;!-- This chapter must be displayed with no number, like a colophon --&gt;
86 &lt;/chapter&gt;
87 ...
88 </pre><p>You can also set a label to a specific integer to force a section
89 counter. In this case there is no more automatic numbering. The automatic
90 numbering then applies to the following sections that increment the counter
91 set for this section if there is no label.</p><pre class="programlisting">
92 &lt;chapter id="intro" <span class="bold"><strong>label="2"</strong></span>&gt;&lt;title&gt;Introduction&lt;/title&gt;
93 &lt;!-- This chapter is forced to have number 2 (it should be 1) --&gt;
94 &lt;section id="s1" <span class="bold"><strong>label="3"</strong></span>&gt;&lt;title&gt;Section 2.3&lt;/title&gt;
95 &lt;!-- This section is forced to have number 3 (it should be 1) --&gt;
96 &lt;section id="s11" <span class="bold"><strong>label="4"</strong></span>&gt;&lt;title&gt;Section 2.3.4&lt;/title&gt;
97 &lt;!-- This section is forced to have number 4 (it should be 1) --&gt;
98 &lt;/section&gt;
99 &lt;/section&gt;
100 &lt;/chapter&gt;
101 </pre></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sec-covers.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sec-figinclude.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Book Covers </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 
102 Figure Inclusion
103 </td></tr></table></div></body></html>