Debian Codegraph @

docs/formatting.xml

raw
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3 "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
4
5 <section>
6 <title>Correcting Poor Formatting</title>
7
8 <para>LaTeX does not invariably produce good looking output. To
9 remedy this it can sometimes be useful to guide LaTeX in the
10 formatting of individual characters, words, sentences, and pages.
11 It is best to adjust with caution, making adjustments only to fix
12 specific problems and limiting adjustments to the affected
13 area.</para>
14
15 <tip>
16 <para>Adjustments to formatting are best done late in the
17 production process so that subsequent changes to content do not
18 produce new problems.</para>
19 </tip>
20
21 <para>This section provides an overview of common problems and
22 summarizes methods which may be used to resolve issues related to
23 formatting. Much more detail can be found in the <xref
24 linkend="sec-custom"/> chapter and the <xref linkend="sec-params"/>
25 and <xref linkend="sec-pis"/> appendixes. Be sure to look through
26 these, especially the appendixes, to see whether there is an
27 adjustment which will solve your particular problem. Of course the
28 DocBook documentation should also be consulted to see if a DocBook
29 attribute can be used to adjust document presentation.</para>
30
31 <section>
32 <title>Floats</title>
33
34 <para>Floats are figures, tables, examples, images, and so forth
35 which do not necessarily appear in the output document in the
36 location in which they appear in the DocBook source. The
37 placement of floats can result in visually poor or otherwise
38 undesirable output.</para>
39
40 <para>One direct approach is to use the <quote>informal</quote>
41 versions of the affected DocBook elements. E.g. use
42 <sgmltag>informaltable</sgmltag> instead of
43 <sgmltag>table</sgmltag>. The <quote>informal</quote> elements do
44 not float. Bear in mind though that <quote>informal</quote>
45 elements do not appear in the table of contents.</para>
46
47 <para>The alternative to eliminating the float entirely is
48 to make an adjustment by parameter, attributes, or processing
49 instruction. For figure, example, and equation, you can play
50 with these methods:</para>
51
52 <itemizedlist>
53 <listitem><para>In a specific element, use the
54 <sgmltag>floatstyle</sgmltag> attribute to
55 specify the latex float placement policy. For example
56 <literal>'[H]'</literal> tries to place the element where it is
57 declared.</para></listitem>
58
59 <listitem><para>Use the parameter
60 <literal><replaceable>element</replaceable>.defaut.position</literal>
61 to specify globaly the placement policy for this element.</para>
62 </listitem>
63 </itemizedlist>
64
65 <para>Look at page <xref xrefstyle="template:%p"
66 linkend="float-placement-choices"/> for more details
67 about the meaning of the placement choice letters.</para>
68 </section>
69
70 <section>
71 <title>Tables</title>
72
73 <para>Placement problems with tables relate to their
74 classification as a float. For resolution regarding these issues
75 see the section on floats above.</para>
76
77 <para>Tables exceeding the length of a page, or tables that
78 otherwise need to cross page boundaries, have special
79 requirements. They must not be floats and must be rendered using
80 the LaTeX <package>longtable</package> environment. Among the
81 available controls are: use of a <sgmltag>informaltable</sgmltag>
82 element in place of a <sgmltag>table</sgmltag> element, the
83 <sgmltag>table</sgmltag> element's <sgmltag>tabstyle</sgmltag>
84 attribute, the <parameter>table.default.tabstyle</parameter> parameter,
85 the <parameter>table.in.float</parameter> parameter<!--, and the <xref
86 linkend="dblatex_table-in-float"/> PI-->.</para>
87
88 <para>It is worth mentioning that good typesetting design practice
89 for tables generally calls for eliminating all vertical rules (the
90 lines between columns) and most horizontal rules.</para>
91
92 <para><?latex-block sloppy="1"?>Better vertical placement of
93 table horizontal rules can be obtained by providing values for
94 the <parameter>newtbl.format.thead</parameter> and
95 <parameter>newtbl.format.tbody</parameter> parameters. Depending on the
96 font in use, a value like
97 <literal>\rule{0pt}{2.6ex}\rule[-0.9ex]{0pt}{0pt}</literal> can be
98 used for both parameters. This inserts a
99 <wordasword>strut</wordasword>, a 0 width character, in each row
100 of the table which <quote>pushes</quote> the horizontal rules
101 upwards and downwards to provide adequate vertical spacing.</para>
102 </section>
103
104 <section>
105 <title>Examples</title>
106
107 <para>Placement of examples has the same issue than tables, that is, it
108 is an element that can contain many materials and need to split over
109 several pages. In this case it cannot be considered as a float.</para>
110
111 <para>To avoid an example floating and to allow it cover several
112 pages, set the parameter <parameter>example.float.type</parameter>
113 to <literal>none</literal>.</para>
114 </section>
115
116 <section>
117 <title>Hyphenation and over-long lines</title>
118
119 <para>LaTeX is generally very good at hyphenation, but this
120 applies only to actual words. Technical writing may include long
121 character sequences that are not actual words. Hyphenation
122 failure will typically result in lines of text that flow past the
123 expected right-hand edge of a line. In LaTeX terminology this is
124 known as a <quote>overfull hbox</quote>.</para>
125
126 <para>The <parameter>hyphenation.format</parameter> parameter can
127 be helpful to flag some formats for more agressive
128 hyphenation.</para>
129
130 <para>Various adjustments can be made with the
131 <sgmltag class="xmlpi">latex</sgmltag> processing instruction to
132 add raw latex directives and eliminate
133 overfull hboxes but it often makes sense to address hyphenation
134 problems directly. This can be done either on an ad-hoc basis,
135 telling LaTeX how to hyphenate specific occurrences of words where
136 a problem exists, or by telling LaTeX how to hyphenate words it
137 does not know. The first method is accomplished by inserting
138 <quote>soft hyphens</quote> into words in your DocBook source
139 using the <xref linkend="pi-latex"/> processing instruction. This is
140 described in the <xref linkend="sec-safe-latex"/> section.</para>
141
142 <para>To educate LaTeX as to how to hyphenate your special
143 vocabulary a custom LaTeX style is required. Setting this up is
144 described in the <xref linkend="sec-custom-latex"/> section. The
145 LaTeX command to use is <code>\hyphenation</code>. For example
146 <code>\hyphenation{PostgreSQL trans-mog-re-fi-ca-tion}</code>
147 tells LaTeX that <wordasword>PostgreSQL</wordasword> should not be
148 hyphenated and where to hyphenate
149 <wordasword>transmogrification</wordasword>.</para>
150
151 <para>Finally, long URLs can cause over-long lines. Especially in
152 footnotes. Using the LaTeX <package>breakurl</package> package is
153 one way to solve this. This can be done with a custom latex
154 stylesheet. See <xref linkend="sec-custom-latex"/>.</para>
155 </section>
156
157 <!-- latex-block not yet provided
158 <section>
159 <title>Paragraphs, Lines, and Sentences</title>
160
161 <para>Widows and orphans, single (or too few) lines at the top and
162 bottom of pages, can be controlled with the <xref
163 linkend="latex-block"/> processing instruction.</para>
164
165 <para>Lines can grow longer than their normal right-hand boundary.
166 This is generally due to problems with hyphenation. Hyphenation
167 problems can arise in various ways, e.g. the introduction of
168 hyperlinks which do not hyphenate. Sometimes hyphenation cannot
169 or should not be changed. In these situations the <xref
170 linkend="latex-block"/> processing instruction can be used to
171 prevent poorly formatted lines. It provides controls which
172 affect, among other things, the placement of line breaks.</para>
173
174 <para>The <xref linkend="latex.frenchspacing"/> parameter controls
175 spacing between sentences. A <quote>safe</quote> <xref
176 linkend="latex"/> processing instruction
177 <parameter>content</parameter> value can, in some cases, provide
178 control over individual instances of this.</para>
179 </section>
180 -->
181
182 <section>
183 <title>Characters and Manual Spacing</title>
184
185 <para>The <sgmltag class="xmlpi">latex</sgmltag> processing instruction
186 may be used to limit character kerning, the joining of pairs of
187 characters.</para>
188
189 <para>The following DocBook entity declarations can be useful to
190 control spacing. These may be declared in your DocBook
191 <code>DTD</code> within the trailing pair of square braces
192 (<literal>[]</literal>) or elsewhere. Once declared the entities
193 may be used in your document text. E.g.
194 <literal>Von&amp;nbsp;Trapp</literal> puts a non-breaking space
195 between <literal>Von</literal> and <literal>Trapp</literal>,
196 ensuring that these two words will not appear on separate
197 lines.</para>
198
199 <programlisting>
200 &lt;!ENTITY nbsp "&amp;#x000A0;" &gt;
201 &lt;!ENTITY ensp "&amp;#x02002;" &gt;
202 &lt;!ENTITY emsp "&amp;#x02003;" &gt;
203 </programlisting>
204 </section>
205 </section>