From 06ae7bf0c16c0b658eb6d3788c483618539fa67f Mon Sep 17 00:00:00 2001
From: Petter Reinholdtsen <pere@hungry.com>
Date: Thu, 16 Jul 2015 23:24:24 +0200
Subject: [PATCH] Adjust dblatex chapter numbering to avoid one-off numbers.

---
 data/pdf.xsl |  8 ++++++--
 myclass.cls  | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 2 deletions(-)
 create mode 100644 myclass.cls

diff --git a/data/pdf.xsl b/data/pdf.xsl
index 41e1881..c113541 100644
--- a/data/pdf.xsl
+++ b/data/pdf.xsl
@@ -8,8 +8,12 @@
 <!-- Put the dblatex logo -->
 <!-- xsl:param name="doc.publisher.show">1</xsl:param -->
 
-<!-- List the examples and equations too, no tables -->
-<xsl:param name="doc.lot.show">figure,example</xsl:param>
+<!-- List the examples and equations too, no tables and figures -->
+<xsl:param name="doc.lot.show">example</xsl:param>
+
+<!-- Avoid incorrect chapter numbers -->
+<xsl:param name="doc.section.depth">-2</xsl:param>
+<xsl:param name="latex.class.book">myclass</xsl:param>
 
 <xsl:param name="imagedata.default.scale">maxwidth=15.5cm,maxheight=12cm</xsl:param>
 <xsl:param name="draft.mode">yes</xsl:param>
diff --git a/myclass.cls b/myclass.cls
new file mode 100644
index 0000000..ba9f905
--- /dev/null
+++ b/myclass.cls
@@ -0,0 +1,39 @@
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{myclass}[]
+
+%% Just use the original class and pass the options
+\LoadClassWithOptions{scrreprt}
+% report, book, memoir, scrreprt or scrbook ?
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Based on ideas from https://bugs.debian.org/684772
+\usepackage{titlesec}
+%
+% Useless with unnumbered sections (e.g. use of \setcounter{secnumdepth}{0})
+%
+%
+\newcommand\makeletterof[1]{%
+\ifthenelse{\equal{#1}{1}}{EN}{%
+\ifthenelse{\equal{#1}{2}}{TO}{%
+\ifthenelse{\equal{#1}{3}}{TRE}{%
+\ifthenelse{\equal{#1}{4}}{FIRE}{%
+\ifthenelse{\equal{#1}{5}}{FEM}{%
+\ifthenelse{\equal{#1}{6}}{SEKS}{%
+\ifthenelse{\equal{#1}{7}}{SJU}{%
+\ifthenelse{\equal{#1}{8}}{ÃTTE}{%
+\ifthenelse{\equal{#1}{9}}{NI}{%
+\ifthenelse{\equal{#1}{10}}{TI}{%
+\ifthenelse{\equal{#1}{11}}{ELLEVE}{%
+\ifthenelse{\equal{#1}{12}}{TOLV}{%
+#1}}}}}}}}}}}}}
+
+%% Redefines the headings
+\titleformat{\chapter}[block]
+{\filcenter\huge}{\filcenter\MakeUppercase{\chaptertitlename} \makeletterof{\thechapter}}{20pt}{\Huge}
+
+\titleformat{\section}
+{\filcenter\Large\bfseries}{\thesection}{1em}{}
+
+\titleformat{\subsection}
+{\filcenter\large\bfseries}{\thesubsection}{1em}{}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-- 
2.51.0

