~ubuntu-branches/ubuntu/wily/dblatex/wily

« back to all changes in this revision

Viewing changes to docs/custom/custom.xml

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Hoenen
  • Date: 2008-08-11 20:28:56 UTC
  • mfrom: (4.1.7 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080811202856-d2qjg24ut53mgufx
Tags: 0.2.9-3
* Improve CJK (Chinese/Japanese/Korean) support:
  + Let XSL configuration parameter cjk.font default to gkai (instead of the
    cyberbit font not included in Debian).
  + Add Suggests dependency on latex-cjk-all for the gkai fonts.
  + Fix the db2latex style not to collide with the CJKutf8.sty file.
  Thanks to W. Martin Borgert for reporting and hints.
  Closes: #482857, #492350
* Fix a name clash with TeXLive for spanish documents in native style.
  Thanks to W. Martin Borgert for reporting.  Closes: #492304
* Support underscore characters in xreflabel attributes.  Thanks to
  Sébastien Villemot for reporting.  Closes: #492959

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0" encoding="iso-8859-1"?>
 
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
2
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3
3
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
4
4
 <chapter id="sec-custom">
5
 
  <title>
6
 
  Customization
7
 
 </title>
 
5
  <title>Customization</title>
8
6
 <para>
9
7
  The transformation process (and thus the output rendering) can be heavily customized by:
10
8
 </para>
11
9
 <itemizedlist>
12
10
  <listitem>
13
11
  <para>
14
 
  using a configuration stylesheet,
15
 
  </para>
16
 
 </listitem>
17
 
  <listitem>
18
 
  <para>
19
 
  using customized stylesheets,
20
 
  </para>
21
 
 </listitem>
22
 
  <listitem>
23
 
  <para>
24
 
  using a customized LaTeX style package.
 
12
  using some <link linkend="sec-param">configuration parameters</link> either in
 
13
  a <link linkend="sec-param-stylesheet">configuration stylesheet</link> or directly
 
14
  from the <link linkend="sec-param-value">command line</link>,
 
15
  </para>
 
16
 </listitem>
 
17
  <listitem>
 
18
  <para>
 
19
  using some <link linkend="sec-custom-stylesheet">customized stylesheets</link>,
 
20
  </para>
 
21
 </listitem>
 
22
  <listitem>
 
23
  <para>
 
24
  using a <link linkend="sec-custom-latex">customized LaTeX style package</link>.
25
25
  </para>
26
26
 </listitem>
27
27
  <listitem>
33
33
 <para>
34
34
  All these customization methods can be used independently and in exceptional cases, but it can also be combined and registered in a master configuration file, called a specification file (cf. <xref linkend="sec-specs"/>) to create a new tool dedicated to your needs.
35
35
 </para>
36
 
  <sect1 id="sec-param">
37
 
   <title>
38
 
   Configuration Parameter Stylesheet
39
 
  </title>
 
36
  <section id="sec-param">
 
37
   <title>XSL Parameters</title>
40
38
  <para>
41
 
   The PDF rendering can be customised by using an XSL configuration stylesheet. The configuration file is specified by using the option <option>-p <replaceable>custom.xsl</replaceable></option>. The available configuration parameters are the following:
 
39
   The PDF rendering can be customised by using some XSL configuration parameters.
 
40
   The available configuration parameters are the following:
42
41
  </para>
43
42
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="param.xml"/>
44
 
   <sect2 id="sec-defaultscale">
 
43
   <section id="sec-defaultscale">
45
44
    <title>imagedata.default.scale</title>
46
45
    <para>Default scale to apply to every <sgmltag>imagedata</sgmltag> that does not
47
46
contain any scaling attribute.</para>
60
59
</para>
61
60
<para>Except these special reserved values, the expected value of the parameter
62
61
must be some valid options passed to the \includegraphics command.</para>
63
 
</sect2>
64
 
   <sect2 id="sec-hyperparam">
65
 
    <title>
66
 
    latex.hyperparam
67
 
   </title>
 
62
</section>
 
63
   <section id="sec-hyperparam">
 
64
    <title>latex.hyperparam</title>
68
65
   <para>
69
66
    This parameter gives the options to pass to the LaTeX hyperref package. No validity check is done. 
70
67
   </para>
83
80
]]><![CDATA[</xsl:stylesheet>
84
81
]]>   </programlisting>
85
82
</example>
86
 
  </sect2>
87
 
  </sect1>
