]> pere.pagekite.me Git - homepage.git/blob - blog/data/2015-07-16-dblatex-endnotes.txt
Generated.
[homepage.git] / blog / data / 2015-07-16-dblatex-endnotes.txt
1 Title: Typesetting DocBook footnotes as endnotes with dblatex
2 Tags: english, docbook, freeculture
3 Date: 2015-07-16 18:10
4
5 <p>I'm still working on the Norwegian version of the
6 <a href="http://free-culture.cc/">Free Culture book by Lawrence
7 Lessig</a>, and is now working on the final typesetting and layout.
8 One of the features I want to get the structure similar to the
9 original book is to typeset the footnotes as endnotes in the notes
10 chapter. Based on the
11 <a href="https://bugs.debian.org/685063">feedback from the Debian
12 maintainer and the dblatex developer</a>, I came up with this recipe I
13 would like to share with you. The proposal was to create a new LaTeX
14 class file and add the LaTeX code there, but this is not always
15 practical, when I want to be able to replace the class using a make
16 file variable. So my proposal misuses the latex.begindocument XSL
17 parameter value, to get a small fragment into the correct location in
18 the generated LaTeX File.</p>
19
20 <p>First, decide where in the DocBook document to place the endnotes,
21 and add this text there:</p>
22
23 <pre>
24 &lt;?latex \theendnotes ?&gt;
25 </pre>
26
27 <p>Next, create a xsl stylesheet file dblatex-endnotes.xsl to add the
28 code needed to add the endnote instructions in the preamble of the
29 generated LaTeX document, with content like this:</p>
30
31 <pre>
32 &lt;?xml version='1.0'?&gt;
33 &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'&gt;
34 &lt;xsl:param name="latex.begindocument"&gt;
35 &lt;xsl:text&gt;
36 \usepackage{endnotes}
37 \let\footnote=\endnote
38 \def\enoteheading{\mbox{}\par\vskip-\baselineskip }
39 \begin{document}
40 &lt;/xsl:text&gt;
41 &lt;/xsl:param&gt;
42 &lt;/xsl:stylesheet&gt;
43 </pre>
44
45 <p>Finally, load this xsl file when running dblatex, for example like
46 this:</p>
47
48 <pre>
49 dblatex --xsl-user=dblatex-endnotes.xsl freeculture.nb.xml
50 </pre>
51
52 <p>The end result can be seen on github, where
53 <a href="https://github.com/petterreinholdtsen/free-culture-lessig">my
54 book project</a> is located.</p>