Remove textellipsis because it causes an error when used within chapter names (as...
[project-aon.git] / common / xsl / latex.xsl
1 <?xml version="1.0"?>
2 <!DOCTYPE xsl:transform [
3  <!ENTITY % latex.characters SYSTEM "ltexchar.mod">
4  %latex.characters;
5 ]>
6
7 <xsl:transform version="1.0"
8   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9   xmlns:exslt="http://exslt.org/common"
10   xmlns:date="http://exslt.org/dates-and-times" >
11
12 <xsl:import href="../../common/xsl/org.projectaon.format-date-localized.template.xsl" />
13
14 <xsl:output method="text" encoding="ISO-8859-1" />
15
16 <xsl:strip-space elements="gamebook meta rights section data ol ul dl li dd footnotes footnote illustration instance table tr th td blockquote poetry" />
17 <xsl:preserve-space elements="p choice description" />
18
19 <!--
20
21 $Log$
22 Revision 1.3  2006/04/04 22:02:14  cvsuser
23 Fix two bugs (one } too much and a missing line break)
24
25 Revision 1.2  2005/04/09 19:51:50  angantyr
26 Added handling of open-ended quotes.
27
28 Revision 1.1  2005/01/30 01:32:52  jonathan.blake
29 Initial freepository revision of XML support documents.
30
31 Revision 1.3  2002/10/30 06:33:22  jblake
32 Added capability to filter which illustrators' work is included in the output.
33
34 Revision 1.2  2002/10/20 06:29:58  jblake
35 Added support for CLOSE COMBAT SKILL from the Freeway Warrior books.
36
37 Revision 1.1  2002/10/15 23:30:23  jblake
38 Initial revision
39
40 -->
41
42 <!--
43
44 To Implement:
45
46 The implementation of tables is incomplete and kludgy.
47
48 -->
49
50
51 <!-- ====================== parameters ========================== -->
52
53 <xsl:param name="title-color"><xsl:text>0.0,0.0,0.0</xsl:text></xsl:param>
54 <xsl:param name="use-illustrators" />
55 <xsl:param name="language"><xsl:text>en</xsl:text></xsl:param>
56 <xsl:param name="papersize"><xsl:text>a5paper</xsl:text></xsl:param>
57 <xsl:param name="pagelayout"><xsl:text>twoside</xsl:text></xsl:param>
58 <xsl:param name="usesouvenirfont"><xsl:text>yes</xsl:text></xsl:param>
59 <xsl:param name="usexelatex"><xsl:text>yes</xsl:text></xsl:param>
60
61 <!--
62   The size of the original paperback books is about 178 mm x 110 mm,
63   the scans of the covers are 690 x 425, i.e. the aspect ratio is about
64   1:1.6235.
65   Scaling the page size to A5 (210 mm x 148.5 mm) on gets about
66   210 mm x 129.35 mm -> the binding correction should be set to 19.15 mm.
67   Scaling the page size to letter/2 (215.9 mm x 139.7 mm) on gets about
68   215.9 mm x 133 mm -> the binding correction should be set to 6.7 mm.
69 -->
70
71 <!-- ======================= includes =========================== -->
72
73
74 <!-- ================= internationalization ===================== -->
75
76 <xsl:variable name="i18n" select="document( '../../common/l10n/i18n-pdf.xml' )/messages/message[@lang=$language]"/>
77
78 <!-- ======================= variables ========================== -->
79
80 <xsl:variable name="newline">
81 <xsl:text>
82 </xsl:text>
83 </xsl:variable>
84
85 <xsl:variable name="newparagraph">
86  <xsl:value-of select="$newline" />
87  <xsl:value-of select="$newline" />
88 </xsl:variable>
89
90   <xsl:variable name="resultBoxWidth">15</xsl:variable><!-- 45pt -->
91   <xsl:variable name="resultBoxHeight">15</xsl:variable><!-- 40pt -->
92   <xsl:variable name="rnColWidth">6</xsl:variable><!-- 20pt -->
93   <xsl:variable name="combatRatioBoxHeight">9</xsl:variable><!-- 30pt -->
94   <xsl:variable name="legendHeight">4.5</xsl:variable><!-- 15pt -->
95   <xsl:variable name="legendSep">3</xsl:variable><!-- 10pt -->
96   <xsl:variable name="topLabelSep">3</xsl:variable><!-- 10pt -->
97   <xsl:variable name="topLabelHeight">6</xsl:variable><!-- 20pt -->
98   <xsl:variable name="sideLabelWidth">6</xsl:variable><!-- 20pt -->
99
100   <!-- calculate a few positions -->
101   <xsl:variable name="randomNumberBoxWidth" select="$rnColWidth" />
102   <xsl:variable name="randomNumberBoxHeight" select="$resultBoxHeight" />
103
104   <xsl:variable name="combatRatioBoxWidth" select="$resultBoxWidth" />
105
106   <!-- Random Number Table -->
107   <xsl:variable name="RNTWidthOfBox">12</xsl:variable>
108   <xsl:variable name="RNTHeightOfBox">15.5</xsl:variable>
109   <!-- offsetX = \textwidth / 2 - 5 * widthOfBox = 116.2 / 2 - 60 = - 1.9 -->
110   <xsl:variable name="RNTOffsetX">-1.9</xsl:variable>
111   <xsl:variable name="RNTOffsetY">0</xsl:variable>
112
113 <!-- ======================== Templates ========================= -->
114
115 <!-- ================= hierarchical sections ==================== -->
116
117 <xsl:template match="meta" />
118
119 <!-- ::::::::::::::::::: top-level section :::::::::::::::::::::: -->
120
121 <xsl:template match="/gamebook/section[@id='title']">
122
123 <xsl:text>\documentclass[</xsl:text><xsl:value-of select="$papersize" /><xsl:text>,12pt,</xsl:text><xsl:value-of select="$pagelayout" /><xsl:text>,BCOR10mm,DIVcalc,headinclude,cleardoubleempty]{scrbook}
124 </xsl:text>
125
126 <xsl:choose>
127     <xsl:when test="$usexelatex='yes'">
128 <xsl:text>
129 % xltxtra loads fontspec
130 \usepackage{xltxtra}
131 </xsl:text>
132   </xsl:when>
133    <xsl:otherwise>
134 <xsl:text>
135 %% TrueType font %%
136 \usepackage[T1]{fontenc}
137 </xsl:text>
138    </xsl:otherwise>
139  </xsl:choose>
140
141 <xsl:choose>
142 <xsl:when test="$usesouvenirfont='yes'">
143   <xsl:choose>
144     <xsl:when test="$usexelatex='yes'">
145      <xsl:text>\setmainfont[Ligatures=TeX]{ITC Souvenir Std Light}</xsl:text>
146      <xsl:value-of select="$newline" />
147   </xsl:when>
148    <xsl:otherwise>
149      <xsl:text>\usepackage{souvenir}</xsl:text>
150      <xsl:value-of select="$newline" />
151    </xsl:otherwise>
152  </xsl:choose>
153 </xsl:when>
154 </xsl:choose>
155 <xsl:text>
156
157 \typearea[current]{calc}
158
159 % list only chapters in the ToC
160 \setcounter{tocdepth}{1}
161 </xsl:text>
162
163   <xsl:choose>
164     <xsl:when test="$usexelatex='yes'">
165      <xsl:text>% Graphicx package is loaded by xltxtra</xsl:text>
166      <xsl:value-of select="$newline" />
167   </xsl:when>
168    <xsl:otherwise>
169      <xsl:text>\usepackage[pdftex]{graphicx}</xsl:text>
170      <xsl:value-of select="$newline" />
171    </xsl:otherwise>
172  </xsl:choose>
173
174 <xsl:text>
175 % The eso-pic package helps put objects on the background of pages, without
176 % respecting margins. This is what we use for the bearer scroll
177 \usepackage{eso-pic}
178
179 \usepackage{array}
180 % needed for using \centering in tabular environment
181 \newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp}
182
183 \usepackage{ifthen}
184 \usepackage{calc}
185
186
187 </xsl:text>
188
189 <!-- Review in ../l10n/i18n-pdf.xml but for the meantime define like this -->
190   <xsl:choose>
191     <xsl:when test="$usexelatex='yes'">
192      <xsl:text>
193 % Polyglossia replaces Babel:
194 \usepackage{polyglossia}
195 \setdefaultlanguage{spanish}
196      </xsl:text>
197   </xsl:when>
198    <xsl:otherwise>
199      <xsl:value-of select="$i18n[@src='include babel package']"/>
200    </xsl:otherwise>
201  </xsl:choose>
202
203 <xsl:text>
204 %% color info %%
205 \usepackage{color}
206 \definecolor{titlecolor}{rgb}{</xsl:text><xsl:value-of select="$title-color" /><xsl:text>}
207 \definecolor{lightgray}{gray}{0.75}
208
209 %% headers and footers %%
210 \usepackage{fancyhdr}
211
212 \renewcommand{\chaptermark}[1]{}
213 \renewcommand{\sectionmark}[1]{}
214 \fancyhf{}
215
216 \ifthenelse{\boolean{@twoside}}%
217 { %% Two-sided %%
218   \fancyhead[CO]{\iffloatpage{}{</xsl:text><xsl:value-of select="/gamebook/meta/creator[@class='short']" /><xsl:text>}}
219   \fancyhead[CE]{\iffloatpage{}{\bfseries </xsl:text><xsl:value-of select="/gamebook/meta/title[1]" /><xsl:text>}}
220   \fancyhead[LO,RE]{\iffloatpage{}{\thepage}}%
221 }
222 { %% One-sided %%
223   \fancyhead[C]{\iffloatpage{}{\bfseries{</xsl:text><xsl:value-of select="/gamebook/meta/title[1]" /><xsl:text>:} \normalfont{</xsl:text><xsl:value-of select="/gamebook/meta/creator[@class='short']" /><xsl:text>}}}
224   \fancyhead[R]{\iffloatpage{}{\thepage}}}
225   \renewcommand{\headrulewidth}{\iffloatpage{0pt}{0.4pt}%
226 }
227
228 \fancypagestyle{plain}{
229  \fancyhf{}
230  \renewcommand{\headrulewidth}{0pt}
231 }
232
233 \fancypagestyle{empty}{
234  \fancyhf{}
235  \renewcommand{\headrulewidth}{0pt}
236 }
237
238 % support for PDF metadata not supported by hyperref package
239 \usepackage{hyperxmp}
240 %% hyper-references %%
241 </xsl:text>
242 <xsl:choose>
243     <xsl:when test="$usexelatex='yes'">
244      <xsl:text>\usepackage[xetex,colorlinks=false,bookmarks=true]{hyperref}</xsl:text>
245      <xsl:value-of select="$newline" />
246   </xsl:when>
247    <xsl:otherwise>
248      <xsl:text>\usepackage[pdftex,colorlinks=false,pdfborder=0 0 0,bookmarks=true]{hyperref}</xsl:text>
249      <xsl:value-of select="$newline" />
250    </xsl:otherwise>
251  </xsl:choose>
252 <xsl:text>
253 \hypersetup{
254   pdftitle={</xsl:text><xsl:value-of select="/gamebook/meta/title[1]" /><xsl:text>},
255   pdfauthor={</xsl:text>
256     <xsl:apply-templates select="/gamebook/meta/rights[@class='copyrights']" />
257     <xsl:value-of select="$i18n[@src=' Published by ']"/>
258     <xsl:apply-templates select="/gamebook/meta/publisher[1]" />
259     <xsl:text>.},
260   pdfcopyright={</xsl:text>
261     <xsl:apply-templates select="/gamebook/meta/rights[@class='copyrights']" />
262     <xsl:value-of select="$i18n[@src=' Published by ']"/>
263     <xsl:apply-templates select="/gamebook/meta/publisher[1]" />
264     <xsl:text>.},
265   pdflicenseurl={http://www.projectaon.org/en/Main/License},
266 %% We need a meta-variable for the series in order to include it here:
267   pdfsubject={Lone Wolf Series},
268   pdfkeywords={lone wolf, project aon}
269 }
270
271 % \raggedbottom
272
273 \usepackage{multicol}
274
275 % provides environments for changing the spacing
276 \usepackage{setspace}
277
278 % package ellipsis provides an ellipsis with even spacing before and after the ellipsis
279 \usepackage{ellipsis}
280
281 %% new environments %%
282 \newenvironment{aonchoice}{\begin{list}{}{\setlength{\topsep}{0pt}} \item}{\end{list}}
283 \newenvironment{aoncombat}{\begin{list}{}{\setlength{\topsep}{0pt}} \item}{\end{list}}
284 \newenvironment{aonitemize}{\begin{list}{}{\setlength{\topsep}{0pt} \setlength{\parsep}{0pt} \setlength{\itemsep}{0pt}}}{\end{list}}
285 \newenvironment{aonordereditemize}{\begin{list}{\arabic{aoncounter}.}{\usecounter{aoncounter} \setlength{\topsep}{0pt} \setlength{\parsep}{0pt} \setlength{\itemsep}{0pt}}}{\end{list}}
286 \newcounter{aoncounter}
287
288 %% new commands %%
289 \newcommand{\lightgraybox}[2]{{\fboxsep0pt%
290   \colorbox{lightgray}{\makebox(#1,#2){}}}}
291
292 % set the general style for all sectioning titles
293 \setkomafont{sectioning}{\normalcolor\bfseries}
294
295 % set the color of the title
296 \addtokomafont{title}{\color{titlecolor}}
297
298 % set layout of footnotes
299 \deffootnote{1em}{1em}{\textsuperscript{\thefootnotemark}}
300
301 % define the height of the large illustrations
302 \newlength{\figureheight}
303 \setlength{\figureheight}{\textheight+\headsep+\headheight/2}
304
305 % mark overfull lines; comment out to disable the marker
306 %\overfullrule=30pt
307
308 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
309 \begin{document}
310
311 \title{</xsl:text><xsl:value-of select="/gamebook/meta/title[1]" /><xsl:text>}
312 \author{</xsl:text><xsl:apply-templates select="/gamebook/meta/creator[@class='medium']/line" /><xsl:text>}
313 \date{}
314
315 </xsl:text>
316
317 <!--
318 \begin{titlepage}
319
320  \vspace*{\stretch{0.7}}
321  \begin{center}
322   \Huge{\textcolor{titlecolor}{\textbf{</xsl:text><xsl:value-of select="/gamebook/meta/title[1]" /><xsl:text>}}} \vspace{-0.8em}\\
323
324   \vspace*{\stretch{1}}
325   \normalsize{</xsl:text><xsl:apply-templates select="/gamebook/meta/creator[@class='medium']" /><xsl:text>}
326  \end{center}
327  \vspace*{\stretch{1.3}}
328
329  \pagestyle{empty}
330
331  \newpage
332
333  \vspace*{\stretch{1}}
334 -->
335
336   <xsl:text>\uppertitleback{</xsl:text>
337     <xsl:apply-templates select="/gamebook/meta/description[@class='blurb']" />
338   <xsl:text>}</xsl:text>
339
340   <xsl:value-of select="$newparagraph" />
341
342   <xsl:text>\lowertitleback{</xsl:text>
343     <xsl:value-of select="$newline" />
344     <xsl:apply-templates select="/gamebook/meta/rights[@class='license-notification']/p/line" />
345
346     <xsl:value-of select="$newline" />
347     <xsl:text>~\\</xsl:text>
348     <xsl:value-of select="$newline" />
349
350     <xsl:value-of select="$i18n[@src='Publication Date: ']"/>
351
352     <xsl:variable name="date-string">
353       <xsl:value-of select="/gamebook/meta/date[@class='publication']/year" />
354       <xsl:text>-</xsl:text>
355       <xsl:if test="/gamebook/meta/date[@class='publication']/month &lt; 10">
356         <xsl:text>0</xsl:text>
357       </xsl:if>
358       <xsl:value-of select="/gamebook/meta/date[@class='publication']/month" />
359       <xsl:text>-</xsl:text>
360       <xsl:if test="/gamebook/meta/date[@class='publication']/day &lt; 10">
361         <xsl:text>0</xsl:text>
362       </xsl:if>
363       <xsl:value-of select="/gamebook/meta/date[@class='publication']/day" />
364     </xsl:variable>
365
366     <xsl:call-template name="date:format-date-localized">
367       <xsl:with-param name="date-time" select="$date-string" />
368       <xsl:with-param name="pattern" select="$i18n[@src='Format of publication date']" />
369     </xsl:call-template>
370
371     <xsl:text>\\</xsl:text>
372     <xsl:value-of select="$newparagraph" />
373
374     <xsl:apply-templates select="/gamebook/meta/description[@class='publication']" />
375     <xsl:text>~\\</xsl:text>
376     <xsl:value-of select="$newline" />
377
378     <xsl:value-of select="$i18n[@src='This PDF was typeset with \LaTeX.']"/>
379     <xsl:value-of select="$newline" />
380   <xsl:text>}</xsl:text>
381
382   <xsl:value-of select="$newparagraph" />
383
384   <xsl:text>\dedication{</xsl:text>
385     <xsl:apply-templates select="/gamebook/section/data/section/data/p[@class='dedication']" />
386   <xsl:text>}</xsl:text>
387
388   <xsl:value-of select="$newparagraph" />
389
390   <xsl:text>\maketitle</xsl:text>
391
392   <xsl:value-of select="$newparagraph" />
393
394   <xsl:text>
395 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
396 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Bearer Scroll  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
397 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
398
399 % The following definition is use to put the bearer scroll over the margin.
400 % Measurement is based on the English bearer scrolls (420 x 597).
401 % To prevent problems with other scrolls, the scrolls is scaled to 
402 % this size
403 % -----------------------------------------------------------------------
404 % \thispagestyle{empty}
405 % \newlength{\bearersaveunitlength}
406 % \setlength{\bearersaveunitlength}{\unitlength}
407 % \setlength{\unitlength}{1mm}
408 %\begin{picture}(0,0)
409 %  \put(-22,-180){\includegraphics[height=597pt,keepaspectratio]{bearer.pdf}}
410 % \end{picture}%
411 % \setlength{\unitlength}{\bearersaveunitlength}
412 % \cleardoublepage
413 % -----------------------------------------------------------------------
414 %
415 % Alternate definition -  [TODO] needs to be tested in English PDF builds
416 %
417 % In order to not depend on the *real* size of the PDF
418 % it is be best to have the size be strictly defined.
419 % This section uses the eso-pic package to 
420 % set the bearer scroll as a background picture, centered and 
421 % scaled to fit in the page.
422 \AddToShipoutPicture*{
423     \put(0,0){
424         \parbox[b][\paperheight]{\paperwidth}{
425             \vfill
426             \centering
427             \includegraphics[height=\paperheight,keepaspectratio]{bearer.pdf}
428             \vfill
429          }
430     }
431 }
432 \clearpage\mbox{}\clearpage
433 \ClearShipoutPicture
434 \cleardoublepage
435
436
437 \tableofcontents
438
439 \pagestyle{fancy}
440
441 % we do not need the special properties of the frontmatter, e.g.
442 % separate page numbering with Roman numbers; so we omit the command
443 % \frontmatter
444
445 </xsl:text>
446
447 <xsl:text>\addchap{</xsl:text>
448 <xsl:value-of select="$i18n[@src='About the Author and Illustrator']"/>
449 <xsl:text>}</xsl:text>
450
451 <xsl:apply-templates select="/gamebook/meta/creator[@class='long']" />
452
453 <xsl:apply-templates select="data/section[@class='frontmatter']" />
454
455 <xsl:text>
456
457 % we do not use \frontmatter; so we omit the command \mainmatter as well
458
459 </xsl:text>
460
461 <xsl:if test="data/section[@class='mainmatter']">
462  <xsl:apply-templates select="data/section[@class='mainmatter']" />
463 </xsl:if>
464
465 <xsl:if test="data/section[@class='numbered']">
466  <xsl:apply-templates select="data/section[@class='numbered']" />
467 </xsl:if>
468
469 <xsl:text>
470
471 \backmatter
472
473 \ifthenelse{\boolean{@twoside}}%
474 { %% Two-sided %%
475   \fancyhead[RO,LE]{}
476 }
477 { %% One-sided %%
478   \fancyhead[R]{}
479 }
480
481 \setcounter{topnumber}{6}
482 \renewcommand{\topfraction}{1}
483 \renewcommand{\textfraction}{0}
484 \setlength{\floatsep}{10pt}
485
486 </xsl:text>
487
488 <!-- insert the backmatter sections in the following order -->
489
490 <xsl:apply-templates select="data/section[@class='backmatter' and @id='action']" />
491 <xsl:apply-templates select="data/section[@class='backmatter' and @id='crsumary']" />
492 <xsl:apply-templates select="data/section[@class='backmatter' and @id='crtable']" />
493 <xsl:apply-templates select="data/section[@class='backmatter' and @id='random']" />
494 <xsl:apply-templates select="data/section[@class='backmatter' and @id='errata']" />
495 <xsl:apply-templates select="data/section[@class='backmatter' and @id='license']" />
496 <xsl:apply-templates select="data/section[@class='backmatter' and @id='map']" />
497
498 <xsl:text>
499
500 \end{document}
501 </xsl:text>
502
503 </xsl:template>
504
505 <xsl:template match="/gamebook/section[@id='toc']" />
506
507 <xsl:template match="section" />
508
509 <!-- ::::::::::: second-level frontmatter sections :::::::::::::: -->
510
511 <xsl:template match="/gamebook/section/data/section[@class='frontmatter']">
512
513  <xsl:value-of select="$newline" />
514
515  <xsl:text>\addchap{</xsl:text>
516  <xsl:apply-templates select="meta/title[1]" />
517  <xsl:text>}</xsl:text>
518  <xsl:text>\hypertarget{</xsl:text>
519  <xsl:value-of select="@id" />
520  <xsl:text>}{}</xsl:text>
521  <xsl:value-of select="$newparagraph" />
522
523  <xsl:apply-templates />
524
525 </xsl:template>
526
527
528 <!-- override the above for the dedication section -->
529 <!-- do nothing; the dedication is explicitly handled by <xsl:template match="/gamebook/section[@id='title']"> -->
530 <xsl:template match="/gamebook/section/data/section[@class='frontmatter' and @id='dedicate']" />
531
532
533 <!-- :::::::::::: third-level front matter sections ::::::::::::: -->
534
535 <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter']">
536
537  <xsl:value-of select="$newline" />
538
539  <xsl:text>\addsec{</xsl:text>
540  <xsl:apply-templates select="meta/title[1]" />
541  <xsl:text>}</xsl:text>
542  <xsl:text>\hypertarget{</xsl:text>
543  <xsl:value-of select="@id" />
544  <xsl:text>}{}</xsl:text>
545  <xsl:value-of select="$newparagraph" />
546
547  <xsl:apply-templates />
548
549 </xsl:template>
550
551
552 <!-- override the above for the Credits section of the Acknowledgements chapter -->
553 <!-- do not add the title of the Credits section -->
554 <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter' and @id='credits']">
555   <xsl:apply-templates />
556 </xsl:template>
557
558
559 <xsl:template match="/gamebook/section/data/section/data/section[@class='frontmatter-separate']">
560
561  <xsl:value-of select="$newline" />
562
563  <!--
564  <xsl:text>\newpage</xsl:text><xsl:value-of select="$newline" />
565  -->
566
567  <xsl:text>\addsec{</xsl:text>
568  <xsl:apply-templates select="meta/title[1]" />
569  <xsl:text>}</xsl:text>
570  <xsl:text>\hypertarget{</xsl:text>
571  <xsl:value-of select="@id" />
572  <xsl:text>}{}</xsl:text>
573  <xsl:value-of select="$newparagraph" />
574
575  <xsl:apply-templates />
576
577 </xsl:template>
578
579 <!-- :::::::::::: fourth-level front matter sections :::::::::::: -->
580
581 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='frontmatter']">
582
583  <xsl:value-of select="$newline" />
584
585  <xsl:text>\subsection*{</xsl:text>
586  <xsl:apply-templates select="meta/title[1]" />
587  <xsl:text>}</xsl:text>
588  <xsl:text>\hypertarget{</xsl:text>
589  <xsl:value-of select="@id" />
590  <xsl:text>}{}</xsl:text>
591  <xsl:value-of select="$newparagraph" />
592
593  <xsl:apply-templates />
594
595 </xsl:template>
596
597 <!-- ::::::::::::: fifth-level front matter sections :::::::::::: -->
598
599 <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='frontmatter']">
600  <xsl:text>{\large \hypertarget{</xsl:text>
601   <xsl:value-of select="@id" />
602  <xsl:text>}{</xsl:text>
603  <xsl:apply-templates select="meta/title[1]" />
604  <xsl:text>}}</xsl:text>
605  <xsl:value-of select="$newparagraph" />
606
607  <xsl:apply-templates />
608 </xsl:template>
609
610 <!-- ::::::::::: second-level main matter sections :::::::::::::: -->
611
612 <xsl:template match="/gamebook/section/data/section[@class='mainmatter']">
613  <xsl:text>\clearpage{\pagestyle{empty}\cleardoublepage}</xsl:text>
614  <xsl:value-of select="$newparagraph" />
615
616  <xsl:text>{\huge \hypertarget{</xsl:text>
617   <xsl:value-of select="@id" />
618  <xsl:text>}{</xsl:text>
619  <xsl:apply-templates select="meta/title[1]" />
620  <xsl:text>}}</xsl:text>
621  <xsl:value-of select="$newline" />
622  <xsl:text>\addcontentsline{toc}{section}{\protect\numberline{}{</xsl:text>
623   <xsl:apply-templates select="meta/title[1]" />
624  <xsl:text>}}</xsl:text>
625  <xsl:value-of select="$newparagraph" />
626
627  <xsl:apply-templates />
628
629 </xsl:template>
630
631 <!-- :::::::::::: third-level main matter sections ::::::::::::: -->
632
633 <xsl:template match="/gamebook/section/data/section/data/section[@class='mainmatter'] | /gamebook/section/data/section/data/section[@class='mainmatter-separate']">
634
635  <xsl:text>\newpage</xsl:text><xsl:value-of select="$newline" />
636  <xsl:text>{\LARGE \hypertarget{</xsl:text>
637   <xsl:value-of select="@id" />
638  <xsl:text>}{</xsl:text>
639  <xsl:apply-templates select="meta/title[1]" />
640  <xsl:text>}}</xsl:text>
641  <xsl:value-of select="$newline" />
642  <xsl:text>\addcontentsline{toc}{subsection}{\protect\numberline{}{</xsl:text>
643   <xsl:apply-templates select="meta/title[1]" />
644  <xsl:text>}}</xsl:text>
645  <xsl:value-of select="$newparagraph" />
646
647  <xsl:apply-templates />
648 </xsl:template>
649
650 <!-- :::::::::::: fourth-level main matter sections :::::::::::: -->
651
652 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='mainmatter'] | /gamebook/section/data/section/data/section/data/section[@class='mainmatter-separate']">
653  <xsl:text>{\Large \hypertarget{</xsl:text>
654   <xsl:value-of select="@id" />
655  <xsl:text>}{</xsl:text>
656  <xsl:apply-templates select="meta/title[1]" />
657  <xsl:text>}}</xsl:text>
658  <xsl:value-of select="$newparagraph" />
659
660  <xsl:apply-templates />
661 </xsl:template>
662
663 <!-- ::::::::::::: fifth-level main matter sections :::::::::::: -->
664
665 <xsl:template match="/gamebook/section/data/section/data/section/data/section/data/section[@class='mainmatter']">
666  <xsl:text>{\large \hypertarget{</xsl:text>
667   <xsl:value-of select="@id" />
668  <xsl:text>}{</xsl:text>
669  <xsl:apply-templates select="meta/title[1]" />
670  <xsl:text>}}</xsl:text>
671  <xsl:value-of select="$newparagraph" />
672
673  <xsl:apply-templates />
674 </xsl:template>
675
676 <!-- :::::::::::: third-level glossary sections ::::::::::::: -->
677 <!-- Glossary sections should be contained in a second level section. -->
678
679 <xsl:template match="/gamebook/section/data/section/data/section[@class='glossary'] | /gamebook/section/data/section/data/section[@class='glossary-separate']">
680
681  <xsl:text>\newpage</xsl:text><xsl:value-of select="$newline" />
682  <xsl:text>{\LARGE \hypertarget{</xsl:text>
683   <xsl:value-of select="@id" />
684  <xsl:text>}{</xsl:text>
685  <xsl:apply-templates select="meta/title[1]" />
686  <xsl:text>}}</xsl:text>
687  <xsl:value-of select="$newparagraph" />
688
689  <xsl:apply-templates />
690 </xsl:template>
691
692 <!-- :::::::::::::::::: numbered sections ::::::::::::::::::::::: -->
693
694 <xsl:template match="/gamebook/section/data/section[@class='numbered']">
695  <xsl:text>\cleardoublepage</xsl:text>
696  <xsl:value-of select="$newparagraph" />
697
698  <xsl:if test="position() = 1">
699   <xsl:text>\newcommand{\aonmarks}{
700     \ifthenelse{\equal{\leftmark}{\rightmark}}
701       {\rightmark}
702       {\rightmark{} - \leftmark}
703   \ifthenelse{\boolean{@twoside}}%
704    {%% Two-sided %%
705     \fancyhead[RO,LE]{\iffloatpage{}{\large{\bfseries \aonmarks}}}
706     \fancyhead[LO,RE]{\iffloatpage{}{\thepage}}}
707    {%% One-sided %%
708     \fancyhead[R]{\iffloatpage{}{\large{\bfseries \aonmarks}}}
709     \fancyhead[L]{\iffloatpage{}{\thepage}}%
710     }
711    }</xsl:text>
712    <xsl:value-of select="$newparagraph" />
713  </xsl:if>
714
715  <xsl:choose>
716    <xsl:when test="not( self::node()[@id='numbered'] )">
717      <xsl:text>\addchap[</xsl:text>
718        <xsl:apply-templates select="meta/title[1]" />
719      <xsl:text>]{\hfill{}</xsl:text>
720        <xsl:apply-templates select="meta/title[1]" />
721      <xsl:text>\hfill}</xsl:text>
722      <xsl:text>\hypertarget{</xsl:text>
723        <xsl:value-of select="@id" />
724      <xsl:text>}{}</xsl:text>
725    </xsl:when>
726    <xsl:otherwise>
727      <xsl:text>\phantomsection</xsl:text>
728      <xsl:text>\hypertarget{</xsl:text>
729        <xsl:value-of select="@id" />
730      <xsl:text>}{}</xsl:text>
731      <xsl:value-of select="$newline" />
732      <xsl:text>\addcontentsline{toc}{chapter}{\protect{</xsl:text>
733        <xsl:apply-templates select="meta/title[1]" />
734      <xsl:text>}}</xsl:text>
735    </xsl:otherwise>
736  </xsl:choose>
737
738  <xsl:value-of select="$newparagraph" />
739
740  <xsl:apply-templates />
741
742  <xsl:value-of select="$newparagraph" />
743  <xsl:text>\cleardoublepage</xsl:text>
744  <xsl:value-of select="$newparagraph" />
745
746 </xsl:template>
747
748 <xsl:template match="/gamebook/section/data/section[@class='numbered']/data/section[@class='numbered']">
749
750   <xsl:variable name="section-title" select="meta/title[1]" />
751
752   <xsl:value-of select="$newline" />
753
754   <xsl:text>\addsec[</xsl:text>
755   <xsl:value-of select="$i18n[@src='Section']" />
756   <xsl:text> </xsl:text>
757   <xsl:value-of select="$section-title" />
758   <xsl:text>]{\hspace*{\fill}</xsl:text>
759   <xsl:text>\hypertarget{</xsl:text>
760   <xsl:value-of select="@id" />
761   <xsl:text>}{}</xsl:text>
762   <xsl:value-of select="$section-title" />
763   <xsl:text>\hspace*{\fill}}</xsl:text>
764   <xsl:value-of select="$newparagraph" />
765
766   <xsl:for-each select="data/illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]">
767     <xsl:text>\hspace*{\fill} \mbox{\itshape \hyperlink{ill</xsl:text>
768     <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="1" />
769     <xsl:text>}{</xsl:text>
770     <xsl:value-of select="$i18n[@src='Illustration']" />
771     <xsl:text>~</xsl:text>
772     <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="I" />
773     <xsl:text>}}\hspace*{\fill}\\*[\parskip]</xsl:text>
774     <xsl:value-of select="$newline" />
775
776     <!-- insert the illustration -->
777     <xsl:text>\begin{figure}[p]</xsl:text>
778     <xsl:value-of select="$newline" />
779     <xsl:text>\centering</xsl:text>
780     <xsl:value-of select="$newline" />
781     <xsl:text>\hypertarget{ill</xsl:text>
782       <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="1" />
783     <xsl:text>}{}</xsl:text>
784     <xsl:value-of select="$newline" />
785     <xsl:text>\raisebox{0cm}[\textheight]{</xsl:text>
786       <xsl:text>\includegraphics[width=\textwidth,height=\figureheight,keepaspectratio]{</xsl:text>
787         <xsl:value-of select="instance[@class='pdf']/@src" />
788       <xsl:text>}</xsl:text>
789     <xsl:text>}%</xsl:text>
790     <xsl:value-of select="$newline" />
791     <xsl:text>\\{\itshape </xsl:text>
792       <xsl:apply-templates select="meta/description" />
793     <xsl:text>}</xsl:text>
794     <xsl:value-of select="$newline" />
795     <xsl:text>\end{figure}</xsl:text>
796     <xsl:value-of select="$newline" />
797   </xsl:for-each>
798
799   <xsl:apply-templates />
800
801 </xsl:template>
802
803 <!-- :::::::::::: second-level backmatter sections :::::::::::::: -->
804
805 <xsl:template match="/gamebook/section/data/section[@class='backmatter']">
806
807  <xsl:value-of select="$newline" />
808
809  <xsl:text>\addchap{</xsl:text>
810  <xsl:apply-templates select="meta/title[1]" />
811  <xsl:text>}</xsl:text>
812  <xsl:text>\hypertarget{</xsl:text>
813  <xsl:value-of select="@id" />
814  <xsl:text>}{}</xsl:text>
815  <xsl:value-of select="$newparagraph" />
816
817  <xsl:apply-templates />
818
819 </xsl:template>
820
821
822 <!-- override the above for the Footnotes section -->
823 <!-- do nothing; we do not want a Footnotes in the PDF -->
824 <xsl:template match="/gamebook/section/data/section[@class='backmatter' and @id='footnotz']" />
825
826 <!-- override the above for the Table of Illustrations section -->
827 <!-- do nothing; we do not want a Table of Illustrations in the PDF -->
828 <xsl:template match="/gamebook/section/data/section[@class='backmatter' and @id='illstrat']" />
829
830 <xsl:template match="/gamebook/section/data/section[@class='backmatter' and ( @id='license' or @id='errata' )]">
831   <xsl:value-of select="$newline" />
832
833   <xsl:text>\addchap{</xsl:text>
834   <xsl:apply-templates select="meta/title[1]" />
835   <xsl:text>}</xsl:text>
836   <xsl:text>\hypertarget{</xsl:text>
837   <xsl:value-of select="@id" />
838   <xsl:text>}{}</xsl:text>
839   <xsl:value-of select="$newparagraph" />
840
841 <xsl:text>
842 \addtokomafont{section}{\scriptsize}
843 \addtokomafont{paragraph}{\tiny}
844 \begin{multicols}{2}
845 \tiny
846 </xsl:text>
847
848   <xsl:apply-templates />
849
850 <xsl:text>
851 \end{multicols}
852 \addtokomafont{section}{\Large}
853 \addtokomafont{paragraph}{\normalsize}
854 </xsl:text>
855
856 </xsl:template>
857
858
859 <!-- ::::::::::::: third-level back matter sections ::::::::::::: -->
860
861 <xsl:template match="/gamebook/section/data/section/data/section[@class='backmatter']">
862
863  <xsl:value-of select="$newline" />
864
865  <xsl:text>\addsec*{</xsl:text>
866  <xsl:apply-templates select="meta/title[1]" />
867  <xsl:text>}</xsl:text>
868  <xsl:text>\hypertarget{</xsl:text>
869  <xsl:value-of select="@id" />
870  <xsl:text>}{}</xsl:text>
871  <xsl:value-of select="$newparagraph" />
872
873  <xsl:apply-templates />
874
875 </xsl:template>
876
877 <!-- ::::::::::::: fourth-level back matter sections ::::::::::::: -->
878
879 <xsl:template match="/gamebook/section/data/section/data/section/data/section[@class='backmatter']">
880
881  <xsl:value-of select="$newline" />
882
883  <xsl:text>\subsection*{</xsl:text>
884  <xsl:apply-templates select="meta/title[1]" />
885  <xsl:text>}</xsl:text>
886  <xsl:text>\hypertarget{</xsl:text>
887  <xsl:value-of select="@id" />
888  <xsl:text>}{}</xsl:text>
889  <xsl:value-of select="$newline" />
890
891  <xsl:value-of select="$newparagraph" />
892
893  <xsl:apply-templates />
894
895 </xsl:template>
896
897
898 <xsl:template match="/gamebook/section/data/section[@id='license']/data/section/data/section[@class='backmatter']">
899   <xsl:value-of select="$newline" />
900
901   <xsl:text>\paragraph*{</xsl:text>
902   <xsl:apply-templates select="meta/title[1]" />
903   <xsl:text>}</xsl:text>
904   <xsl:text>\hypertarget{</xsl:text>
905   <xsl:value-of select="@id" />
906   <xsl:text>}{}</xsl:text>
907   <xsl:value-of select="$newparagraph" />
908
909   <xsl:apply-templates />
910 </xsl:template>
911
912
913 <!-- :::::::::::::::::: dedication template ::::::::::::::::::::: -->
914
915 <xsl:template match="p[@class='dedication']">
916  <xsl:apply-templates />
917 </xsl:template>
918
919 <!-- ::::::::::::::::::::: map template ::::::::::::::::::::::::: -->
920
921 <xsl:template match="/gamebook/section/data/section[@id='map']">
922   <xsl:variable name="map-title" select="meta/title" />
923
924   <xsl:text>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</xsl:text>
925   <xsl:value-of select="$newline" />
926   <xsl:text>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Map  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</xsl:text>
927   <xsl:value-of select="$newline" />
928   <xsl:text>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</xsl:text>
929   <xsl:value-of select="$newparagraph" />
930
931   <xsl:text>\clearpage</xsl:text>
932   <xsl:value-of select="$newline" />
933   <xsl:text>\ifthispageodd{\thispagestyle{empty}~\clearpage}{}</xsl:text>
934   <xsl:value-of select="$newparagraph" />
935
936   <xsl:for-each select="data/illustration[contains( $use-illustrators, concat( ':', meta/creator, ':' ) ) ]">
937     <xsl:variable name="illustration-src" select="instance[@class='pdf']/@src" />
938
939     <xsl:text>\phantomsection\hypertarget{map}{}</xsl:text>
940     <xsl:value-of select="$newline" />
941     <xsl:text>\addcontentsline{toc}{chapter}{\protect{</xsl:text>
942       <xsl:value-of select="$map-title" />
943     <xsl:text>}}</xsl:text>
944     <xsl:value-of select="$newparagraph" />
945
946     <xsl:text>
947 \thispagestyle{empty}
948 \newlength{\saveunitlength}
949 \setlength{\saveunitlength}{\unitlength}
950 \setlength{\unitlength}{1mm}
951 \ifthenelse{\boolean{@twoside}}%
952 { %% Two-sided %%
953   \begin{picture}(10,10)
954   \put(-0.5,-170){\includegraphics[origin=c,width=28cm,height=20cm,keepaspectratio]{</xsl:text><xsl:value-of select="$illustration-src" /><xsl:text>}}
955   \end{picture}
956   \clearpage
957   \thispagestyle{empty}
958   \begin{picture}(10,10)
959   \put(-151.23,-170){\includegraphics[origin=c,width=28cm,height=20cm,keepaspectratio]{</xsl:text><xsl:value-of select="$illustration-src" /><xsl:text>}}
960   \end{picture}
961 }%
962 { %% One-sided %%
963   \begin{picture}(10,10)
964   \put(-29,-188){\includegraphics[angle=90,origin=c,width=20cm,height=28cm,keepaspectratio]{</xsl:text><xsl:value-of select="$illustration-src" /><xsl:text>}}
965   \end{picture}%
966 }
967 \setlength{\unitlength}{\saveunitlength}</xsl:text>
968     <xsl:value-of select="$newparagraph" />
969   </xsl:for-each>
970 </xsl:template>
971
972 <!-- :::::::::::::::::: action chart template ::::::::::::::::::: -->
973
974 <!-- TODO: This definition only works if the PDF image is exactly
975      one page in its size. This definition could be similar to the
976      bearer scroll above -->
977 <xsl:template match="/gamebook/section/data/section[@id='action']">
978
979   <xsl:text>
980 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
981 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Action Chart  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
982 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
983
984 \clearpage
985 \ifthispageodd{\thispagestyle{empty}~\clearpage}{}
986
987 \newlength{\acsaveunitlength}
988 \setlength{\acsaveunitlength}{\unitlength}
989 \setlength{\unitlength}{1mm}
990
991 \phantomsection\hypertarget{action}{}
992 \addcontentsline{toc}{chapter}{\protect{</xsl:text><xsl:apply-templates select="meta/title[1]" /><xsl:text>}}</xsl:text>
993   <xsl:value-of select="$newparagraph" />
994
995   <xsl:for-each select="data/illustration[contains( $use-illustrators, concat( ':', meta/creator, ':' ) ) ]/instance[@class='pdf']">
996     <xsl:variable name="src" select="@src" />
997     <xsl:variable name="posx" select="@posx" />
998     <xsl:variable name="posy" select="@posy" />
999
1000     <xsl:text>\thispagestyle{empty}</xsl:text>
1001     <xsl:value-of select="$newline" />
1002     <xsl:text>\begin{picture}(0,0)</xsl:text>
1003     <xsl:value-of select="$newline" />
1004     <xsl:text>  \put(</xsl:text><xsl:value-of select="$posx" /><xsl:text>,</xsl:text>
1005       <xsl:value-of select="$posy" /><xsl:text>){\includegraphics{</xsl:text>
1006       <xsl:value-of select="$src" /><xsl:text>}}</xsl:text>
1007     <xsl:value-of select="$newline" />
1008     <xsl:text>\end{picture}%</xsl:text>
1009     <xsl:value-of select="$newline" />
1010     <xsl:text>\clearpage</xsl:text>
1011     <xsl:value-of select="$newparagraph" />
1012   </xsl:for-each>
1013
1014   <xsl:text>\setlength{\unitlength}{\acsaveunitlength}</xsl:text>
1015   <xsl:value-of select="$newparagraph" />
1016
1017 </xsl:template>
1018
1019 <!-- :::::::::::::: combat results table template ::::::::::::::: -->
1020
1021 <xsl:template match="/gamebook/section/data/section[@id='crtable']">
1022
1023  <xsl:text>\clearpage</xsl:text>
1024  <xsl:value-of select="$newline" />
1025  <xsl:text>\ifthispageodd{\thispagestyle{empty}~\clearpage}{}</xsl:text>
1026  <xsl:value-of select="$newparagraph" />
1027
1028  <xsl:text>\phantomsection\hypertarget{crtable}{}</xsl:text>
1029  <xsl:value-of select="$newline" />
1030  <xsl:text>\addcontentsline{toc}{chapter}{\protect{</xsl:text>
1031   <xsl:apply-templates select="meta/title[1]" />
1032  <xsl:text>}}</xsl:text>
1033  <xsl:value-of select="$newparagraph" />
1034
1035   <xsl:choose>
1036     <xsl:when test="data/illustration/instance[@class='text']">
1037       <xsl:text>\thispagestyle{empty}</xsl:text>
1038       <xsl:value-of select="$newparagraph" />
1039       <xsl:call-template name="combat-ratio-table">
1040         <xsl:with-param name="title"><xsl:value-of select="$i18n[@src='Negative Combat Ratio']" /></xsl:with-param>
1041         <xsl:with-param name="startCol" select="1" />
1042         <xsl:with-param name="endCol" select="7" />
1043         <xsl:with-param name="colHeaders">
1044           <th><xsl:text>\shortstack{\footnotesize \textbf{-11} </xsl:text><xsl:value-of select="$i18n[@src='or (as in -11 or less)']" /><xsl:text>\\ \footnotesize </xsl:text><xsl:value-of select="$i18n[@src='less (as in -11 or less)']" /><xsl:text>}</xsl:text></th>
1045           <th><xsl:text>\footnotesize \bfseries -10/-9</xsl:text></th>
1046           <th><xsl:text>\footnotesize \bfseries -8/-7</xsl:text></th>
1047           <th><xsl:text>\footnotesize \bfseries -6/-5</xsl:text></th>
1048           <th><xsl:text>\footnotesize \bfseries -4/-3</xsl:text></th>
1049           <th><xsl:text>\footnotesize \bfseries -2/-1</xsl:text></th>
1050           <th><xsl:text>\footnotesize \bfseries 0</xsl:text></th>
1051         </xsl:with-param>
1052         <xsl:with-param name="showLeftLabel" select="1" />
1053       </xsl:call-template>
1054       <xsl:text>\clearpage</xsl:text>
1055       <xsl:value-of select="$newparagraph" />
1056       <xsl:text>\thispagestyle{empty}</xsl:text>
1057       <xsl:value-of select="$newparagraph" />
1058       <xsl:call-template name="combat-ratio-table">
1059         <xsl:with-param name="title"><xsl:value-of select="$i18n[@src='Positive Combat Ratio']" /></xsl:with-param>
1060         <xsl:with-param name="startCol" select="7" />
1061         <xsl:with-param name="endCol" select="13" />
1062         <xsl:with-param name="colHeaders">
1063           <th><xsl:text>\footnotesize \bfseries 0</xsl:text></th>
1064           <th><xsl:text>\footnotesize \bfseries 1/2</xsl:text></th>
1065           <th><xsl:text>\footnotesize \bfseries 3/4</xsl:text></th>
1066           <th><xsl:text>\footnotesize \bfseries 5/6</xsl:text></th>
1067           <th><xsl:text>\footnotesize \bfseries 7/8</xsl:text></th>
1068           <th><xsl:text>\footnotesize \bfseries 9/10</xsl:text></th>
1069           <th><xsl:text>\shortstack{\footnotesize \textbf{11} </xsl:text><xsl:value-of select="$i18n[@src='or (as in 11 or greater)']" /><xsl:text>\\ \footnotesize </xsl:text><xsl:value-of select="$i18n[@src='greater (as in 11 or greater)']" /><xsl:text>}</xsl:text></th>
1070         </xsl:with-param>
1071         <xsl:with-param name="showRightLabel" select="1" />
1072       </xsl:call-template>
1073     </xsl:when>
1074     <xsl:otherwise>
1075       <xsl:message terminate="yes">
1076         Error: Instance of random number table of class 'text' is missing.
1077       </xsl:message>
1078     </xsl:otherwise>
1079   </xsl:choose>
1080
1081 </xsl:template>
1082
1083 <!-- ::::::::::::::: random number table template ::::::::::::::: -->
1084
1085 <xsl:template match="/gamebook/section/data/section[@id='random']">
1086   <xsl:text>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</xsl:text>
1087   <xsl:value-of select="$newline" />
1088   <xsl:text>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Random Number Table  %%%%%%%%%%%%%%%%%%%%%%%%%%%%</xsl:text>
1089   <xsl:value-of select="$newline" />
1090   <xsl:text>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</xsl:text>
1091   <xsl:value-of select="$newparagraph" />
1092
1093   <xsl:text>\clearpage</xsl:text>
1094   <xsl:value-of select="$newline" />
1095   <xsl:text>\thispagestyle{empty}</xsl:text>
1096   <xsl:value-of select="$newparagraph" />
1097
1098   <xsl:text>\phantomsection\begin{center}\hypertarget{random}{{\usekomafont{disposition}\usekomafont{chapter}</xsl:text>
1099     <xsl:apply-templates select="meta/title[1]" />
1100   <xsl:text>}}\end{center}</xsl:text>
1101   <xsl:value-of select="$newline" />
1102   <xsl:text>\addcontentsline{toc}{chapter}{\protect{</xsl:text>
1103     <xsl:apply-templates select="meta/title[1]" />
1104   <xsl:text>}}</xsl:text>
1105   <xsl:value-of select="$newparagraph" />
1106
1107   <xsl:choose>
1108     <xsl:when test="data/illustration/instance[@class='text']">
1109       <!-- use a dummy value for the width of the picture environment -->
1110       <xsl:text>
1111 \setlength{\unitlength}{1mm}
1112 \noindent\begin{picture}(10,</xsl:text><xsl:value-of select="10 * number($RNTHeightOfBox)" /><xsl:text>)(</xsl:text><xsl:value-of select="-1 * number($RNTOffsetX)" /><xsl:text>,</xsl:text><xsl:value-of select="-1 * number($RNTOffsetY)" /><xsl:text>)
1113   \linethickness{0.25mm}
1114
1115   %% Boxes %%
1116   \multiput(0,0)(0,</xsl:text><xsl:value-of select="2 * number($RNTHeightOfBox)" /><xsl:text>){5}{%
1117     \multiput(0,0)(</xsl:text><xsl:value-of select="2 * number($RNTWidthOfBox)" /><xsl:text>,0){5}{\lightgraybox{</xsl:text><xsl:value-of select="$RNTWidthOfBox" /><xsl:text>}{</xsl:text><xsl:value-of select="$RNTHeightOfBox" /><xsl:text>}}%
1118   }
1119   \multiput(0,</xsl:text><xsl:value-of select="$RNTHeightOfBox" /><xsl:text>)(0,</xsl:text><xsl:value-of select="2 * number($RNTHeightOfBox)" /><xsl:text>){5}{%
1120     \multiput(</xsl:text><xsl:value-of select="$RNTWidthOfBox" /><xsl:text>,0)(</xsl:text><xsl:value-of select="2 * number($RNTWidthOfBox)" /><xsl:text>,0){5}{\lightgraybox{</xsl:text><xsl:value-of select="$RNTWidthOfBox" /><xsl:text>}{</xsl:text><xsl:value-of select="$RNTHeightOfBox" /><xsl:text>}}%
1121   }
1122
1123   %% Lines %%
1124   \multiput(0,0)(0,</xsl:text><xsl:value-of select="$RNTHeightOfBox" /><xsl:text>){11}{%
1125     \line(1,0){</xsl:text><xsl:value-of select="10 * number($RNTWidthOfBox)" /><xsl:text>}%
1126   }
1127   \multiput(0,0)(</xsl:text><xsl:value-of select="$RNTWidthOfBox" /><xsl:text>,0){11}{%
1128     \line(0,1){</xsl:text><xsl:value-of select="10 * number($RNTHeightOfBox)" /><xsl:text>}%
1129   }
1130
1131   %% Numbers %%</xsl:text>
1132       <xsl:value-of select="$newline" />
1133       <xsl:for-each select="data/illustration/instance[@class='text']/table/tr">
1134         <xsl:variable name="row"><xsl:number value="position()" format="1" /></xsl:variable>
1135         <xsl:text>  %% row </xsl:text><xsl:value-of select="$row" /><xsl:text> %%</xsl:text>
1136         <xsl:value-of select="$newline" />
1137         <xsl:for-each select="./td">
1138           <xsl:variable name="col"><xsl:number value="position()" format="1" /></xsl:variable>
1139           <xsl:text>  \put(</xsl:text><xsl:value-of select="number($col) * number($RNTWidthOfBox) - number($RNTWidthOfBox) div 2" /><xsl:text>,</xsl:text><xsl:value-of select="(10 - number($row)) * number($RNTHeightOfBox) + number($RNTHeightOfBox) div 2" /><xsl:text>){\makebox(0,0){\bfseries \Huge </xsl:text><xsl:value-of select="." /><xsl:text>}}</xsl:text>
1140           <xsl:value-of select="$newline" />
1141         </xsl:for-each>
1142       </xsl:for-each>
1143       <xsl:value-of select="$newline" />
1144       <xsl:text>\end{picture}</xsl:text>
1145       <xsl:value-of select="$newline" />
1146       <xsl:text>\setlength{\unitlength}{1pt}</xsl:text>
1147       <xsl:value-of select="$newparagraph" />
1148     </xsl:when>
1149     <xsl:otherwise>
1150       <xsl:message terminate="yes">
1151         Error: Instance of random number table of class 'text' is missing.
1152       </xsl:message>
1153     </xsl:otherwise>
1154   </xsl:choose>
1155
1156 </xsl:template>
1157
1158 <!-- ==================== block elements ======================== -->
1159
1160 <xsl:template match="p">
1161   <xsl:apply-templates />
1162   <xsl:choose>
1163     <xsl:when test="position()!=last()">
1164       <xsl:value-of select="$newparagraph" />
1165     </xsl:when>
1166     <xsl:otherwise>
1167       <xsl:value-of select="$newline" />
1168     </xsl:otherwise>
1169   </xsl:choose>
1170 </xsl:template>
1171
1172 <xsl:template match="ul">
1173  <xsl:text>\begin{aonitemize}</xsl:text><xsl:value-of select="$newline" />
1174  <xsl:apply-templates />
1175  <xsl:text>\end{aonitemize}</xsl:text>
1176  <xsl:value-of select="$newparagraph" />
1177 </xsl:template>
1178
1179 <xsl:template match="ul[@class='unbulleted']">
1180  <xsl:text>\begin{aonitemize}</xsl:text><xsl:value-of select="$newline" />
1181  <xsl:apply-templates />
1182  <xsl:text>\end{aonitemize}</xsl:text>
1183  <xsl:value-of select="$newparagraph" />
1184 </xsl:template>
1185
1186 <xsl:template match="ol">
1187  <xsl:text>\begin{aonordereditemize}</xsl:text><xsl:value-of select="$newline" />
1188  <xsl:apply-templates />
1189  <xsl:text>\end{aonordereditemize}</xsl:text>
1190  <xsl:value-of select="$newparagraph" />
1191 </xsl:template>
1192
1193 <xsl:template match="dl">
1194  <xsl:apply-templates />
1195 </xsl:template>
1196
1197 <xsl:template match="dt">
1198  <xsl:text>\minisec{</xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1199  <xsl:value-of select="$newline" />
1200 </xsl:template>
1201
1202 <xsl:template match="dd">
1203  <xsl:apply-templates />
1204  <xsl:value-of select="$newparagraph" />
1205 </xsl:template>
1206
1207 <xsl:template match="li">
1208  <xsl:text>\item </xsl:text><xsl:apply-templates />
1209  <xsl:value-of select="$newline" />
1210 </xsl:template>
1211
1212 <xsl:template match="table">
1213  <xsl:text>\begin{tabular}{*{</xsl:text>
1214  <xsl:for-each select="tr[1]">
1215    <xsl:value-of select="count(descendant::*[not(child::*)])" />
1216  </xsl:for-each>
1217  <xsl:text>}{l}}</xsl:text>
1218  <xsl:value-of select="$newline" />
1219   <xsl:apply-templates />
1220  <xsl:text>\end{tabular}</xsl:text>
1221  <xsl:value-of select="$newparagraph" />
1222 </xsl:template>
1223
1224 <xsl:template match="tr">
1225  <xsl:apply-templates />
1226  <xsl:text>\\&#10;</xsl:text>
1227 </xsl:template>
1228
1229 <xsl:template match="th">
1230  <xsl:text>\multicolumn{</xsl:text>
1231     <xsl:choose>
1232     <xsl:when test="@colspan!=0"><xsl:value-of select="@colspan" /></xsl:when>
1233     <xsl:otherwise><xsl:text>1</xsl:text></xsl:otherwise>
1234     </xsl:choose>
1235  <xsl:text>}{</xsl:text>
1236  <xsl:choose>
1237   <xsl:when test="@align='left'"><xsl:text>l}{\bfseries </xsl:text></xsl:when>
1238   <xsl:when test="@align='right'"><xsl:text>r}{\bfseries </xsl:text></xsl:when>
1239   <xsl:when test="@align='center'"><xsl:text>c}{\bfseries </xsl:text></xsl:when>
1240   <xsl:otherwise><xsl:text>l}{\bfseries </xsl:text></xsl:otherwise>
1241  </xsl:choose>
1242   <xsl:apply-templates />
1243  <xsl:text>} </xsl:text>
1244  <xsl:if test="position()!=last()"><xsl:text> &amp; </xsl:text></xsl:if>
1245 </xsl:template>
1246
1247 <xsl:template match="td">
1248  <xsl:text>\multicolumn{</xsl:text>
1249     <xsl:choose>
1250     <xsl:when test="@colspan!=0"><xsl:value-of select="@colspan" /></xsl:when>
1251     <xsl:otherwise><xsl:text>1</xsl:text></xsl:otherwise>
1252     </xsl:choose>
1253  <xsl:text>}{</xsl:text>
1254  <xsl:choose>
1255   <xsl:when test="@align='left'"><xsl:text>l}{</xsl:text></xsl:when>
1256   <xsl:when test="@align='right'"><xsl:text>r}{</xsl:text></xsl:when>
1257   <xsl:when test="@align='center'"><xsl:text>c}{</xsl:text></xsl:when>
1258   <xsl:otherwise><xsl:text>l}{</xsl:text></xsl:otherwise>
1259  </xsl:choose>
1260   <xsl:apply-templates />
1261  <xsl:text>} </xsl:text>
1262  <xsl:if test="position()!=last()"><xsl:text> &amp; </xsl:text></xsl:if>
1263 </xsl:template>
1264
1265 <xsl:template match="combat">
1266  <xsl:text>\begin{aoncombat}</xsl:text>
1267   <xsl:apply-templates select="enemy" />
1268   <xsl:choose>
1269    <xsl:when test="enemy-attribute[@class='combatskill']">
1270     <xsl:text>: {\sc </xsl:text>
1271     <xsl:value-of select="$i18n[@src='Combat~Skill']" />
1272     <xsl:text>}~</xsl:text>
1273     <xsl:value-of select="enemy-attribute[@class='combatskill']" />
1274    </xsl:when>
1275    <xsl:when test="enemy-attribute[@class='closecombatskill']">
1276     <xsl:text>: {\sc </xsl:text>
1277     <xsl:value-of select="$i18n[@src='Close~Combat~Skill']" />
1278     <xsl:text>}~</xsl:text>
1279     <xsl:value-of select="enemy-attribute[@class='closecombatskill']" />
1280    </xsl:when>
1281   </xsl:choose>
1282   <xsl:choose>
1283    <xsl:when test="enemy-attribute[@class='endurance']">
1284     <xsl:text> ~~{\sc </xsl:text>
1285     <xsl:value-of select="$i18n[@src='Endurance']" />
1286     <xsl:text>}~</xsl:text>
1287     <xsl:value-of select="enemy-attribute[@class='endurance']" />
1288    </xsl:when>
1289    <xsl:when test="enemy-attribute[@class='target']">
1290     <xsl:value-of select="$i18n[@src='~({\sc Target}~points)~']" />
1291     <xsl:value-of select="enemy-attribute[@class='target']" />
1292    </xsl:when>
1293    <xsl:when test="enemy-attribute[@class='resistance']">
1294     <xsl:value-of select="$i18n[@src='~({\sc Resistance}~points)~']" />
1295     <xsl:value-of select="enemy-attribute[@class='resistance']" />
1296    </xsl:when>
1297   </xsl:choose>
1298  <xsl:text>\end{aoncombat}</xsl:text>
1299  <xsl:value-of select="$newparagraph" />
1300 </xsl:template>
1301
1302 <xsl:template match="choice">
1303  <xsl:variable name="link">
1304   <xsl:value-of select="@idref" />
1305  </xsl:variable>
1306
1307  <xsl:text>\nopagebreak\begin{aonchoice}</xsl:text>
1308   <xsl:for-each select="* | text()">
1309    <xsl:choose>
1310     <xsl:when test="self::link-text">
1311      <xsl:text>\hyperlink{</xsl:text>
1312      <xsl:value-of select="$link" />
1313      <xsl:text>}{\bfseries </xsl:text>
1314       <xsl:apply-templates />
1315      <xsl:text>}</xsl:text>
1316     </xsl:when>
1317     <xsl:otherwise>
1318      <xsl:apply-templates select="." />
1319     </xsl:otherwise>
1320    </xsl:choose>
1321   </xsl:for-each>
1322  <xsl:text>\end{aonchoice}</xsl:text>
1323  <xsl:value-of select="$newparagraph" />
1324 </xsl:template>
1325
1326 <!-- "top-level" signpost element -->
1327 <xsl:template match="data/signpost">
1328   <!-- CSS for HTML:
1329        text-align: center;
1330        padding-top: 0.5em;
1331        padding-bottom: 0.5em;
1332        line-height: 1.5em;
1333   -->
1334   <xsl:text>\begin{onehalfspace}\begin{center}</xsl:text>
1335     <xsl:apply-templates />
1336   <xsl:text>\end{center}\end{onehalfspace}</xsl:text>
1337   <xsl:value-of select="$newparagraph" />
1338 </xsl:template>
1339
1340 <!-- inline signpost element -->
1341 <xsl:template match="signpost">
1342   <!-- CSS for HTML:
1343        font-size: 0.8em
1344   -->
1345   <xsl:text>\begin{small}</xsl:text>
1346     <xsl:apply-templates />
1347   <xsl:text>\end{small}</xsl:text>
1348 </xsl:template>
1349
1350 <xsl:template match="blockquote">
1351  <xsl:text>\begin{quote}</xsl:text>
1352  <xsl:apply-templates />
1353  <xsl:text>\end{quote}</xsl:text>
1354  <xsl:value-of select="$newparagraph" />
1355 </xsl:template>
1356
1357 <xsl:template match="poetry">
1358   <xsl:text>\begin{flushleft}</xsl:text>
1359   <xsl:value-of select="$newline" />
1360   <xsl:text>\begin{verse}</xsl:text>
1361   <xsl:value-of select="$newline" />
1362   <xsl:apply-templates />
1363   <xsl:text>\end{verse}</xsl:text>
1364   <xsl:value-of select="$newline" />
1365   <xsl:text>\end{flushleft}</xsl:text>
1366   <xsl:value-of select="$newparagraph" />
1367 </xsl:template>
1368
1369 <!-- special treatment of the blockquote in the License section
1370      since a quote environment does not fit -->
1371 <xsl:template match="section[@id='license']//blockquote">
1372   <xsl:text>\begin{center}</xsl:text>
1373   <xsl:value-of select="$newline" />
1374     <xsl:apply-templates />
1375   <xsl:text>\end{center}</xsl:text>
1376   <xsl:value-of select="$newparagraph" />
1377 </xsl:template>
1378
1379 <xsl:template match="illustration">
1380  <xsl:choose>
1381   <xsl:when test="instance[@class='pdf'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
1382    <xsl:text>\begin{figure}[</xsl:text>
1383    <xsl:choose>
1384     <xsl:when test="@class='inline'">!ht</xsl:when>
1385     <xsl:when test="@class='float'">p</xsl:when>
1386     <xsl:when test="@class='accent'">bt</xsl:when>
1387     <xsl:otherwise><xsl:text>invalid class</xsl:text></xsl:otherwise>
1388    </xsl:choose>
1389    <xsl:text>]</xsl:text>
1390    <xsl:value-of select="$newline" />
1391    <xsl:text>\centering</xsl:text>
1392    <xsl:value-of select="$newline" />
1393    <xsl:if test="@class='float'">
1394     <xsl:text>\hypertarget{ill</xsl:text>
1395     <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="1" />
1396     <xsl:text>}{}</xsl:text>
1397     <xsl:value-of select="$newline" />
1398    </xsl:if>
1399    <xsl:text>\includegraphics</xsl:text>
1400    <xsl:choose>
1401     <xsl:when test="@class='inline'">
1402      <xsl:text>[width=</xsl:text>
1403      <xsl:choose>
1404       <xsl:when test="instance[@class='pdf']/@originalwidth">
1405        <xsl:value-of select="instance[@class='pdf']/@originalwidth" />
1406       </xsl:when>
1407       <xsl:otherwise>\textwidth</xsl:otherwise>
1408      </xsl:choose>
1409      <xsl:text>,keepaspectratio]</xsl:text>
1410     </xsl:when>
1411     <xsl:when test="@class='float'">
1412      <xsl:text>[width=\textwidth,height=\textheight,keepaspectratio]</xsl:text>
1413     </xsl:when>
1414     <xsl:when test="@class='accent'" />
1415     <xsl:otherwise><xsl:text>invalid class</xsl:text></xsl:otherwise>
1416    </xsl:choose>
1417    <xsl:text>{</xsl:text>
1418     <xsl:value-of select="instance[@class='pdf']/@src" />
1419    <xsl:text>} %</xsl:text>
1420    <xsl:if test="@class='float'">
1421     <xsl:value-of select="$newline" />
1422     <xsl:text>\vspace*{\fill}</xsl:text>
1423     <xsl:value-of select="$newline" />
1424     <!--
1425     <xsl:text>\\ \mbox{ \hypertarget{ill</xsl:text>
1426      <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="1" />
1427        <xsl:choose>
1428         <xsl:when test="$language='es'">
1429             <xsl:text>}{Ilustraci&oacute;n </xsl:text>
1430         </xsl:when>
1431         <xsl:otherwise>
1432             <xsl:text>}{Illustration </xsl:text>
1433         </xsl:otherwise>
1434        </xsl:choose>
1435      <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="I" />
1436     <xsl:text>}}\\[1em]</xsl:text>
1437     -->
1438     <xsl:text>\\{\itshape </xsl:text>
1439     <xsl:apply-templates select="meta/description" />
1440     <xsl:text>}</xsl:text>
1441    </xsl:if>
1442    <xsl:value-of select="$newline" />
1443    <xsl:text>\end{figure}</xsl:text>
1444    <xsl:value-of select="$newline" />
1445   </xsl:when>
1446
1447   <xsl:when test="instance[@class='tex'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
1448    <xsl:value-of select="$newline" />
1449    <xsl:text>\begin{figure}[!h]</xsl:text>
1450    <xsl:value-of select="$newline" />
1451     <xsl:text>\centering</xsl:text>
1452     <xsl:value-of select="$newline" />
1453     <xsl:text>\input{</xsl:text><xsl:value-of select="instance[@class='tex']/@src" /><xsl:text>}</xsl:text>
1454     <xsl:value-of select="$newline" />
1455    <xsl:text>\end{figure}</xsl:text>
1456    <xsl:value-of select="$newline" />
1457
1458    <xsl:text>\clearpage{}</xsl:text>   
1459    <xsl:value-of select="$newparagraph" />
1460   </xsl:when>
1461
1462   <xsl:otherwise />
1463
1464  </xsl:choose>
1465 </xsl:template>
1466
1467 <!-- override the above template for illustrations in numbered sections;
1468      they are handled by the template for numbered sections -->
1469 <xsl:template match="/gamebook/section/data/section[@class='numbered']/data/section[@class='numbered']//illustration[@class='float']" />
1470
1471 <!-- override the above template for illustrations for the Equipment section -->
1472 <xsl:template match="section[@id='equipmnt']//illustration[@class='inline']">
1473   <xsl:if test="instance[@class='pdf'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
1474     <xsl:text>\vspace{.2\baselineskip}</xsl:text>
1475     <xsl:value-of select="$newline" />
1476     <xsl:text>\begin{center}</xsl:text>
1477     <xsl:value-of select="$newline" />
1478     <xsl:text>\includegraphics</xsl:text>
1479     <xsl:text>[width=</xsl:text>
1480     <xsl:choose>
1481       <xsl:when test="instance[@class='pdf']/@originalwidth">
1482         <xsl:value-of select="instance[@class='pdf']/@originalwidth" />
1483       </xsl:when>
1484       <xsl:otherwise>\textwidth</xsl:otherwise>
1485     </xsl:choose>
1486     <xsl:text>,keepaspectratio]{</xsl:text>
1487       <xsl:value-of select="instance[@class='pdf']/@src" />
1488     <xsl:text>} %</xsl:text>
1489     <xsl:value-of select="$newline" />
1490     <xsl:text>\end{center}</xsl:text>
1491     <xsl:value-of select="$newline" />
1492     <xsl:text>\vspace{.2\baselineskip}</xsl:text>
1493     <xsl:value-of select="$newline" />
1494   </xsl:if>
1495 </xsl:template>
1496
1497 <!-- override the above template for illustrations for the Weaponskill section -->
1498 <xsl:template match="section[@id='wepnskll']//illustration[@class='inline']">
1499   <xsl:if test="instance[@class='pdf'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
1500     <xsl:text>\begin{figure}[!ht]</xsl:text>
1501     <xsl:value-of select="$newline" />
1502     <xsl:text>\centering</xsl:text>
1503     <xsl:value-of select="$newline" />
1504
1505 <xsl:text>
1506   \let\PBS=\PreserveBackslash
1507   \begin{tabular}{>{\PBS\centering}m{50mm}@{\hspace{0mm}}>{\PBS\centering}m{50mm}}%
1508     % \hline
1509     \rule[-1mm]{0mm}{10mm}\includegraphics[width=10.5mm,keepaspectratio]{weapons-dagger.pdf} &amp;
1510     \rule[-1mm]{0mm}{10mm}\includegraphics[width=27mm,keepaspectratio]{weapons-sword.pdf} \\ % \hline
1511     0 = </xsl:text><xsl:value-of select="$i18n[@src='Dagger']"/><xsl:text> &amp; 5 = </xsl:text><xsl:value-of select="$i18n[@src='Sword']"/><xsl:text> \\ % \hline
1512     \rule[-1mm]{0mm}{10mm}\includegraphics[width=39mm,keepaspectratio]{weapons-spear.pdf} &amp;
1513     \rule[-1mm]{0mm}{10mm}\includegraphics[width=20mm,keepaspectratio]{weapons-axe.pdf} \\ % \hline
1514     1 = </xsl:text><xsl:value-of select="$i18n[@src='Spear']"/><xsl:text> &amp; 6 = </xsl:text><xsl:value-of select="$i18n[@src='Axe']"/><xsl:text> \\ % \hline
1515     \rule[-1mm]{0mm}{10mm}\includegraphics[width=20mm,keepaspectratio]{weapons-mace.pdf} &amp;
1516     \rule[-1mm]{0mm}{10mm}\includegraphics[width=27mm,keepaspectratio]{weapons-sword.pdf} \\ % \hline
1517     2 = </xsl:text><xsl:value-of select="$i18n[@src='Mace']"/><xsl:text> &amp; 7 = </xsl:text><xsl:value-of select="$i18n[@src='Sword']"/><xsl:text> \\ % \hline
1518     \rule[-1mm]{0mm}{10mm}\includegraphics[width=20mm,keepaspectratio]{weapons-shortsword.pdf} &amp;
1519     \rule[-1mm]{0mm}{10mm}\includegraphics[width=43.5mm,keepaspectratio]{weapons-quarterstaff.pdf} \\ % \hline
1520     3 = </xsl:text><xsl:value-of select="$i18n[@src='Short Sword']"/><xsl:text> &amp; 8 = </xsl:text><xsl:value-of select="$i18n[@src='Quarterstaff']"/><xsl:text> \\ % \hline
1521     \rule[-1mm]{0mm}{10mm}\includegraphics[width=16mm,keepaspectratio]{weapons-warhammer.pdf} &amp;
1522     \rule[-1mm]{0mm}{10mm}\includegraphics[width=33mm,keepaspectratio]{weapons-broadsword.pdf} \\ % \hline
1523     4 = </xsl:text><xsl:value-of select="$i18n[@src='Warhammer']"/><xsl:text> &amp; 9 = </xsl:text><xsl:value-of select="$i18n[@src='Broadsword']"/><xsl:text> \\ % \hline
1524   \end{tabular}
1525 </xsl:text>
1526
1527 <!--
1528     <xsl:for-each select="instance[@class='pdf']/table/tr">
1529       <xsl:variable name="row"><xsl:number value="position()" format="1" /></xsl:variable>
1530       <xsl:
1531         <xsl:text>  %% row </xsl:text><xsl:value-of select="$row" /><xsl:text> %%</xsl:text>
1532         <xsl:value-of select="$newline" />
1533         <xsl:for-each select="./td">
1534           <xsl:variable name="col"><xsl:number value="position()" format="1" /></xsl:variable>
1535           <xsl:text>  \put(</xsl:text><xsl:value-of select="number($col) * number($RNTWidthOfBox) - number($RNTWidthOfBox) div 2" /><xsl:text>,</xsl:text><xsl:value-of select="(10 - number($row)) * number($RNTHeightOfBox) + number($RNTHeightOfBox) div 2" /><xsl:text>){\makebox(0,0){\bfseries \Huge </xsl:text><xsl:value-of select="." /><xsl:text>}}</xsl:text>
1536           <xsl:value-of select="$newline" />
1537         </xsl:for-each>
1538     </xsl:for-each>
1539 -->
1540
1541     <xsl:text>\end{figure}</xsl:text>
1542     <xsl:value-of select="$newline" />
1543   </xsl:if>
1544 </xsl:template>
1545
1546 <!-- override the above template for illustrations for the Weaponmastery section -->
1547 <xsl:template match="section[@id='wpnmstry']//illustration[@class='inline']">
1548   <xsl:if test="instance[@class='pdf'] and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )">
1549     <xsl:text>\begin{figure}[!ht]</xsl:text>
1550     <xsl:value-of select="$newline" />
1551     <xsl:text>\centering</xsl:text>
1552     <xsl:value-of select="$newline" />
1553
1554 <xsl:text>
1555   \let\PBS=\PreserveBackslash
1556   \begin{tabular}{>{\PBS\centering}m{50mm}@{\hspace{0mm}}>{\PBS\centering}m{50mm}}%
1557     % \hline
1558     \rule[-1mm]{0mm}{10mm}\includegraphics[width=39mm,keepaspectratio]{weapons-spear.pdf} &amp;
1559     \rule[-1mm]{0mm}{10mm}\includegraphics[width=42.5mm,keepaspectratio]{weapons-bow.pdf} \\ % \hline
1560     </xsl:text><xsl:value-of select="$i18n[@src='Spear']"/><xsl:text> &amp; </xsl:text><xsl:value-of select="$i18n[@src='Bow']"/><xsl:text> \\ % \hline
1561     \rule[-1mm]{0mm}{10mm}\includegraphics[width=10.5mm,keepaspectratio]{weapons-dagger.pdf} &amp;
1562     \rule[-1mm]{0mm}{10mm}\includegraphics[width=20mm,keepaspectratio]{weapons-axe.pdf} \\ % \hline
1563     </xsl:text><xsl:value-of select="$i18n[@src='Dagger']"/><xsl:text> &amp; </xsl:text><xsl:value-of select="$i18n[@src='Axe']"/><xsl:text> \\ % \hline
1564     \rule[-1mm]{0mm}{10mm}\includegraphics[width=20mm,keepaspectratio]{weapons-mace.pdf} &amp;
1565     \rule[-1mm]{0mm}{10mm}\includegraphics[width=27mm,keepaspectratio]{weapons-sword.pdf} \\ % \hline
1566     </xsl:text><xsl:value-of select="$i18n[@src='Mace']"/><xsl:text> &amp; </xsl:text><xsl:value-of select="$i18n[@src='Sword']"/><xsl:text> \\ % \hline
1567     \rule[-1mm]{0mm}{10mm}\includegraphics[width=20mm,keepaspectratio]{weapons-shortsword.pdf} &amp;
1568     \rule[-1mm]{0mm}{10mm}\includegraphics[width=43.5mm,keepaspectratio]{weapons-quarterstaff.pdf} \\ % \hline
1569     </xsl:text><xsl:value-of select="$i18n[@src='Short Sword']"/><xsl:text> &amp; </xsl:text><xsl:value-of select="$i18n[@src='Quarterstaff']"/><xsl:text> \\ % \hline
1570     \rule[-1mm]{0mm}{10mm}\includegraphics[width=16mm,keepaspectratio]{weapons-warhammer.pdf} &amp;
1571     \rule[-1mm]{0mm}{10mm}\includegraphics[width=33mm,keepaspectratio]{weapons-broadsword.pdf} \\ % \hline
1572     </xsl:text><xsl:value-of select="$i18n[@src='Warhammer']"/><xsl:text> &amp; </xsl:text><xsl:value-of select="$i18n[@src='Broadsword']"/><xsl:text> \\ % \hline
1573   \end{tabular}
1574 </xsl:text>
1575     <xsl:text>\end{figure}</xsl:text>
1576     <xsl:value-of select="$newline" />
1577   </xsl:if>
1578 </xsl:template>
1579
1580 <!-- override the above template for illustrations for the Map section -->
1581 <!-- the map is handled by the template for the map section -->
1582 <xsl:template match="section[@id='map']//illustration" />
1583
1584 <xsl:template match="instance" />
1585
1586 <xsl:template match="footnotes" />
1587
1588 <xsl:template match="footnote">
1589  <xsl:apply-templates />
1590 </xsl:template>
1591
1592 <xsl:template match="hr">
1593  <xsl:text>\rule{\textwidth}{0.4pt}</xsl:text>
1594  <xsl:value-of select="$newline" />
1595 </xsl:template>
1596
1597 <!-- ==================== inline elements ======================= -->
1598
1599 <xsl:template match="a">
1600  <xsl:if test="@href">
1601   <xsl:text>\href{</xsl:text>
1602   <xsl:value-of select="@href" />
1603   <xsl:text>}{</xsl:text>
1604  </xsl:if>
1605  <xsl:if test="@idref">
1606   <xsl:text>\hyperlink{</xsl:text>
1607   <xsl:value-of select="@idref" />
1608   <xsl:text>}{</xsl:text>
1609  </xsl:if>
1610  <xsl:if test="@id">
1611   <xsl:text>\hypertarget{</xsl:text>
1612   <xsl:value-of select="@id" />
1613   <xsl:text>}{</xsl:text>
1614  </xsl:if>
1615
1616  <xsl:apply-templates />
1617
1618  <xsl:if test="@id">
1619   <xsl:text>}</xsl:text>
1620  </xsl:if>
1621  <xsl:if test="@idref">
1622   <xsl:text>}</xsl:text>
1623  </xsl:if>
1624  <xsl:if test="@href">
1625   <xsl:text>}</xsl:text>
1626  </xsl:if>
1627 </xsl:template>
1628
1629 <xsl:template match="a[@idref='action']">
1630  <xsl:text>\hyperlink{action}{\emph{</xsl:text>
1631   <xsl:apply-templates />
1632  <xsl:text>}}</xsl:text>
1633 </xsl:template>
1634
1635 <xsl:template match="a[@idref='random']">
1636  <xsl:text>\hyperlink{random}{\emph{</xsl:text>
1637   <xsl:apply-templates />
1638  <xsl:text>}}</xsl:text>
1639 </xsl:template>
1640
1641 <!-- This template is obsolete, the "footref" element should be used instead -->
1642 <xsl:template match="a[@class='footnote']">
1643  <xsl:apply-templates />
1644  <xsl:text>\footnote{</xsl:text>
1645  <xsl:for-each select="id( @idref )">
1646   <xsl:apply-templates />
1647  </xsl:for-each>
1648  <xsl:text>}</xsl:text>
1649 </xsl:template>
1650
1651 <xsl:template match="footref">
1652  <xsl:apply-templates />
1653  <xsl:text>\footnote{</xsl:text>
1654  <xsl:for-each select="id( @idref )">
1655   <xsl:apply-templates />
1656  </xsl:for-each>
1657  <xsl:text>}</xsl:text>
1658 </xsl:template>
1659
1660 <xsl:template match="em">
1661  <xsl:text>\emph{</xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1662 </xsl:template>
1663
1664 <xsl:template match="strong">
1665  <xsl:text>{\bfseries </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1666 </xsl:template>
1667
1668 <xsl:template match="thought">
1669  <xsl:text>{\itshape </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1670 </xsl:template>
1671
1672 <xsl:template match="onomatopoeia">
1673  <xsl:text>{\itshape </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1674 </xsl:template>
1675
1676 <xsl:template match="spell">
1677  <xsl:text>{\itshape </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1678 </xsl:template>
1679
1680 <xsl:template match="item">
1681  <xsl:apply-templates />
1682 </xsl:template>
1683
1684 <xsl:template match="foreign">
1685  <xsl:text>{\itshape </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1686 </xsl:template>
1687
1688 <xsl:template match="quote">
1689  <xsl:text>&lsquot;</xsl:text>
1690   <xsl:apply-templates />
1691   <xsl:if test="not(self::*[@class='open-ended'])"><xsl:text>&rsquot;</xsl:text></xsl:if>
1692 </xsl:template>
1693
1694 <xsl:template match="quote//quote">
1695  <xsl:text>&ldquot;</xsl:text>
1696   <xsl:apply-templates />
1697   <xsl:if test="not(self::*[@class='open-ended'])"><xsl:text>&rdquot;</xsl:text></xsl:if>
1698 </xsl:template>
1699
1700 <xsl:template match="cite">
1701  <xsl:text>{\itshape </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1702 </xsl:template>
1703
1704 <xsl:template match="code">
1705  <xsl:text>{\ttfamily </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1706 </xsl:template>
1707
1708 <xsl:template match="line">
1709  <xsl:apply-templates />
1710  <xsl:if test="following-sibling::line">\\</xsl:if>
1711  <xsl:value-of select="$newline" />
1712 </xsl:template>
1713
1714 <xsl:template match="br">
1715  <xsl:text>\\</xsl:text>
1716 </xsl:template>
1717
1718 <xsl:template match="typ[@class='attribute']">
1719  <xsl:choose>
1720   <xsl:when test="contains(self::node(),'ENDURANCE')">
1721    <xsl:text>{\sc Endurance}</xsl:text>
1722   </xsl:when>
1723   <xsl:when test="contains(self::node(),'COMBAT SKILL')">
1724    <xsl:text>{\sc Combat Skill}</xsl:text>
1725   </xsl:when>
1726   <xsl:when test="contains(self::node(),'WILLPOWER')">
1727    <xsl:text>{\sc Willpower}</xsl:text>
1728   </xsl:when>
1729   <xsl:when test="contains(self::node(),'TARGET')">
1730    <xsl:text>{\sc Target}</xsl:text>
1731   </xsl:when>
1732   <xsl:when test="contains(self::node(),'CS')">
1733    <xsl:text>{\small CS}</xsl:text>
1734   </xsl:when>
1735   <xsl:when test="contains(self::node(),'EP')">
1736    <xsl:text>{\small EP}</xsl:text>
1737   </xsl:when>
1738   <xsl:when test="contains(self::node(),'RESISTANCE')">
1739    <xsl:text>{\sc Resistance}</xsl:text>
1740   </xsl:when>
1741   <xsl:when test="contains(self::node(),'DESTREZA EN EL COMBATE')">
1742    <xsl:text>{\sc DESTREZA EN EL COMBATE}</xsl:text>
1743   </xsl:when>
1744   <xsl:when test="contains(self::node(),'RESISTENCIA')">
1745    <xsl:text>{\sc RESISTENCIA}</xsl:text>
1746   </xsl:when>
1747   <xsl:when test="contains(self::node(),'BLANCOS')">
1748    <xsl:text>{\sc BLANCOS}</xsl:text>
1749   </xsl:when>
1750   <xsl:when test="contains(self::node(),'DC')">
1751    <xsl:text>{\small DC}</xsl:text>
1752   </xsl:when>
1753   <xsl:when test="contains(self::node(),'PR')">
1754    <xsl:text>{\small PR}</xsl:text>
1755   </xsl:when>
1756   <xsl:otherwise>
1757    <xsl:message terminate="yes">
1758      Error: Unknown attribute "<xsl:value-of select="self::node()" />"
1759    </xsl:message>
1760   </xsl:otherwise>
1761  </xsl:choose>
1762 <!--
1763  <xsl:text>{\small </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1764 -->
1765 </xsl:template>
1766
1767 <xsl:template match="footnote//typ[@class='attribute']">
1768  <xsl:text>{\scriptsize </xsl:text><xsl:apply-templates /><xsl:text>}</xsl:text>
1769 </xsl:template>
1770
1771 <!-- ====================== text elements ======================= -->
1772
1773 <!-- Special template for discarding (whitespace) text between <line>
1774      elements in illustration captions; this is done to avoid potentially
1775      harmful (for the layout) line breaks.
1776      Note: Since <description> elements either contain "verbatim" text or
1777            text structured with <line> or <p> elements, but never a mix of
1778            non-whitespace text elements and <line> elements, I decided
1779            to leave out more complicated code that ensures that only
1780            whitespace is discarded.
1781 -->
1782 <xsl:template match="illustration/meta/description/text()">
1783   <xsl:choose>
1784     <xsl:when test="following-sibling::line|preceding-sibling::line" />
1785     <xsl:otherwise>
1786       <xsl:copy />
1787     </xsl:otherwise>
1788   </xsl:choose>
1789 </xsl:template>
1790
1791 <!-- ==================== character elements ==================== -->
1792 <!--
1793
1794 These templates define the mapping between the character elements used in
1795 the Project Aon instances of Gamebook XML and the ISO-8859-1
1796 characters.
1797
1798 Portions Copyright International Organization for Standardization 1986 
1799 Permission to copy in any form is granted for use with conforming SGML 
1800 systems and applications as defined in ISO 8879, provided this notice 
1801 is included in all copies.
1802
1803 -->
1804
1805 <!-- JFS: TODO - probably the \definitions need to be in {} to prevent 
1806      issues if followed by text -->
1807
1808 <xsl:template match="ch.apos"><xsl:text>&#39;</xsl:text></xsl:template><!-- apostrophe = single quotation mark -->
1809 <xsl:template match="ch.nbsp"><xsl:text>~</xsl:text></xsl:template><!-- no-break space = non-breaking space, U+00A0 ISOnum -->
1810 <xsl:template match="ch.iexcl"><xsl:text>{\textexclamdown}</xsl:text></xsl:template><!-- inverted exclamation mark, U+00A1 ISOnum -->
1811 <xsl:template match="ch.cent"><xsl:text>\textcent</xsl:text></xsl:template><!-- cent sign, U+00A2 ISOnum -->
1812 <xsl:template match="ch.pound"><xsl:text>\pounds</xsl:text></xsl:template><!-- pound sign, U+00A3 ISOnum -->
1813 <xsl:template match="ch.curren"><xsl:text>\textcurrency</xsl:text></xsl:template><!-- currency sign, U+00A4 ISOnum -->
1814 <xsl:template match="ch.yen"><xsl:text>\textyen</xsl:text></xsl:template><!-- yen sign = yuan sign, U+00A5 ISOnum -->
1815 <xsl:template match="ch.brvbar"><xsl:text>\textbar</xsl:text></xsl:template><!-- broken bar = broken vertical bar, U+00A6 ISOnum -->
1816 <xsl:template match="ch.sect"><xsl:text>\textsection</xsl:text></xsl:template><!-- section sign, U+00A7 ISOnum -->
1817 <xsl:template match="ch.uml"><xsl:text>\ddot{}</xsl:text></xsl:template><!-- diaeresis = spacing diaeresis, U+00A8 ISOdia -->
1818 <xsl:template match="ch.copy"><xsl:text>{\copyright}</xsl:text></xsl:template><!-- copyright sign, U+00A9 ISOnum -->
1819 <xsl:template match="ch.ordf"><xsl:text>\textordfeminine</xsl:text></xsl:template><!-- feminine ordinal indicator, U+00AA ISOnum -->
1820 <xsl:template match="ch.laquo"><xsl:text>{\guillemotleft}</xsl:text></xsl:template><!-- left-pointing double angle quotation mark = left pointing guillemet, U+00AB ISOnum -->
1821 <xsl:template match="ch.not"><xsl:text>\textlnot</xsl:text></xsl:template><!-- not sign, U+00AC ISOnum -->
1822 <xsl:template match="ch.shy"><xsl:text>\-</xsl:text></xsl:template><!-- soft hyphen = discretionary hyphen, U+00AD ISOnum -->
1823 <xsl:template match="ch.reg"><xsl:text>{\texttrademark}</xsl:text></xsl:template><!-- registered sign = registered trade mark sign, U+00AE ISOnum -->
1824 <xsl:template match="ch.macr"><xsl:text>\textasciimacron</xsl:text></xsl:template><!-- macron = spacing macron = overline = APL overbar, U+00AF ISOdia -->
1825 <xsl:template match="ch.deg"><xsl:text>\textdegree</xsl:text></xsl:template><!-- degree sign, U+00B0 ISOnum -->
1826 <xsl:template match="ch.plusmn"><xsl:text>\textpm</xsl:text></xsl:template><!-- plus-minus sign = plus-or-minus sign, U+00B1 ISOnum -->
1827 <xsl:template match="ch.sup2"><xsl:text>^2</xsl:text></xsl:template><!-- superscript two = superscript digit two = squared, U+00B2 ISOnum -->
1828 <xsl:template match="ch.sup3"><xsl:text>^3</xsl:text></xsl:template><!-- superscript three = superscript digit three = cubed, U+00B3 ISOnum -->
1829 <xsl:template match="ch.acute"><xsl:text>\'</xsl:text></xsl:template><!-- acute accent = spacing acute, U+00B4 ISOdia -->
1830 <xsl:template match="ch.micro"><xsl:text>\textmu</xsl:text></xsl:template><!-- micro sign, U+00B5 ISOnum -->
1831 <xsl:template match="ch.para"><xsl:text>\textparagraph</xsl:text></xsl:template><!-- pilcrow sign  = paragraph sign, U+00B6 ISOnum -->
1832 <xsl:template match="ch.middot"><xsl:text>\textperiodcentered</xsl:text></xsl:template><!-- middle dot = Georgian comma = Greek middle dot, U+00B7 ISOnum -->
1833 <xsl:template match="ch.cedil"><xsl:text>\c{c}</xsl:text></xsl:template><!-- cedilla = spacing cedilla, U+00B8 ISOdia -->
1834 <xsl:template match="ch.sup1"><xsl:text>^1</xsl:text></xsl:template><!-- superscript one = superscript digit one, U+00B9 ISOnum -->
1835 <xsl:template match="ch.ordm"><xsl:text>\textordmasculine</xsl:text></xsl:template><!-- masculine ordinal indicator, U+00BA ISOnum -->
1836 <xsl:template match="ch.raquo"><xsl:text>{\guillemotright}</xsl:text></xsl:template><!-- right-pointing double angle quotation mark = right pointing guillemet, U+00BB ISOnum -->
1837 <xsl:template match="ch.frac14"><xsl:text>$\frac{1}{4}$</xsl:text></xsl:template><!-- vulgar fraction one quarter = fraction one quarter, U+00BC ISOnum -->
1838 <xsl:template match="ch.frac12"><xsl:text>$\frac{1}{2}$</xsl:text></xsl:template><!-- vulgar fraction one half = fraction one half, U+00BD ISOnum -->
1839 <xsl:template match="ch.frac34"><xsl:text>$\frac{3}{4}$</xsl:text></xsl:template><!-- vulgar fraction three quarters = fraction three quarters, U+00BE ISOnum -->
1840 <xsl:template match="ch.iquest"><xsl:text>{\textquestiondown}</xsl:text></xsl:template><!-- inverted question mark = turned question mark, U+00BF ISOnum -->
1841 <xsl:template match="ch.Agrave"><xsl:text>&#192;</xsl:text></xsl:template><!-- latin capital letter A with grave = latin capital letter A grave, U+00C0 ISOlat1 -->
1842 <xsl:template match="ch.Aacute"><xsl:text>&#193;</xsl:text></xsl:template><!-- latin capital letter A with acute, U+00C1 ISOlat1 -->
1843 <xsl:template match="ch.Acirc"><xsl:text>&#194;</xsl:text></xsl:template><!-- latin capital letter A with circumflex, U+00C2 ISOlat1 -->
1844 <xsl:template match="ch.Atilde"><xsl:text>&#195;</xsl:text></xsl:template><!-- latin capital letter A with tilde, U+00C3 ISOlat1 -->
1845 <xsl:template match="ch.Auml"><xsl:text>&#196;</xsl:text></xsl:template><!-- latin capital letter A with diaeresis, U+00C4 ISOlat1 -->
1846 <xsl:template match="ch.Aring"><xsl:text>&#197;</xsl:text></xsl:template><!-- latin capital letter A with ring above = latin capital letter A ring, U+00C5 ISOlat1 -->
1847 <xsl:template match="ch.AElig"><xsl:text>&#198;</xsl:text></xsl:template><!-- latin capital letter AE = latin capital ligature AE, U+00C6 ISOlat1 -->
1848 <xsl:template match="ch.Ccedil"><xsl:text>&#199;</xsl:text></xsl:template><!-- latin capital letter C with cedilla, U+00C7 ISOlat1 -->
1849 <xsl:template match="ch.Egrave"><xsl:text>&#200;</xsl:text></xsl:template><!-- latin capital letter E with grave, U+00C8 ISOlat1 -->
1850 <xsl:template match="ch.Eacute"><xsl:text>&#201;</xsl:text></xsl:template><!-- latin capital letter E with acute, U+00C9 ISOlat1 -->
1851 <xsl:template match="ch.Ecirc"><xsl:text>&#202;</xsl:text></xsl:template><!-- latin capital letter E with circumflex, U+00CA ISOlat1 -->
1852 <xsl:template match="ch.Euml"><xsl:text>&#203;</xsl:text></xsl:template><!-- latin capital letter E with diaeresis, U+00CB ISOlat1 -->
1853 <xsl:template match="ch.Igrave"><xsl:text>&#204;</xsl:text></xsl:template><!-- latin capital letter I with grave, U+00CC ISOlat1 -->
1854 <xsl:template match="ch.Iacute"><xsl:text>&#205;</xsl:text></xsl:template><!-- latin capital letter I with acute, U+00CD ISOlat1 -->
1855 <xsl:template match="ch.Icirc"><xsl:text>&#206;</xsl:text></xsl:template><!-- latin capital letter I with circumflex, U+00CE ISOlat1 -->
1856 <xsl:template match="ch.Iuml"><xsl:text>&#207;</xsl:text></xsl:template><!-- latin capital letter I with diaeresis, U+00CF ISOlat1 -->
1857 <xsl:template match="ch.ETH"><xsl:text>&#208;</xsl:text></xsl:template><!-- latin capital letter ETH, U+00D0 ISOlat1 -->
1858 <xsl:template match="ch.Ntilde"><xsl:text>&#209;</xsl:text></xsl:template><!-- latin capital letter N with tilde, U+00D1 ISOlat1 -->
1859 <xsl:template match="ch.Ograve"><xsl:text>&#210;</xsl:text></xsl:template><!-- latin capital letter O with grave, U+00D2 ISOlat1 -->
1860 <xsl:template match="ch.Oacute"><xsl:text>&#211;</xsl:text></xsl:template><!-- latin capital letter O with acute, U+00D3 ISOlat1 -->
1861 <xsl:template match="ch.Ocirc"><xsl:text>&#212;</xsl:text></xsl:template><!-- latin capital letter O with circumflex, U+00D4 ISOlat1 -->
1862 <xsl:template match="ch.Otilde"><xsl:text>&#213;</xsl:text></xsl:template><!-- latin capital letter O with tilde, U+00D5 ISOlat1 -->
1863 <xsl:template match="ch.Ouml"><xsl:text>&#214;</xsl:text></xsl:template><!-- latin capital letter O with diaeresis, U+00D6 ISOlat1 -->
1864 <xsl:template match="ch.times"><xsl:text>&#215;</xsl:text></xsl:template><!-- multiplication sign, U+00D7 ISOnum -->
1865 <xsl:template match="ch.Oslash"><xsl:text>&#216;</xsl:text></xsl:template><!-- latin capital letter O with stroke = latin capital letter O slash, U+00D8 ISOlat1 -->
1866 <xsl:template match="ch.Ugrave"><xsl:text>&#217;</xsl:text></xsl:template><!-- latin capital letter U with grave, U+00D9 ISOlat1 -->
1867 <xsl:template match="ch.Uacute"><xsl:text>&#218;</xsl:text></xsl:template><!-- latin capital letter U with acute, U+00DA ISOlat1 -->
1868 <xsl:template match="ch.Ucirc"><xsl:text>&#219;</xsl:text></xsl:template><!-- latin capital letter U with circumflex, U+00DB ISOlat1 -->
1869 <xsl:template match="ch.Uuml"><xsl:text>&#220;</xsl:text></xsl:template><!-- latin capital letter U with diaeresis, U+00DC ISOlat1 -->
1870 <xsl:template match="ch.Yacute"><xsl:text>&#221;</xsl:text></xsl:template><!-- latin capital letter Y with acute, U+00DD ISOlat1 -->
1871 <xsl:template match="ch.THORN"><xsl:text>&#222;</xsl:text></xsl:template><!-- latin capital letter THORN, U+00DE ISOlat1 -->
1872 <xsl:template match="ch.szlig"><xsl:text>&#223;</xsl:text></xsl:template><!-- latin small letter sharp s = ess-zed, U+00DF ISOlat1 -->
1873 <xsl:template match="ch.agrave"><xsl:text>&#224;</xsl:text></xsl:template><!-- latin small letter a with grave = latin small letter a grave, U+00E0 ISOlat1 -->
1874 <xsl:template match="ch.aacute"><xsl:text>&#225;</xsl:text></xsl:template><!-- latin small letter a with acute, U+00E1 ISOlat1 -->
1875 <xsl:template match="ch.acirc"><xsl:text>&#226;</xsl:text></xsl:template><!-- latin small letter a with circumflex, U+00E2 ISOlat1 -->
1876 <xsl:template match="ch.atilde"><xsl:text>&#227;</xsl:text></xsl:template><!-- latin small letter a with tilde, U+00E3 ISOlat1 -->
1877 <xsl:template match="ch.auml"><xsl:text>&#228;</xsl:text></xsl:template><!-- latin small letter a with diaeresis, U+00E4 ISOlat1 -->
1878 <xsl:template match="ch.aring"><xsl:text>&#229;</xsl:text></xsl:template><!-- latin small letter a with ring above = latin small letter a ring, U+00E5 ISOlat1 -->
1879 <xsl:template match="ch.aelig"><xsl:text>&#230;</xsl:text></xsl:template><!-- latin small letter ae = latin small ligature ae, U+00E6 ISOlat1 -->
1880 <xsl:template match="ch.ccedil"><xsl:text>&#231;</xsl:text></xsl:template><!-- latin small letter c with cedilla, U+00E7 ISOlat1 -->
1881 <xsl:template match="ch.egrave"><xsl:text>&#232;</xsl:text></xsl:template><!-- latin small letter e with grave, U+00E8 ISOlat1 -->
1882 <xsl:template match="ch.eacute"><xsl:text>&#233;</xsl:text></xsl:template><!-- latin small letter e with acute, U+00E9 ISOlat1 -->
1883 <xsl:template match="ch.ecirc"><xsl:text>&#234;</xsl:text></xsl:template><!-- latin small letter e with circumflex, U+00EA ISOlat1 -->
1884 <xsl:template match="ch.euml"><xsl:text>&#235;</xsl:text></xsl:template><!-- latin small letter e with diaeresis, U+00EB ISOlat1 -->
1885 <xsl:template match="ch.igrave"><xsl:text>&#236;</xsl:text></xsl:template><!-- latin small letter i with grave, U+00EC ISOlat1 -->
1886 <xsl:template match="ch.iacute"><xsl:text>&#237;</xsl:text></xsl:template><!-- latin small letter i with acute, U+00ED ISOlat1 -->
1887 <xsl:template match="ch.icirc"><xsl:text>&#238;</xsl:text></xsl:template><!-- latin small letter i with circumflex, U+00EE ISOlat1 -->
1888 <xsl:template match="ch.iuml"><xsl:text>&#239;</xsl:text></xsl:template><!-- latin small letter i with diaeresis, U+00EF ISOlat1 -->
1889 <xsl:template match="ch.eth"><xsl:text>&#240;</xsl:text></xsl:template><!-- latin small letter eth, U+00F0 ISOlat1 -->
1890 <xsl:template match="ch.ntilde"><xsl:text>&#241;</xsl:text></xsl:template><!-- latin small letter n with tilde, U+00F1 ISOlat1 -->
1891 <xsl:template match="ch.ograve"><xsl:text>&#242;</xsl:text></xsl:template><!-- latin small letter o with grave, U+00F2 ISOlat1 -->
1892 <xsl:template match="ch.oacute"><xsl:text>&#243;</xsl:text></xsl:template><!-- latin small letter o with acute, U+00F3 ISOlat1 -->
1893 <xsl:template match="ch.ocirc"><xsl:text>&#244;</xsl:text></xsl:template><!-- latin small letter o with circumflex, U+00F4 ISOlat1 -->
1894 <xsl:template match="ch.otilde"><xsl:text>&#245;</xsl:text></xsl:template><!-- latin small letter o with tilde, U+00F5 ISOlat1 -->
1895 <xsl:template match="ch.ouml"><xsl:text>&#246;</xsl:text></xsl:template><!-- latin small letter o with diaeresis, U+00F6 ISOlat1 -->
1896 <xsl:template match="ch.divide"><xsl:text>&#247;</xsl:text></xsl:template><!-- division sign, U+00F7 ISOnum -->
1897 <xsl:template match="ch.oslash"><xsl:text>&#248;</xsl:text></xsl:template><!-- latin small letter o with stroke, = latin small letter o slash, U+00F8 ISOlat1 -->
1898 <xsl:template match="ch.ugrave"><xsl:text>&#249;</xsl:text></xsl:template><!-- latin small letter u with grave, U+00F9 ISOlat1 -->
1899 <xsl:template match="ch.uacute"><xsl:text>&#250;</xsl:text></xsl:template><!-- latin small letter u with acute, U+00FA ISOlat1 -->
1900 <xsl:template match="ch.ucirc"><xsl:text>&#251;</xsl:text></xsl:template><!-- latin small letter u with circumflex, U+00FB ISOlat1 -->
1901 <xsl:template match="ch.uuml"><xsl:text>&#252;</xsl:text></xsl:template><!-- latin small letter u with diaeresis, U+00FC ISOlat1 -->
1902 <xsl:template match="ch.yacute"><xsl:text>&#253;</xsl:text></xsl:template><!-- latin small letter y with acute, U+00FD ISOlat1 -->
1903 <xsl:template match="ch.thorn"><xsl:text>&#254;</xsl:text></xsl:template><!-- latin small letter thorn, U+00FE ISOlat1 -->
1904 <xsl:template match="ch.yuml"><xsl:text>&#255;</xsl:text></xsl:template><!-- latin small letter y with diaeresis, U+00FF ISOlat1 -->
1905
1906 <!-- ~~~~~~~~~~~~~~~~~~~~~ Special Characters ~~~~~~~~~~~~~~~~~~~~ -->
1907
1908 <xsl:template match="ch.ampersand">\&amp;</xsl:template><!-- ampersand -->
1909 <xsl:template match="ch.lsquot">\textquoteleft </xsl:template><!-- opening left quotation mark -->
1910 <xsl:template match="ch.rsquot">\textquoteright </xsl:template><!-- closing right quotation mark -->
1911 <xsl:template match="ch.ldquot">``</xsl:template><!-- opening left double quotation mark -->
1912 <xsl:template match="ch.rdquot">''</xsl:template><!-- closing right double quotation mark -->
1913 <xsl:template match="ch.minus">$-$</xsl:template><!-- mathematical minus -->
1914 <xsl:template match="ch.endash">--</xsl:template><!-- endash -->
1915 <xsl:template match="ch.emdash">---</xsl:template><!-- emdash -->
1916 <xsl:template match="ch.ellips">...</xsl:template><!-- ellipsis -->
1917 <xsl:template match="ch.lellips">...</xsl:template><!-- left ellipsis, used at the beginning of edited material -->
1918 <xsl:template match="ch.blankline">\_\_\_\_\_\_\_</xsl:template><!-- blank line to be filled in -->
1919 <xsl:template match="ch.percent"><xsl:text>\%</xsl:text></xsl:template><!-- percent sign -->
1920 <xsl:template match="ch.thinspace"><xsl:text>\ </xsl:text></xsl:template><!-- small horizontal space for use between adjacent quotation marks - added mainly for LaTeX's sake -->
1921 <xsl:template match="ch.frac116"><xsl:text>1/16</xsl:text></xsl:template><!-- vulgar fraction one sixteenth = fraction on sixteenth -->
1922 <xsl:template match="ch.plus"><xsl:text>+</xsl:text></xsl:template><!-- mathematical plus -->
1923
1924 <!-- ==================== named templates ======================= -->
1925
1926 <!--
1927  A "subroutine" to generate a link to the current section, with the section title (expanded with "Section " in case of a numbered section) as link text.
1928 -->
1929 <xsl:template name="section-title-link">
1930  <!-- will the list always contain the closest ancestor first? -->
1931  <xsl:variable name="section-title">
1932   <!-- numbered or not? -->
1933   <xsl:if test="ancestor::section[position()=1]/@class='numbered'">
1934    <xsl:value-of select="$i18n[@src='Section']" />
1935    <xsl:text>~</xsl:text>
1936   </xsl:if>
1937   <xsl:apply-templates select="ancestor::section[position()=1]/meta/title[1]" />
1938  </xsl:variable>
1939  
1940  <a>
1941   <xsl:attribute name="href"><xsl:text>#</xsl:text><xsl:value-of select="ancestor::section[position()=1]/@id" /></xsl:attribute>
1942   <xsl:value-of select="$section-title" />
1943  </a>
1944 </xsl:template>
1945
1946 <!--
1947         Subroutines to generate the combat ratio tables.
1948 -->
1949
1950 <xsl:template name="combat-ratio-table">
1951   <xsl:param name="title" />
1952   <xsl:param name="startCol" />
1953   <xsl:param name="endCol" />
1954   <xsl:param name="colHeaders" />
1955   <xsl:param name="showLeftLabel" select="0" />
1956   <xsl:param name="showRightLabel" select="0" />
1957
1958   <xsl:variable name="offsetX">0</xsl:variable>
1959   <xsl:variable name="offsetY">10</xsl:variable>
1960
1961   <!-- calculate a few sizes and positions -->
1962   <xsl:variable name="leftLabelWidth" select="number($showLeftLabel) * number($sideLabelWidth)" />
1963   <xsl:variable name="rightLabelWidth" select="number($showRightLabel) * number($sideLabelWidth)" />
1964
1965   <xsl:variable name="legendWidth" select="2 * number($rnColWidth) + 7 * number($resultBoxWidth)" />
1966   <xsl:variable name="legendX" select="$leftLabelWidth" />
1967   <xsl:variable name="legendY" select="0" />
1968
1969   <xsl:variable name="topLabelX" select="number($leftLabelWidth) + number($legendWidth) div 2" />
1970   <xsl:variable name="topLabelY" select="number($legendHeight) + number($legendSep) + 2 * number($combatRatioBoxHeight) + 10 * number($resultBoxHeight) + number($topLabelSep)" />
1971
1972   <xsl:variable name="leftLabelX" select="number($leftLabelWidth) div 2" />
1973   <xsl:variable name="leftLabelY" select="number($legendHeight) + number($legendSep) + number($combatRatioBoxHeight) + 5 * number($resultBoxHeight)" />
1974   <xsl:variable name="rightLabelX" select="number($leftLabelWidth) + 2 * number($rnColWidth) + 7 * number($resultBoxWidth) + number($rightLabelWidth) div 2" />
1975   <xsl:variable name="rightLabelY" select="number($legendHeight) + number($legendSep) + number($combatRatioBoxHeight) + 5 * number($resultBoxHeight)" />
1976
1977   <xsl:variable name="randomNumberBoxesLeftX" select="$leftLabelWidth" />
1978   <xsl:variable name="randomNumberBoxesRightX" select="number($leftLabelWidth) + number($rnColWidth) + 7 * number($resultBoxWidth)" />
1979   <xsl:variable name="randomNumberBoxesY" select="number($legendHeight) + number($legendSep) + number($combatRatioBoxHeight)" />
1980
1981   <xsl:variable name="resultBoxesX" select="number($leftLabelWidth) + number($rnColWidth)" />
1982   <xsl:variable name="resultBoxesY" select="number($legendHeight) + number($legendSep) + number($combatRatioBoxHeight)" />
1983
1984   <xsl:variable name="combatRatioBoxesX" select="number($leftLabelWidth) + number($rnColWidth)" />
1985   <xsl:variable name="combatRatioBoxesBottomY" select="number($legendHeight) + number($legendSep)" />
1986   <xsl:variable name="combatRatioBoxesTopY" select="number($legendHeight) + number($legendSep) + number($combatRatioBoxHeight) + 10 * number($resultBoxHeight)" />
1987
1988   <xsl:variable name="totalWidth" select="number($sideLabelWidth) + 2 * number($rnColWidth) + 7 * number($resultBoxWidth)" />
1989   <xsl:variable name="totalHeight" select="number($legendHeight) + number($legendSep) + 2 * number($combatRatioBoxHeight) + 10 * number($resultBoxHeight) + number($topLabelSep) + number($topLabelHeight)" />
1990
1991 <xsl:text>\setlength{\unitlength}{1mm}
1992 \vspace*{\stretch{1}}
1993 \begin{center}
1994 \begin{picture}(0,0)(</xsl:text><xsl:value-of select="0.5 * number($totalWidth) - number($offsetX)" /><xsl:text>,</xsl:text><xsl:value-of select="0.5 * number($totalHeight) - number($offsetY)" /><xsl:text>)
1995
1996   %% the legend %%
1997   \put(</xsl:text><xsl:value-of select="$legendX" /><xsl:text>,</xsl:text><xsl:value-of select="$legendY" /><xsl:text>){%
1998     \makebox(</xsl:text><xsl:value-of select="$legendWidth" /><xsl:text>,</xsl:text><xsl:value-of select="$legendHeight" /><xsl:text>){%
1999       \mbox{\footnotesize </xsl:text><xsl:value-of select="$i18n[@src='E = Enemy EP loss']" /><xsl:text>}%
2000       \hfill%
2001       \mbox{\footnotesize </xsl:text><xsl:value-of select="$i18n[@src='LW = Lone Wolf EP loss']" /><xsl:text>}%
2002       \hfill%
2003       \mbox{\footnotesize </xsl:text><xsl:value-of select="$i18n[@src='K = Automatic Kill']" /><xsl:text>}%
2004     }%
2005   }
2006
2007   %% the labels %%</xsl:text>
2008   <xsl:value-of select="$newline" />
2009   <xsl:if test="number($showLeftLabel) = 1">
2010     <xsl:text>  \put(</xsl:text><xsl:value-of select="$leftLabelX" /><xsl:text>,</xsl:text><xsl:value-of select="$leftLabelY" /><xsl:text>){\makebox(0,0){\rotatebox{90}{\bfseries \large </xsl:text><xsl:value-of select="$i18n[@src='Random Number']" /><xsl:text>}}}</xsl:text>
2011     <xsl:value-of select="$newline" />
2012   </xsl:if>
2013   <xsl:if test="number($showRightLabel) = 1">
2014     <xsl:text>  \put(</xsl:text><xsl:value-of select="$rightLabelX" /><xsl:text>,</xsl:text><xsl:value-of select="$rightLabelY" /><xsl:text>){\makebox(0,0){\rotatebox{270}{\bfseries \large </xsl:text><xsl:value-of select="$i18n[@src='Random Number']" /><xsl:text>}}}</xsl:text>
2015     <xsl:value-of select="$newline" />
2016   </xsl:if>
2017   <xsl:text>  \put(</xsl:text><xsl:value-of select="$topLabelX" /><xsl:text>,</xsl:text><xsl:value-of select="$topLabelY" /><xsl:text>){\makebox(0,0)[b]{\bfseries \large </xsl:text><xsl:value-of select="$title" /><xsl:text>}}
2018
2019   %% random number boxes %%
2020   \multiput(</xsl:text><xsl:value-of select="$randomNumberBoxesLeftX" /><xsl:text>,</xsl:text><xsl:value-of select="$randomNumberBoxesY" /><xsl:text>)(0,</xsl:text><xsl:value-of select="2 * number($randomNumberBoxHeight)" /><xsl:text>){5}{%
2021     \lightgraybox{</xsl:text><xsl:value-of select="$randomNumberBoxWidth" /><xsl:text>}{</xsl:text><xsl:value-of select="$randomNumberBoxHeight" /><xsl:text>}%
2022   }
2023   \multiput(</xsl:text><xsl:value-of select="$randomNumberBoxesRightX" /><xsl:text>,</xsl:text><xsl:value-of select="$randomNumberBoxesY" /><xsl:text>)(0,</xsl:text><xsl:value-of select="2 * number($randomNumberBoxHeight)" /><xsl:text>){5}{%
2024     \lightgraybox{</xsl:text><xsl:value-of select="$randomNumberBoxWidth" /><xsl:text>}{</xsl:text><xsl:value-of select="$randomNumberBoxHeight" /><xsl:text>}%
2025   }
2026
2027   %% results boxes %%
2028   \multiput(</xsl:text><xsl:value-of select="$resultBoxesX" /><xsl:text>,</xsl:text><xsl:value-of select="$resultBoxesY" /><xsl:text>)(0,</xsl:text><xsl:value-of select="2 * number($resultBoxHeight)" /><xsl:text>){5}{%
2029     \multiput(</xsl:text><xsl:value-of select="$resultBoxWidth" /><xsl:text>,0)(</xsl:text><xsl:value-of select="2 * number($resultBoxWidth)" /><xsl:text>,0){3}{%
2030       \lightgraybox{</xsl:text><xsl:value-of select="$resultBoxWidth" /><xsl:text>}{</xsl:text><xsl:value-of select="$resultBoxHeight" /><xsl:text>}%
2031     }%
2032   }
2033   \multiput(</xsl:text><xsl:value-of select="$resultBoxesX" /><xsl:text>,</xsl:text><xsl:value-of select="number($resultBoxesY) + number($resultBoxHeight)" /><xsl:text>)(0,</xsl:text><xsl:value-of select="2 * number($resultBoxHeight)" /><xsl:text>){5}{%
2034     \multiput(0,0)(</xsl:text><xsl:value-of select="2 * number($resultBoxWidth)" /><xsl:text>,0){4}{%
2035       \lightgraybox{</xsl:text><xsl:value-of select="$resultBoxWidth" /><xsl:text>}{</xsl:text><xsl:value-of select="$resultBoxHeight" /><xsl:text>}%
2036     }%
2037   }
2038
2039   %% combat ratio boxes %%
2040   \multiput(</xsl:text><xsl:value-of select="number($combatRatioBoxesX) + number($combatRatioBoxWidth)" /><xsl:text>,</xsl:text><xsl:value-of select="$combatRatioBoxesTopY" /><xsl:text>)(</xsl:text><xsl:value-of select="2 * number($combatRatioBoxWidth)" /><xsl:text>,0){3}{%
2041     \lightgraybox{</xsl:text><xsl:value-of select="$combatRatioBoxWidth" /><xsl:text>}{</xsl:text><xsl:value-of select="$combatRatioBoxHeight" /><xsl:text>}%
2042   }
2043   \multiput(</xsl:text><xsl:value-of select="$combatRatioBoxesX" /><xsl:text>,</xsl:text><xsl:value-of select="$combatRatioBoxesBottomY" /><xsl:text>)(</xsl:text><xsl:value-of select="2 * number($combatRatioBoxWidth)" /><xsl:text>,0){4}{%
2044     \lightgraybox{</xsl:text><xsl:value-of select="$combatRatioBoxWidth" /><xsl:text>}{</xsl:text><xsl:value-of select="$combatRatioBoxHeight" /><xsl:text>}%
2045   }
2046
2047   %% lines %%
2048   \put(</xsl:text><xsl:value-of select="$combatRatioBoxesX" /><xsl:text>,</xsl:text><xsl:value-of select="$combatRatioBoxesBottomY" /><xsl:text>){%
2049     \line(1,0){</xsl:text><xsl:value-of select="7 * number($combatRatioBoxWidth)" /><xsl:text>}%
2050   }
2051   \multiput(</xsl:text><xsl:value-of select="$randomNumberBoxesLeftX" /><xsl:text>,</xsl:text><xsl:value-of select="$randomNumberBoxesY" /><xsl:text>)(0,</xsl:text><xsl:value-of select="$randomNumberBoxHeight" /><xsl:text>){11}{%
2052     \line(1,0){</xsl:text><xsl:value-of select="2 * number($randomNumberBoxWidth) + 7 * number($resultBoxWidth)" /><xsl:text>}%
2053   }
2054   \multiput(</xsl:text><xsl:value-of select="$resultBoxesX" /><xsl:text>,</xsl:text><xsl:value-of select="number($resultBoxesY) + number($resultBoxHeight) div 2" /><xsl:text>)(0,</xsl:text><xsl:value-of select="$resultBoxHeight" /><xsl:text>){10}{%
2055     \line(1,0){</xsl:text><xsl:value-of select="7 * number($resultBoxWidth)" /><xsl:text>}%
2056   }
2057   \put(</xsl:text><xsl:value-of select="$combatRatioBoxesX" /><xsl:text>,</xsl:text><xsl:value-of select="number($combatRatioBoxesTopY) + number($combatRatioBoxHeight)" /><xsl:text>){%
2058     \line(1,0){</xsl:text><xsl:value-of select="7 * number($combatRatioBoxWidth)" /><xsl:text>}%
2059   }
2060
2061   \put(</xsl:text><xsl:value-of select="$randomNumberBoxesLeftX" /><xsl:text>,</xsl:text><xsl:value-of select="$randomNumberBoxesY" /><xsl:text>){%
2062     \line(0,1){</xsl:text><xsl:value-of select="10 * number($randomNumberBoxHeight)" /><xsl:text>}%
2063   }
2064   \multiput(</xsl:text><xsl:value-of select="$combatRatioBoxesX" /><xsl:text>,</xsl:text><xsl:value-of select="$combatRatioBoxesBottomY" /><xsl:text>)(</xsl:text><xsl:value-of select="$combatRatioBoxWidth" /><xsl:text>,0){8}{%
2065     \line(0,1){</xsl:text><xsl:value-of select="2 * number($combatRatioBoxHeight) + 10 * number($randomNumberBoxHeight)" /><xsl:text>}%
2066   }
2067   \put(</xsl:text><xsl:value-of select="number($randomNumberBoxesRightX) + number($randomNumberBoxWidth)" /><xsl:text>,</xsl:text><xsl:value-of select="$randomNumberBoxesY" /><xsl:text>){%
2068     \line(0,1){</xsl:text><xsl:value-of select="10 * number($randomNumberBoxHeight)" /><xsl:text>}%
2069   }</xsl:text>
2070   <xsl:value-of select="$newparagraph" />
2071
2072   <xsl:text>  %% random numbers %%</xsl:text>
2073   <xsl:value-of select="$newline" />
2074   <!-- xsltproc does not understand select="1 to 10"; so we abuse the fact that the
2075        <tbody> element contains more than 10 <tr> elements. -->
2076   <xsl:for-each select="data/illustration/instance[@class='text']/table/tbody/tr">
2077     <xsl:if test="position() &lt; 11">
2078       <xsl:text>  \multiput(</xsl:text><xsl:value-of select="number($randomNumberBoxesLeftX) + number($randomNumberBoxWidth) div 2" /><xsl:text>,</xsl:text><xsl:value-of select="number($randomNumberBoxesY) + ( 10.5 - position() ) * number($randomNumberBoxHeight)" /><xsl:text>)(</xsl:text><xsl:value-of select="number($randomNumberBoxWidth) + 7 * number($resultBoxWidth)" /><xsl:text>,0){2}{\makebox(0,0){\bfseries </xsl:text><xsl:value-of select="position() mod 10" /><xsl:text>}}</xsl:text>
2079       <xsl:value-of select="$newline" />
2080     </xsl:if>
2081   </xsl:for-each>
2082   <xsl:value-of select="$newline" />
2083
2084   <xsl:text>  %% combat ratios %%</xsl:text>
2085   <xsl:value-of select="$newline" />
2086   <xsl:for-each select="exslt:node-set($colHeaders)/*">
2087     <xsl:text>  \multiput(</xsl:text><xsl:value-of select="number($combatRatioBoxesX) + ( position() - 0.5 ) * number($combatRatioBoxWidth)" /><xsl:text>,</xsl:text><xsl:value-of select="number($combatRatioBoxesBottomY) + number($combatRatioBoxHeight) div 2" /><xsl:text>)(0,</xsl:text><xsl:value-of select="10 * number($resultBoxHeight) + number($combatRatioBoxHeight)" /><xsl:text>){2}{%</xsl:text>
2088     <xsl:value-of select="$newline" />
2089     <xsl:text>    \makebox(0,0){</xsl:text><xsl:value-of select="." /><xsl:text>}%</xsl:text>
2090     <xsl:value-of select="$newline" />
2091     <xsl:text>  }</xsl:text>
2092     <xsl:value-of select="$newline" />
2093   </xsl:for-each>
2094   <xsl:value-of select="$newline" />
2095
2096   <xsl:text>  %% E &amp; LW %%</xsl:text>
2097   <xsl:value-of select="$newline" />
2098   <xsl:text>  \multiput(</xsl:text><xsl:value-of select="$resultBoxesX" /><xsl:text>,</xsl:text><xsl:value-of select="$resultBoxesY" /><xsl:text>)(0,</xsl:text><xsl:value-of select="$resultBoxHeight" /><xsl:text>){10}{%
2099     \multiput(0,0)(</xsl:text><xsl:value-of select="$resultBoxWidth" /><xsl:text>,0){7}{%
2100       \makebox(0,</xsl:text><xsl:value-of select="number($resultBoxHeight) div 2" /><xsl:text>)[l]{\footnotesize ~</xsl:text><xsl:value-of select="$i18n[@src='LW']" /><xsl:text>}%
2101     }%
2102   }
2103   \multiput(</xsl:text><xsl:value-of select="$resultBoxesX" /><xsl:text>,</xsl:text><xsl:value-of select="number($resultBoxesY) + number($resultBoxHeight) div 2" /><xsl:text>)(0,</xsl:text><xsl:value-of select="$resultBoxHeight" /><xsl:text>){10}{%
2104     \multiput(0,0)(</xsl:text><xsl:value-of select="$resultBoxWidth" /><xsl:text>,0){7}{%
2105       \makebox(0,</xsl:text><xsl:value-of select="number($resultBoxHeight) div 2" /><xsl:text>)[l]{\footnotesize ~</xsl:text><xsl:value-of select="$i18n[@src='E (abbr. of Enemy EP loss)']" /><xsl:text>}%
2106     }%
2107   }</xsl:text>
2108   <xsl:value-of select="$newparagraph" />
2109
2110   <xsl:text>  %% losses %%</xsl:text>
2111   <xsl:value-of select="$newline" />
2112   <xsl:for-each select="data/illustration/instance[@class='text']/table/tbody/tr">
2113     <!-- the actual data is in row 3..12 -->
2114     <xsl:variable name="row" select="position() - 2" />
2115     <xsl:for-each select="./td">
2116       <xsl:if test="position() = 1">
2117         <xsl:text>  %% row </xsl:text><xsl:value-of select="$row" /><xsl:text> %%</xsl:text>
2118         <xsl:value-of select="$newline" />
2119       </xsl:if>
2120       <xsl:if test="position() &gt;= number($startCol) and position() &lt;= number($endCol)">
2121         <xsl:variable name="col" select="position() - number($startCol) + 1" />
2122         <xsl:variable name="losses"><xsl:value-of select="." /></xsl:variable>
2123         <xsl:variable name="lossE" select="substring-before($losses,'/')" />
2124         <xsl:text>  \put(</xsl:text><xsl:value-of select="number($resultBoxesX) + number($col) * number($resultBoxWidth)" /><xsl:text>,</xsl:text><xsl:value-of select="number($resultBoxesY) + ( 10.5 - number($row) ) * number($resultBoxHeight)" /><xsl:text>){\makebox(0,</xsl:text><xsl:value-of select="number($resultBoxHeight) div 2" /><xsl:text>)[r]{\footnotesize </xsl:text>
2125         <xsl:choose>
2126           <xsl:when test="$lossE='k'">
2127             <xsl:value-of select="$i18n[@src='K (abbr. of Automatic Kill)']" />
2128           </xsl:when>
2129           <xsl:otherwise>
2130             <xsl:value-of select="$lossE" />
2131           </xsl:otherwise>
2132         </xsl:choose>
2133         <xsl:text>~}}</xsl:text>
2134         <xsl:value-of select="$newline" />
2135         <xsl:variable name="lossLW" select="substring-after($losses,'/')" />
2136         <xsl:text>  \put(</xsl:text><xsl:value-of select="number($resultBoxesX) + number($col) * number($resultBoxWidth)" /><xsl:text>,</xsl:text><xsl:value-of select="number($resultBoxesY) + ( 10 - number($row) ) * number($resultBoxHeight)" /><xsl:text>){\makebox(0,</xsl:text><xsl:value-of select="number($resultBoxHeight) div 2" /><xsl:text>)[r]{\footnotesize </xsl:text>
2137         <xsl:choose>
2138           <xsl:when test="$lossLW='k'">
2139             <xsl:text>K</xsl:text>
2140           </xsl:when>
2141           <xsl:otherwise>
2142             <xsl:value-of select="$lossLW" />
2143           </xsl:otherwise>
2144         </xsl:choose>
2145         <xsl:text>~}}</xsl:text>
2146         <xsl:value-of select="$newline" />
2147       </xsl:if>
2148     </xsl:for-each>
2149   </xsl:for-each>
2150
2151   <xsl:text>\end{picture}
2152 \end{center}
2153 \vspace*{\stretch{1}}</xsl:text>
2154   <xsl:value-of select="$newline" />
2155   <xsl:text>\setlength{\unitlength}{1pt}</xsl:text>
2156   <xsl:value-of select="$newparagraph" />
2157
2158 </xsl:template>
2159
2160 </xsl:transform>