88
 
  <sect1 id="sec-param-value"><title>Setting Parameter values</title>
89
 
  <para>It is possible to set some XSL parameter values directly from the command
90
 
  line without creating a configuration parameter stylesheet, by using the
 
83
  </section>
 
84
  </section>
 
85
 
 
86
<section id="sec-param-value"><title>Setting Command line Parameters</title>
 
87
  <para>You can set some XSL parameters directly from the command
 
88
  line without creating a configuration parameter stylesheet, with the
91
89
  <option>-P <replaceable>parameter=value</replaceable></option> option.</para>
92
90
  <para>The following example set the latex.hyperparam parameter value:
93
91
   <programlisting>
94
92
<![CDATA[  dblatex -P latex.hyperparam=colorlinks,linkcolor=blue myfile.xml
95
93
]]></programlisting>
96
94
  </para>
97
 
  </sect1>
98
 
  <sect1>
99
 
   <title>
100
 
   Customized stylesheets
101
 
  </title>
102
 
  <para>
103
 
   If one needs to change some of the translations done by the XSL stylesheets, it is possible to provide user stylesheets to override the templates. To do this, write the stylesheets (e.g. mystyle.xsl) and include them in the configuration file such as shown by the following example.
104
 
  </para>
105
 
<example><title>Using a customized stylesheet in a configuration file</title>
 
95
</section>
 
96
 
 
97
<section>
 
98
<title>XSL User Stylesheet</title>
 
99
  <para>You can provide your own XSL stylesheet to set some of the XSL parameters,
 
100
  and/or to override some of the dblatex XSL templates. The user stylesheet is
 
101
  specified by using the option
 
102
  <option>-p <replaceable>custom.xsl</replaceable></option>.</para>
 
103
 
 
104
<section id="sec-param-stylesheet">
 
105
<title>Changing the XSL parameter values</title>
 
106
  <para>
 
107
   The parameters can be stored in a user defined XSL stylesheet. An example of
 
108
   configuration stylesheet is given with this manual:
 
109
  </para>
 
110
  <programlisting><textobject><textdata
 
111
  fileref="myparam.xsl"/></textobject></programlisting>
 
112
  </section>
 
113
  <section id="sec-custom-stylesheet">
 
114
   <title>Overriding some templates</title>
 
115
  <para>
 
116
   You can directly put the overriding templates in your XSL stylesheet, but do not
 
117
   try to import the default dblatex stylesheets in it: it is automatically done by
 
118
   the tool. So, just focus on the template to override and dblatex will ensure
 
119
   that your definitions will get precedence over the dblatex ones.
 
120
  </para>
 
121
  <para>
 
122
  You can of course split your templates in several files, and import each of
 
123
  them in the main user stylesheet by calling <literal>xsl:import</literal>.
 
124
  </para>
 
125
<example><title>Overriding templates</title>
106
126
  <programlisting>
107
127
<![CDATA[<?xml version='1.0' encoding="iso-8859-1"?>
108
 
]]><![CDATA[<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
109
 
]]><![CDATA[ 
110
 
]]><![CDATA[<!-- Let's import our own XSL to override the default behaviour. 
111
 
]]><![CDATA[ -->
112
 
]]><![CDATA[<xsl:import href="mystyle.xsl"/>
113
 
]]><![CDATA[
114
 
]]><![CDATA[</xsl:stylesheet>
 
128
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
 
129
 
 
130
<!-- Let's import our own XSL to override the default behaviour. -->
 
131
<xsl:import href="mystyle.xsl"/>
 
132
 
 
133
<!-- Let's patch directly a template here -->
 
134
<xsl:template match="article" mode="docinfo">
 
135
  <xsl:apply-imports/>
 
136
  <xsl:text>\let\mymacro=\DBKrelease</xsl:text>
 
137
</xsl:template>
 
138
 
 
139
</xsl:stylesheet>
115
140
]]>  </programlisting>
116
141
</example>
117
 
  </sect1>
118
 
  <sect1 id="sec-custom-latex">
119
 
   <title>
120
 
   Customized LaTeX style
121
 
  </title>
 
142
  </section>
 
143
  </section>
 
144
  <section id="sec-custom-latex">
 
145
   <title>Customized LaTeX style</title>
122
146
  <para>
123
147
   The actual output rendering is done by the latex style package used, and not by the XSL stylesheets whose role is only to translate to latex. Users can provide their own LaTeX style file, in respect of some rules:
124
148
  </para>
140
164
  </listitem>
141
165
  </itemizedlist>
142
166
  <para>
143
 
   The latex style file to use is specified by using the option <option>--style <replaceable>latex_style</replaceable></option>. An example of a simple LaTeX DocBook style is provided in the package.
 
167
   The latex style file to use is specified by using the option <option>--texstyle <replaceable>latex_style</replaceable></option>. An example of a simple LaTeX DocBook style is provided in the package.
144
168
  </para>
145
 
   <sect2>
146
 
    <title>
147
 
    Package options
148
 
   </title>
 
169
  <para>
 
170
   The <option>--texstyle <replaceable>latex_style</replaceable></option> option
 
171
   accepts a package name (no path and no <filename>.sty</filename> extension) or a
 
172
   full style file path. If a full path is used,
 
173
   the filename must ends with <filename>.sty</filename>.
 
174
   </para>
 
175
   <programlisting>
 
176
# Give a package name and assume its path is already in TEXINPUTS
 
177
dblatex --texstyle=mystyle file.xml
 
178
 
 
179
# Give the full package path. The TEXINPUTS is then updated by dblatex
 
180
dblatex --texstyle=./mystyle.sty file.xml
 
181
</programlisting>
 
182
<section><title>Reusing an existing LaTeX style</title>
 
183
<para>You can either create your latex style from scratch, in respect of the
 
184
interfaces described in the following sections, or you can simply reuse an
 
185
already existing style and override what you want. The latter method is easier
 
186
for small things to change.</para>
 
187
<para>Here is an example of a style package reusing the default docbook
 
188
style:</para>
 
189
<example><title>Reused LaTeX style</title>
 
190
<programlisting><textobject><textdata fileref="mystyle.sty"/></textobject>
 
191
</programlisting>
 
192
</example>
 
193
</section>
 
194
   <section>
 
195
    <title>Package options</title>
149
196
   <para>A compliant LaTeX style package supports the following options. The options are
150
197
   provided by the XSL stylesheets according to the document attributes.</para>
151
198
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="styoption.xml"/>
152
 
   </sect2>
153
 
   <sect2>
154
 
    <title>
155
 
    Needed packages
156
 
   </title>
 
199
   </section>
 
200
   <section>
 
201
    <title>Needed packages</title>
157
202
   <para>A LaTeX style package must at least include the following packages.</para>
158
203
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="stypackage.xml"/>
159
 
   </sect2>
160
 
   <sect2>
161
 
    <title>
162
 
    DocBook interface
163
 
   </title>
 
204
   </section>
 
205
   <section>
 
206
    <title>DocBook interface</title>
164
207
   <para>
165
208
    All the latex commands beginning with DBK are related to elements under <sgmltag>bookinfo</sgmltag> or <sgmltag>articleinfo</sgmltag>.
166
209
   </para>
167
210
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="stycommand.xml"/>
168
 
   </sect2>
 
211
   </section>
169
212
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="stydebug.xml"/>
170
 
  </sect1>
171
 
  <sect1>
172
 
   <title>
173
 
   Latex post process script
174
 
  </title>
 
213
  </section>
 
214
  <section id="sec-texpost">
 
215
   <title>Latex post process script</title>
175
216
  <para>
176
217
   Extra user actions can be processed on the latex file produced by the XSL stylesheets or on its temporary working files produced by the latex compilation. 
177
218
  </para>
181
222
  <para>
182
223
   The post process script is called just before the last latex compilation, and takes one parameter, the latex file compiled by the tool.
183
224
  </para>
184
 
  </sect1>
185
 
  <sect1 id="sec-specs">
186
 
   <title>
187
 
   Specification file
188
 
  </title>
189
 
  <para>
190
 
   A master configuration file, also called a specification file, can be defined to list all the customizations and options to apply. Such a file is passed by using the option <option>-S <replaceable>specs</replaceable></option>.
191
 
  </para>
 
225
  <section><title>Post latex compilations</title>
 
226
  <para>
 
227
   The latex compilations done once the script is called depend on the return code
 
228
   of the script:
 
229
  <itemizedlist>
 
230
   <listitem>
 
231
   <para>
 
232
   When the return code is 0, <command>dblatex</command> continues the
 
233
   compilation as many times as necessary.
 
234
   </para>
 
235
  </listitem>
 
236
   <listitem>
 
237
   <para>
 
238
   When the return code is 1, no more compilation is done by dblatex.
 
239
   This case is useful
 
240
   if the script needs to control precisely the number of compilation to apply.
 
241
   It is up to the script to perform the expected compilations.</para>
 
242
   <para>To do so, the script can retrieve in the <envar>LATEX</envar> environment
 
243
   variable the actual compiler used by <command>dblatex</command>.
 
244
   </para>
 
245
  </listitem>
 
246
   <listitem>
 
247
   <para>
 
248
   When the return code is another value, an error is raised to signal
 
249
   a failed post process script execution.
 
250
   </para>
 
251
  </listitem>
 
252
  </itemizedlist>
 
253
  </para>
 
254
  </section>
 
255
  </section>
 
256
  <section id="sec-specs">
 
257
   <title>Dblatex Configuration File</title>
 
258
  <para>
 
259
   A master configuration file, also called a specification file, can be used to list
 
260
   all the customizations and options to apply. Such a file is passed by using the
 
261
   option <option>-S <replaceable>config_file</replaceable></option>.
 
262
  </para>
 
263
  <section><title>Configuration File Format</title>
192
264
  <para>
193
265
   The format of the file is the following:
194
266
  </para>
234
306
  <para>
235
307
   Here is the specification file used for this manual.
236
308
  </para>
237
 
<example><title>Specification file example</title>
 
309
<example><title>User Manual Configuration File</title>
238
310
<programlisting><textobject><textdata fileref="manual.specs"/></textobject>
239
311
</programlisting>
240
312
</example>
241
 
  </sect1>
242
 
  <sect1>
243
 
   <title>
244
 
   Customization order
245
 
  </title>
 
313
  </section>
 
314
  <section id="sec-conf-path"><title>Configuration Paths</title>
 
315
  <para>By default <command>dblatex</command> tries to find the configuration files
 
316
  in the following paths, in respect of the order:</para>
 
317
  <orderedlist>
 
318
  <listitem><para>The current directory</para></listitem>
 
319
  <listitem><para><filename>$HOME/.dblatex</filename></para></listitem>
 
320
  <listitem><para><filename>/etc/dblatex</filename></para></listitem>
 
321
  <listitem><para>The dblatex package configuration directories.</para></listitem>
 
322
  </orderedlist>
 
323
  <para>You can add some extra paths where to look for by setting the
 
324
  <envar>DBLATEX_CONFIG_FILES</envar> environment variable. The paths are
 
325
  separated by ":" in Unix like systems, and by ";" on Windows. These paths are used
 
326
  only when nothing is found in the default paths.</para>
 
327
  </section>
 
328
  </section>
 
329
  <section>
 
330
   <title>Customization Precedence</title>
246
331
  <para>
247
332
   All the customization queries are translated to the corresponding command line options. Thus, using several customization methods can be unconsistent because each of them override the same option with another value. 
248
333
  </para>
249
334
  <para>
250
 
   For instance, you can specify the use of a specification file in which it is said to use a latex style (parameter TexStyle) and explicitely use the <option>--style</option> command line option. So, what is the behaviour?
 
335
   For instance, you can specify the use of a specification file in which it is said to use a latex style (parameter TexStyle) and explicitely use the <option>--texstyle</option> command line option. So, what is the behaviour?
251
336
  </para>
252
337
  <para>
253
338
   The options order is the following:
269
354
   </para>
270
355
  </listitem>
271
356
  </itemizedlist>
272
 
<example><title>Customization order</title>
 
357
<example><title>Customization Precedence</title>
273
358
  <para>
274
359
   Let's consider the specification file containing the following parameters:
275
360
  </para>
282
367
   And now the command line:
283
368
  </para>
284
369
  <programlisting>
285
 
<![CDATA[dblatex -b dvips -p file1.xsl -p file2.xsl -S file.specs --style mystyle2 mydoc.sgml
 
370
<![CDATA[dblatex -b dvips -p file1.xsl -p file2.xsl -S file.specs -s mystyle2 mydoc.xml
286
371
]]>  </programlisting>
287
372
  <para>
288
373
   The setting used is the following:
300
385
  </listitem>
301
386
   <listitem>
302
387
   <para>
303
 
   &ldquo;--style mystyle2&rdquo; override &ldquo;mystyle1&rdquo; set by the spec file.
 
388
   &ldquo;-s mystyle2&rdquo; override &ldquo;mystyle1&rdquo; set by the spec file.
304
389
   </para>
305
390
  </listitem>
306
391
  </itemizedlist>
307
392
</example>
308
 
  </sect1>
 
393
  </section>
309
394
 </chapter>