Debian Codegraph @

docs/user/latex.rst

raw
1 .. include:: ../header.rst
2
3 ================================
4 Generating LaTeX with Docutils
5 ================================
6
7 :Author: Engelbert Gruber, Günter Milde
8 :Contact: [email protected]
9 :Revision: $Revision: 10331 $
10 :Date: $Date: 2026-05-08 16:57:28 +0200 (Fr, 08. Mai 2026) $
11 :Copyright: This document has been placed in the public domain.
12 :Abstract: This document covers topics specific to Docutils' LaTeX_ export.
13
14 .. contents::
15 .. sectnum::
16
17
18 LaTeX
19 =====
20
21 LaTeX__, is a document preparation system for high-quality typesetting. It
22 is most often used for medium-to-large technical or scientific documents but
23 it can be used for almost any form of publishing. There exists a wide
24 selection of `LaTeX Documentation on the net`_ and `books on LaTeX and
25 related topics`_. For an introduction to LaTeX see, e.g., `LaTeX2e for
26 authors` [usrguide]_.
27
28 __ https://www.latex-project.org/
29 .. _LaTeX Documentation on the net: https://www.latex-project.org/guides/
30 .. _books on LaTeX and related topics:
31 https://www.latex-project.org/guides/books.html
32
33 .. _LaTeX packages:
34
35 LaTeX document classes and packages
36 -----------------------------------
37
38 Unlike HTML with CSS, LaTeX uses one common language for markup and style
39 definitions. Separation of content and style is realized by collecting style
40 definitions in LaTeX classes and packages, or the
41 `document preamble <LaTeX preamble_>`_.
42
43 LaTeX document classes and packages (similar to Python modules or C
44 libraries) provide means to extend or modify the LaTeX language by
45 redefining macros or providing new ones.
46
47 Using the `document class`_ and `style sheet`_ configuration settings, you
48 can select from a *huge* selection of classes and packages (standard as well
49 as user contributed) coming with your TeX distribution or available at
50 CTAN_ as well as custom style sheets.
51
52 .. _CTAN: https://www.ctan.org
53
54
55 Docutils specific LaTeX macros
56 ------------------------------
57
58 Some Docutils objects have no LaTeX counterpart, they will be typeset
59 using a Docutils specific LaTeX *macro* (command, environment, or length)
60 to allow customization. By convention, these macros use the prefix
61 ``\DU``\ [#]_.
62 Fallback definitions are included after the `custom style sheets`_,
63 for all macros required in the document. Alternatively, you may list
64 "docutils" in the `stylesheet`_ setting to use the `"docutils" package`_
65 instead.
66
67 * Custom `style sheets`_ can define alternative implementations with
68 ``\newcommand``, ``\newenvironment``, and ``\newlength`` followed by
69 ``\setlength``.
70
71 * Definitions with `raw LaTeX`_ are part of the document body. Use
72 ``\def``, ``\renewcommand`` or ``\renewenvironment``, and ``\setlength``.
73
74 See docutils.sty_ and the test output `standalone_rst_latex.tex`_ for
75 an example of the fallback definitions and their use in the document.
76
77 .. [#] DU for Documentation Utilities = Docutils
78
79 .. _"docutils" package: https://ctan.org/pkg/docutils
80 .. _docutils.sty:
81 https://mirrors.ctan.org/macros/latex/contrib/docutils/docutils.sty.html
82
83
84 .. _length unit:
85
86 Length units
87 ------------
88
89 The LaTeX writer supports all `reStructuredText length units`_
90 with the following peculiarities:
91
92 * In LaTeX, the size of the *pixel unit* defaults to **1 px = 1/72 in**
93 while the `CSS3 pixel unit`_ is defined as 1 px = 1/96 in.
94 The LaTeX conversion factor can be configured,
95 see below for the `size of a "px"`_.
96
97 * LaTeX uses "pt" for the `American point`_ (*TeX point*), 1 pt = 1/72.25 in.
98 The `DTP point`_ (*Postscript point*) used in CSS is available in LaTeX
99 as *big point*, 1 bp = 1/72 in.
100
101 Lengths specified in the source with unit "pt" are written with unit
102 "bp" by the LaTeX writer. In `raw LaTeX`_ and `custom style sheets`_,
103 the `DTP point` must be specified as "bp", while "pt" is interpreted as
104 `TeX point`.
105
106 * The **default length unit** (added by the latex writer to length values
107 without unit) is the `DTP point` "**bp**". It will change to "px" in
108 Docutils 1.0.
109
110 The TeX units:
111
112 .. class:: align-center
113
114 ==== ========================= ===================
115 bp "big" point (`DTP point`) 1 bp = 1/72 in
116 cc cîcero 1 cc = 12 dd
117 dd didôt 1 dd = 1238/1157 pt
118 sp scaled point 1sp = 1/65536pt
119 ==== ========================= ===================
120
121 can be used in `raw LaTeX`_ and `custom style sheets`_ but not in
122 reStructuredText.
123
124 .. _CSS3 pixel unit: https://www.w3.org/TR/css-values-3/#px
125 .. _reStructuredText length units:
126 ../ref/rst/restructuredtext.html#length-units
127 .. _American point:
128 https://en.wikipedia.org/wiki/Point_(typography)#American_points
129 .. _DTP point:
130 https://en.wikipedia.org/wiki/Point_(typography)#Desktop_publishing_point
131
132
133 PDF generation
134 ==============
135
136 In most cases, LaTeX code is not the desired end-format of the document.
137 There are several programs to generate PDF documents from the LaTeX source,
138 including:
139
140 _`pdflatex`
141 Generates a PDF document directly from the LaTeX file.
142 Export your document with the _`LaTeX2e writer` (writer
143 name "``latex``", frontend tool rst2latex_).
144
145 _`xelatex` or _`lualatex`
146 The `XeTeX`_ and LuaTeX_ engines work with input files in UTF-8 encoding
147 and system fonts. Export your document with the _`XeLaTeX writer` (writer
148 name "``xetex``", frontend tool rst2xetex_).
149
150 You may need to call the respective command two or three times
151 to get internal references correct.
152
153 .. _xetex: https://tug.org/xetex/
154 .. _luatex: https://www.luatex.org/
155 .. _rst2latex: tools.html#rst2latex
156 .. _rst2xetex: tools.html#rst2xetex
157
158 _`rubber`
159 The Rubber__ wrapper for LaTeX and friends can be used to automatically
160 run all programs the required number of times and delete "spurious" files.
161 This includes processing bibliographic references or indices, as well as
162 compilation or conversion of figures.
163
164 __ https://gitlab.com/latex-rubber/rubber/
165
166
167 Configuration
168 =============
169
170 .. contents:: :local:
171
172 .. _setting:
173 .. _settings:
174
175 Options/Settings
176 ----------------
177
178 `Docutils configuration settings`_ can be specified as
179 *command-line options* or *configuration settings*.
180
181 Run ``rst2latex --help`` to get a list of available options or
182 see `Docutils Configuration`_ for details.
183
184 .. _Docutils configuration settings:
185 .. _Docutils Configuration: config.html
186
187
188 Classes
189 -------
190
191 The `"classes" attribute`_ is one of the common attributes, shared by all
192 Docutils elements.
193 In HTML, the common use is to provide selection criteria for style rules in
194 CSS stylesheets. As there is no comparable framework for LaTeX, Docutils
195 emulates some of this behaviour via `Docutils specific LaTeX macros`_.
196 Due to LaTeX limitations, class arguments are ignored for
197 some elements (e.g. a rubric_).
198
199 *Inline elements*
200 are handled via the ``\DUrole{}`` macro that calls the optional styling
201 command ``\DUrole«classargument»`` with one argument (the role content).
202 See `custom interpreted text roles`_.
203
204 *Block level elements*
205 are wrapped in "class environments":
206 ``\begin{DUclass}`` calls the optional styling command
207 ``\DUCLASS«classargument»{}``, ``\end{DUclass}`` tries
208 ``\endDUCLASS«classargument»``.
209
210 Customization is done by defining matching macros or environments.
211
212 Example 1:
213 Use small caps font inside elements with class value "custom".
214
215 *Inline elements*
216 The LaTeX function ``\textsc`` sets the argument in small caps::
217
218 \newcommand{\DUrolecustom}[1]{\textsc{#1}}
219
220 *Block-level elements*
221 The LaTeX directive (macro without argument) ``\scshape`` switches to
222 the small caps font. Its effect is confined to the wrapper ``DUclass``
223 environment::
224
225 \newcommand*{\DUCLASScustom}{\scshape}
226
227 Example 2:
228 It is even possible to locally redefine other LaTeX macros, e.g. to
229 turn bullet lists with class value "enumerateitems" into enumerated
230 lists::
231
232 \newcommand*{\DUCLASSenumerateitems}{%
233 \renewenvironment{itemize}{\begin{enumerate}}%
234 {\end{enumerate}}%
235 }
236
237 .. rubric:: Notes
238
239 * Class arguments may contain numbers and hyphens, which need special
240 treatment in LaTeX command names (see `class directive`_). The commands
241 ``\csname`` and ``\endcsname`` or the special command ``\@namedef`` can
242 help with the definition of corresponding macros or environments, e.g.::
243
244 \expandafter\newcommand\csname gg1\endcsname{Definition of gg1.}
245
246 or ::
247
248 \makeatletter
249 \@namedef{DUCLASSadmonition-test}{…}
250 \makeatother
251
252 * Elements can have multiple class arguments. In contrast to HTML/CSS, the
253 order of the class arguments cannot be ignored in LaTeX
254
255 * Class handling differs for some elements and class values:
256
257 * Class argument values starting with ``align-`` are transformed to
258 "align" argument values. Class argument values starting with
259 ``language-`` set the elements language property.
260
261 * The table element recognizes some special class values. See section
262 `table style`_.
263
264 * If the legacy-class-functions_ setting is True, the special macros
265 ``\DUadmonition`` and ``\DUtitle`` are written with a comma separated
266 list of class values as optional argument.
267
268 .. _"classes" attribute: ../ref/doctree.html#classes
269 .. _legacy-class-functions: config.html#legacy-class-functions
270
271 LaTeX code
272 ----------
273
274 Custom LaTeX code can be placed in `style sheets`_, the
275 `LaTeX preamble`_, the document body (`raw LaTeX`_), or custom templates_.
276
277 The functional tests that come with Docutils, can serve as example.
278
279 input:
280 standalone_rst_latex.rst_ (includes files from `tests/functional/input/data`_)
281 expected output:
282 standalone_rst_latex.tex_
283
284 .. _standalone_rst_latex.rst:
285 https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/test/functional/input/standalone_rst_latex.rst
286 .. _tests/functional/input/data:
287 https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/test/functional/input/data
288 .. _standalone_rst_latex.tex:
289 https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/test/functional/expected/standalone_rst_latex.tex
290
291
292 .. _style sheet:
293 .. _custom style sheets:
294
295 Style sheets
296 ````````````
297
298 A common way of LaTeX customization is the preparation of custom style
299 sheets, either as simple files with LaTeX code snippets or as home-made
300 `LaTeX packages`_ (see [clsguide]_ for an introduction on LaTeX
301 package writing).
302
303 Setting:
304 stylesheet_
305
306 It is possible to specify multiple style sheets and mix `LaTeX
307 packages`_ with custom style sheets.
308
309 You cannot specify package options with the stylesheet_ setting. If
310 you need to pass options to the package, use the ``\usepackage``
311 command in the `LaTeX preamble`_ or a custom style sheet.
312
313 Example 1:
314 Select Latin Modern fonts with the `lmodern` package::
315
316 --stylesheet=lmodern
317
318 Example 2:
319 Use the `preamble.tex` home-made custom style sheet together with
320 the package `kerkis` (Bookman fonts)::
321
322 --stylesheet=kerkis,preamble.tex
323
324 Example 3:
325 Select Palatino fonts with old-style numbers and true small-caps
326 with the LaTeX command ::
327
328 \usepackage[osf,sc]{mathpazo}
329
330 in the `LaTeX preamble`_ or `custom style sheets`_.
331
332 Stylesheet Repository
333 There is a `repository of user-contributed style sheets`_ in the
334 Docutils Sandbox_.
335
336 .. _stylesheet: config.html#stylesheet-latex-writers
337 .. _embed-stylesheet: config.html#embed-stylesheet-latex-writers
338 .. _repository of user-contributed style sheets:
339 ../../../sandbox/stylesheets/
340 .. _sandbox: ../../../sandbox/
341
342
343 LaTeX preamble
344 ``````````````
345
346 Configuration by LaTeX code in the document preamble is also possible
347 without a separate stylesheet. This way, packages can be loaded with
348 options or commands re-defined without the need to create a separate
349 file (new in Docutils 0.7).
350
351 Setting:
352 latex-preamble_
353
354 Default:
355 used for `font setup`_
356
357 Example:
358 To use the better looking ``txtt`` font for monospaced text define the
359 latex-preamble_ setting in a configuration file::
360
361 latex-preamble: \renewcommand{\ttdefault}{txtt}
362 \usepackage{mathptmx} % Times
363 \usepackage[scaled=.92]{helvet} % Helvetica
364
365 .. _latex-preamble: config.html#latex-preamble
366 .. _PDF standard fonts: https://en.wikipedia.org/wiki/PDF#Standard_Type_1_Fonts
367 .. _Linux Libertine: https://www.linuxlibertine.org
368
369
370 Templates
371 `````````
372
373 Some customizations require commands at places other than the insertion
374 point of stylesheets or depend on the deletion/replacement of parts of the
375 document. This can be done via a custom template. See the `publisher
376 documentation`_ for a description of the `document parts`_ available in a
377 template file.
378
379 Setting:
380 template_
381
382 In addition to the 'default.tex' template, the latex writer directory
383 contains the alternatives 'titlepage.tex' (separate title page) and
384 'titlingpage.tex'" (separate title page with the `memoir`_
385 `document class`_).
386
387 Example:
388 Print a title page including docinfo, dedication, and abstract::
389
390 --template=titlepage.tex
391
392 .. _publisher documentation: ../api/publisher.html
393 .. _document parts:
394 ../api/publisher.html#parts-provided-by-the-xe-latex-writers
395 .. _template: config.html#template-latex-writers
396
397
398 Raw LaTeX
399 `````````
400
401 By means of the `raw directive`_ or a derived `custom role`_, one can
402 give commands directly to LaTeX. These can be both, styling as well as
403 printing commands.
404
405 Example:
406 Math formula::
407
408 .. raw:: latex
409
410 \[x^3 + 3x^2a + 3xa^2 + a^3,\]
411
412 (Drawback: the formula will be invisible in other output formats. Better
413 use the `math directive`_)
414
415 Most LaTeX code examples also work as raw LaTeX inside the document.
416 An exception are commands that need to be given in the document
417 preamble (e.g. package loading with ``\usepackage``, which can be
418 achieved with the ``--style-sheet`` or ``--latex-preamble`` command
419 line options instead). Remember to use *re-defining* commands for
420 customizing `Docutils specific LaTeX macros`_ with raw LaTeX.
421
422 Example:
423 Define the transition command as page break::
424
425 .. raw:: latex
426
427 \renewcommand*{\DUtransition}{\pagebreak[4]}
428
429 See also:
430 * Defining a macro for a `custom role`_.
431 * Forcing `page breaks`_.
432
433 .. _raw directive: ../ref/rst/directives.html#raw
434 .. _math directive: ../ref/rst/directives.html#math
435
436
437 How to configure the ...
438 ========================
439
440 admonitions
441 -----------
442
443 Admonitions__ are specially styled "topics" that can appear anywhere an
444 ordinary `body element`_ can.
445
446 __ ../ref/rst/directives.html#admonitions
447 .. _body element: ../ref/doctree.html#body-elements
448
449 Environment:
450 ``DUadmonition``
451
452 (Command ``\DUadmonition`` with legacy-class-functions_.)
453
454 Default:
455 Typeset in a frame (90 % of text width).
456
457 The admonition title is typeset with the ``\DUtitle`` command (see `titles`_).
458
459 Example 1:
460 A lighter layout without the frame::
461
462 \newenvironment{DUadmonition}%
463 {\begin{quote}}
464 {\end{quote}}
465
466 Example 2:
467 Print all admonitions in the margin::
468
469 \usepackage{environ}
470 \NewEnviron{DUadmonition}{\marginpar{\BODY}}
471
472 Example 3:
473 Use the ``.. note::`` admonition for a margin note::
474
475 \usepackage{environ}
476 \newcommand{\DUCLASSnote}{%
477 \RenewEnviron{DUadmonition}{\marginpar{\BODY}}%
478 \renewcommand{\DUtitle}[1]{}% suppress title ("Note")
479 }
480
481 .. caution:: Make sure there is enough space in the margin.
482 ``\marginpar`` fails in some places or with some content. See also the
483 environ_ and marginnote_ packages.
484
485 .. _environ: https://ctan.org/pkg/environ
486 .. _marginnote: https://ctan.org/pkg/marginnote
487
488
489 .. _custom role:
490
491 custom interpreted text roles
492 -----------------------------
493
494 The rst `role directive`_ allows defining custom `text roles`_ that mark
495 parts of inline text (spans) with class arguments (see section classes_).
496
497 Commands:
498 ``\DUrole``: dispatcher command
499
500 ``\DUrole«classargument»``: optional styling command with 1 argument (the
501 role content).
502
503 Default:
504 The default definition of ``\DUrole{«classargument»}{}`` calls the macro
505 named ``\DUrole«classargument»{}`` if it is defined and silently ignores
506 this class argument if not.
507
508 Example 1:
509 Typeset text in small caps::
510
511 .. role:: smallcaps
512
513 :smallcaps:`Fourier` transformation
514
515 This is transformed to the LaTeX code::
516
517 \DUrole{smallcaps}{Fourier} transformation
518
519 The definition ::
520
521 \newcommand{\DUrolesmallcaps}{\textsc}
522
523 as `raw LaTeX`_ or in the custom `style sheet`_ will give the expected
524 result (if the text font_ supports small caps).
525
526 Example 2:
527 Subscript text in normal size and *italic* shape::
528
529 .. role:: sub(subscript)
530
531 As "sub" inherits from the standard "subscript" role, the LaTeX macro
532 only needs to set the size and shape::
533
534 \newcommand{\DUrolesub}{\normalsize\itshape}
535
536 Example 3:
537 A role with several classes and a converted class name::
538
539 .. role:: custom4
540 :class: argI argII arg_3
541
542 is translated to the nested commands::
543
544 \DUrole{argi}{\DUrole{argii}{\DUrole{arg-3}{<content>}}}
545
546 With the definitions::
547
548 \newcommand{\DUroleargi}[1]{\textsc}
549 \newcommand{\DUroleargii}[1]{{\large #1}}
550 \makeatletter
551 \@namedef{DUrolearg-3}{\textbf}
552 \makeatother
553
554 in a `style sheet`_\ [#]_ or as `raw LaTeX`_ in the document source,
555 text styled with ``:custom4:`large bold small-caps``` will be typeset
556 accordingly.
557
558 .. [#] Leave out the ``\makeatletter`` - ``\makeatother`` pair if the style
559 sheet is a LaTeX package (``*.sty``).
560
561 .. _role directive: ../ref/rst/directives.html#role
562 .. _text roles: ../ref/rst/roles.html
563 .. _class directive: ../ref/rst/directives.html#class-directive
564
565 definition lists
566 ----------------
567
568 ReStructuredText `definition lists`__ correspond to HTML ``<dl>`` list
569 objects.
570
571 Environment:
572 ``description``: LaTeX standard environment
573
574 Command:
575 ``\descriptionlabel``: styling macro for the description term
576
577 Default:
578 bold label text, hanging indent
579
580 Example:
581 A non-bold label can be achieved with::
582
583 \renewcommand\descriptionlabel[1]{\hspace\labelsep \normalfont #1}
584
585 __ ../ref/rst/restructuredtext.html#definition-lists
586
587
588 document class
589 --------------
590
591 There are hundreds of `LaTeX document classes`_ installed by modern
592 LaTeX distributions, provided by publishers, or available at CTAN_.
593
594 Setting:
595 documentclass_
596
597 Popular document classes:
598 * `Standard document classes`_: article, report, book
599 * KOMA-script_ classes: scrartcl, scrrprt, scrbook
600 * memoir_: a highly configurable document class for larger documents
601
602 .. _LaTeX document classes: https://texfaq.org/FAQ-clsvpkg
603 .. _standard document classes:
604 http://mirrors.ctan.org/macros/latex/base/classes.pdf
605 .. _KOMA-script: https://ctan.org/pkg/koma-script
606 .. _memoir: https://ctan.org/pkg/memoir
607 .. _documentclass: config.html#documentclass
608
609
610 document info
611 -------------
612
613 The `bibliographic fields`_ at the top of a document specify
614 document information like author name(s) and copyright info.
615 By default, they are typeset as a table.
616
617 Settings:
618 use-latex-docinfo_, use-latex-abstract_
619
620 If use-latex-docinfo_ is True, the content of the "Author", "Authors",
621 "Address", "Contact", "Organization", and "Date" fields is attached to
622 the `document title`_ (see below).
623
624 If use-latex-abstract_ is True, the "Abstract" field content is placed
625 in an "abstract" environment. The "abstract" environment can be
626 customized or `set up`__ (for the "book" documentclass) with the
627 "abstract_" LaTeX package.
628
629 Length:
630 | ``\DUdocinfowidth`` (width of the `docinfo` table).
631 | Default: ``0.9\textwidth`` (90 % of text width)
632
633 Example:
634 Change the width of the docinfo table to 70 % of text width::
635
636 \newlength{\DUdocinfowidth}
637 \setlength{\DUdocinfowidth}{0.7\textwidth}
638
639 .. _bibliographic fields: ../ref/rst/restructuredtext.html#bibliographic-fields
640 .. _use-latex-docinfo: config.html#use-latex-docinfo
641 .. _use-latex-abstract: config.html#use-latex-abstract
642 __ https://tex.stackexchange.com/a/539606/288060
643 .. _abstract: https://ctan.org/pkg/abstract
644
645
646 document title
647 --------------
648
649 A lone top-level section title is (usually) transformed to the document title
650 (see `section structure`_).
651
652 Settings:
653 doctitle_xform_, documentclass_, use-latex-docinfo_, template_
654
655 The format of the document title is defined by the `document class`_
656 and can be modified by `latex packages`_.
657 The "article" document class uses an in-page title while the "report"
658 and "book" classes use a separate title page.
659 See section Templates_ and the `TeX FAQ`_ on how to customize the
660 `style of document titles`_.
661
662 Example:
663 With `use-latex-docinfo`_, author information and date are typeset
664 as part of the document title instead of the `document info`_ table.
665
666 Paper by three authors, two of them from the same organisation::
667
668 Shop Sketches
669 =============
670
671 :authors: * Mr. Mousebender
672 * Mr. Arthur Wensleydale
673 :organization: Ye National Cheese Emporium
674
675 :author: Hr. Hallmackenreuther
676 :organization: Bettengeschäft
677
678 With ``--use-latex-docinfo``, authors and their affiliations are
679 typeset below the title using the standard LaTeX command ``\author``
680 with a `simple hack for the common affiliation`__. [#]_
681
682 .. [#] Unfortunately, author names don't wrap if there are more
683 authors than fit on one line in one "authors" field.
684
685 __ https://tex.stackexchange.com/a/11656/288060from
686
687
688 .. _section structure: rst/quickref.html#section-structure
689 .. _doctitle_xform: config.html#doctitle-xform
690 .. _TeX FAQ: https://texfaq.org/
691 .. _style of document titles: https://texfaq.org/FAQ-titlsty
692
693
694 field lists
695 -----------
696
697 `Field lists`__ may be used as generic two-column table constructs in
698 documents.
699
700 Environment:
701 ``DUfieldlist``
702
703 Default:
704 Indented description list.
705
706 Example:
707 Use a description list customized with enumitem_::
708
709 \usepackage{enumitem}
710 \newenvironment{DUfieldlist}%
711 {\description[font=,style=sameline,leftmargin=8em]}
712 {\enddescription}
713 }
714
715 The `KOMA-script`_ classes provide a similar environment under the name
716 `labeling`.
717
718 .. _enumitem: https://ctan.org/pkg/enumitem
719 __ ../ref/rst/restructuredtext.html#field-lists
720
721
722 figure and table captions
723 -------------------------
724
725 The caption_ package provides many ways to customise the captions in
726 floating environments like figure and table.
727
728 The chngcntr_ package helps to configure the numbering of figure and table
729 caption numberings.
730
731 Some document classes (e.g. KOMA-script_) provide additional configuration.
732 See also `The style of captions`_ in the LaTeX FAQ.
733
734 Example
735 ::
736
737 \usepackage{caption}
738 \captionsetup{justification=raggedleft,singlelinecheck=false}
739
740 .. _caption: https://ctan.org/pkg/caption
741 .. _chngcntr: https://ctan.org/pkg/chngcntr
742 .. _The style of captions: https://texfaq.org/FAQ-captsty
743
744 figure placement
745 ----------------
746
747 Figures_ might be typeset at the place of definition (default) or "float"
748 to a suitable place at the top or bottom of a page. This is implemented
749 using the float_ package.
750
751 Command:
752 ``\floatplacement``
753
754 The placement setting is valid from the point of definition until the next
755 ``\floatplacement`` command or the end of the document. See float.pdf_ for
756 details.
757
758 Default:
759 ``\floatplacement{figure}{H}`` (here definitely). This corresponds most
760 closely to the source and HTML placement (principle of least surprise).
761
762 Example 1:
763 In a custom `style sheet`_, set the default to let LaTeX find a suitable
764 place for figure floats::
765
766 \usepackage{float}
767 \floatplacement{figure}{htbp} % here, top, bottom, extra-page
768
769 Example 2:
770 To move all following figures to the top or bottom of the page write in
771 the document source::
772
773 .. raw:: latex
774
775 \floatplacement{figure}{tb}
776
777 .. _figures: ../ref/rst/directives.html#figure
778 .. _float: https://ctan.org/pkg/float
779 .. _float.pdf: https://mirrors.ctan.org/macros/latex/contrib/float/float.pdf
780
781
782 .. _font setup:
783
784 font
785 ----
786
787 The selected text font influences the *look*, the *feel*,
788 and the *readability* of the document
789 (cf. `Typography on the information highway`_).
790 Selecting a suitable font also solves the problem with
791 `bad looking PDF output`_.
792
793 Font selection is one of the main differences between pdflatex_
794 and xelatex_/lualatex_:
795
796 pdflatex_
797 requires specially installed fonts in a set of legacy `font encoding`_\ s.
798
799 xelatex_ and lualatex_
800 can use system fonts and provide access to the full feature set of
801 modern OpenType_ fonts.
802
803 The default font setup is done in the latex-preamble_:
804
805 pdflatex_
806 `PDF standard fonts`_ (Times, Helvetica, Courier)
807
808 xelatex_/lualatex_
809 `Linux Libertine`_, a free, high quality alternative to Times with a
810 wide coverage of glyphs, styles, and OpenType features.
811
812 Despite its name, Linux Libertine can be used on any operating
813 system that can handle OpenType fonts.
814
815 Alternative fonts can be selected by
816
817 pdflatex_
818 a) specifying the corresponding LaTeX package(s) as argument to the
819 stylesheet_ setting or with the ``\usepackage`` LaTeX command.
820
821 * packages can be combined,
822 * passing options to a package is only possible in a `style sheet`_
823 or the `LaTeX preamble`_.
824
825 b) changing the font-default macros ``\rmdefault``, ``\sfdefault``
826 and/or ``\ttdefault`` in a custom `style sheet`_, the `LaTeX
827 preamble`_ or `raw LaTeX`_.
828
829 Example 1:
830 Use `Latin Modern`_. `LaTeX code`_::
831
832 \usepackage{lmodern}
833
834 Command line argument::
835
836 --stylesheet=lmodern
837
838 Example 2:
839 The _`Times/Helvetica/Courier` `PDF standard fonts`_ are
840 selected by the LaTeX code [#]_::
841
842 \usepackage{mathptmx} % Times for serif and math
843 \usepackage[scaled=.90]{helvet} % downscaled Helvetica for sans serif
844 \usepackage{courier} % Courier for teletype (mono-space)
845
846 Since Docutils 0.7, this is the default value of the
847 `latex-preamble`_ setting.
848
849 .. [#] When generating PDF-files from LaTeX, the `PDF standard
850 fonts`_ do not need to be embedded in the document. While this
851 results in smaller files, the actually used fonts on screen and in
852 print might differ! (For details see, e.g., the testflow_ package
853 documentation.)
854
855
856 Example 3:
857 Use the teletype font from the txfonts_ package. As there is no
858 package for this, we re-define the font macro with the `LaTeX code`_::
859
860 \renewcommand{\ttdefault}{txtt}
861
862
863 xelatex_/lualatex_
864 using the macros of the fontspec_ package. Use some font-viewer or
865 -manager (e.g. fontmatrix_) to find out the correct names of the
866 fonts on your system.
867
868 Example:
869 DejaVu_, very wide coverage, screen optimized. As this font
870 runs wide, add ``DIV=10`` to the `documentoptions`_::
871
872 \setmainfont{DejaVu Serif}
873 \setsansfont{DejaVu Sans}
874 \setmonofont[HyphenChar=None]{DejaVu Sans Mono}
875
876 .. _Typography on the information highway: https://csarven.ca/web-typography
877 .. _OpenType: https://en.wikipedia.org/wiki/OpenType
878 .. _fontspec: https://ctan.org/pkg/fontspec
879 .. _fontmatrix: https://fontmatrix.net/
880 .. _DejaVu: https://dejavu-fonts.org/
881 .. _documentoptions: config.html#documentoptions
882
883
884 choice of suitable fonts
885 ````````````````````````
886
887 With xelatex_/lualatex_, you may use any of the system fonts.
888
889 The `LaTeX Font Catalogue`_ provides information and examples for a wide
890 range of fonts available for use with PdfLaTeX. Here is just a selection:
891
892 a) The `Latin Modern`_ (LM) fonts are extended outline versions of the
893 standard TeX font Computer Modern (CM).
894
895 +1 simple invocation: ``--stylesheet=lmodern``
896
897 +1 keeps the traditional TeX "look and feel":
898
899 +1 generally accepted as high quality CM replacement,
900 +1 comprehensive math support,
901 +1 including optical sizes,
902 +1 compatible with extensions made to match CM,
903 -1 modern types are hard to read at low (screen) resolutions.
904
905 -1 not part of a minimal standard TeX installation
906
907 b) CM-Super_ is another outline CM replacement.
908
909 +1 simple invocation: modern LaTeX distributions use CM-Super
910 automatically instead of CM if it is installed.
911
912 -1 said to be of inferior quality compared to LM.
913
914 -1 not part of a minimal standard TeX installation,
915 bigger download size than Latin Modern (64 MB).
916
917 c) `Bera`_ (Bitstream Vera)
918
919 +1 simple invocation: ``--stylesheet=bera``
920
921 +1 optimized for on-screen viewing with goot hinting
922
923 -1 not part of a minimal standard TeX installation
924
925 d) PSNFSS_ Postscript fonts
926
927 +1 part of every standard TeX installation
928
929 +1 smaller PDF/Postscript document size if standard fonts are not
930 embedded
931
932 -1 restricted set of glyphs in the free versions [#]_
933
934 -1 different fonts for roman, sans-serif and typewriter fonts.
935
936 -1 invocation somewhat more complex, as several packages are
937 required for a complete font set, sometimes including package
938 options.
939
940 Roman (serif) PSNFSS fonts:
941
942 Bookman
943 good legibility but very wide.
944
945 Charter
946 bread-and-butter type optimized for printing on low-resolution
947 printers
948
949 New Century Schoolbook
950 good legibility but very wide.
951
952 Palatino
953 +1 recommended by font experts
954 +1 good LaTeX support including matching math fonts, small caps,
955 old-style figures
956 -1 bad rendering in xpdf viewer (auto-hinting leads to different
957 x-hight for different characters at some magnifications)
958 (this is fixed in recent versions).
959
960 Times
961 +1 the serif `PDF Standard Font`_,
962 -1 overused and quite narrow (devised for multi-column layouts).
963
964 Utopia
965 recommended by font experts
966
967
968 .. table:: Font packages for standard Postscript fonts
969 (cf. `Using common Postscript fonts with LaTeX`_)
970
971 ========= ============ ============= ============= =========
972 Package Roman Sans Serif Typewriter Math
973 ========= ============ ============= ============= =========
974 (none) CM Roman CM Sans Serif CM Typewriter CM Math
975
976 mathpazo Palatino Palatino
977
978 mathptmx Times Times
979
980 helvet Helvetica
981
982 avant Avant Garde
983
984 courier Courier
985
986 chancery Zapf
987 Chancery
988
989 bookman Bookman Avant Garde Courier
990
991 newcent New Century Avant Garde Courier
992 Schoolbook
993
994 charter Charter
995
996 utopia Utopia
997
998 fourier Utopia Fourier
999 ========= ============ ============= ============= =========
1000
1001 .. [#] Extended versions of the standard Postscript fonts including
1002 accented chars, as well as real small-caps
1003 and old-style numbers are available with the `TeX Gyre`_ bundle
1004 which is part of, e.g., `TeX Live`_.
1005
1006
1007 .. _LaTeX Font Catalogue: https://www.tug.org/FontCatalogue/
1008 .. _Latin Modern: https://ctan.org/pkg/lm
1009 .. _CM-Super: https://ctan.org/pkg/cm-super
1010 .. _bera: https://ctan.org/pkg/bera
1011 .. _TeX Gyre: https://www.gust.org.pl/projects/e-foundry/tex-gyre
1012 .. _PSNFSS: https://ctan.org/pkg/psnfss
1013 .. _Using common PostScript fonts with LaTeX:
1014 https://mirrors.ctan.org/macros/latex/required/psnfss/psnfss2e.pdf
1015 .. _TeX Live: https://www.tug.org/texlive/
1016 .. _txfonts: https://ctan.org/pkg/txfonts
1017 .. _PDF Standard Font:
1018 https://en.wikipedia.org/wiki/PDF#Standard_Type_1_Fonts
1019 .. _testflow: https://ctan.org/pkg/testflow
1020
1021
1022 font encoding
1023 -------------
1024
1025 LaTeX font encodings are described in detail in [encguide]_ which is
1026 part of the LaTeX base documentation.
1027
1028 Setting:
1029 font-encoding_
1030
1031 Default:
1032 "T1"
1033
1034 Example 1:
1035 Use the (obsolete) LaTeX default encoding "OT1"::
1036
1037 --font-encoding=OT1
1038
1039 or (without loading the fontenc_ package)::
1040
1041 --font-encoding=""
1042
1043 This will improve the look on screen with the default Computer Modern
1044 fonts at the expense of problems with `search and text extraction`_
1045 The recommended way is to select a T1-encoded "Type 1" (vector)
1046 font, for example `Latin Modern`_
1047
1048 Example 2:
1049 Support for characters in the Unicode blocks Latin, Latin-1 Supplement,
1050 and Greek together with a T1-encoded "Type 1" (vector) font, for example
1051 `Latin Modern`_::
1052
1053 --font-encoding=LGR,T1 --stylesheet=lmodern
1054
1055 .. _font-encoding: config.html#font-encoding
1056 .. _fontenc: https://ctan.org/pkg/fontenc
1057
1058
1059 font size
1060 ---------
1061
1062 Add font size in points to the document options, e.g.
1063 ``--documentoptions=12``, use e.g. the document classes provided by
1064 extsizes_ for values other than [10,11,12].
1065
1066 .. _extsizes: https://ctan.org/pkg/extsizes
1067
1068
1069 footnotes
1070 ---------
1071
1072 Setting:
1073 latex_footnotes_
1074
1075 By default, `footnote references`_ and footnotes_ are set with the
1076 macros ``\DUfootnotemark`` and ``\DUfootnotetext`` using the footnote
1077 labels from the source or generated by Docutils.
1078
1079 If the setting latex_footnotes_ is True (or with the command line
1080 option ``--latex-footnotes``), numbering and placement of footnotes
1081 is handled by LaTeX:
1082
1083 * Footnotes are set with the standard LaTeX ``\footnote`` command at the
1084 place of the first matching `footnote reference`_.
1085 * LaTeX does its best to place the footnote at the same page as the
1086 footnote reference.
1087 * There is no distinction between numbered footnotes and
1088 `symbol footnotes`_, by default all footnotes are numbered.
1089 * Footnotes are sorted and numbered in the order of the `footnote references`.
1090 * There is no backlink from footnote to footnote reference.
1091 * Unreferenced footnotes are silently ignored!
1092
1093 .. important::
1094 LaTeX footnotes in figures and table captions `are dropped`__.
1095
1096 LaTeX footnotes in a sidebar_ and corner cases like footnotes
1097 referenced from a title and containing a footnote reference lead to
1098 compilation errors!
1099
1100 LaTeX offers a wide range of footnote configuration options
1101 (cf. the `LaTeX WikiBook`__ and the `TeX FAQ`__).
1102 Additionally, the ``\DUfootnotemark`` and ``\DUfootnotetext`` commands
1103 can be configured in a custom `style sheet`_ or the `LaTeX preamble`_.
1104
1105 __ https://texfaq.org/FAQ-ftncapt
1106 __ https://en.wikibooks.org/wiki/LaTeX/Footnotes_and_Margin_Notes
1107 #Common_problems_and_workarounds
1108 __ https://texfaq.org/tags#footnotes
1109
1110 Example 1:
1111 Set footnote text with a hanging indent.
1112
1113 * This is the default with KOMA-script_ classes, e.g::
1114
1115 --documentclass=scrartcl
1116
1117 (for further configuration, see [scrguide]_),
1118
1119 * `LaTeX preamble`_ code for hanging indent with the footmisc_ package::
1120
1121 \usepackage[hang]{footmisc}
1122 \setlength{\footnotemargin}{0em}
1123
1124 (play with the ``\footnotemargin`` setting),
1125
1126 Example 2:
1127 Footnote marks in normal font size, not superscript::
1128
1129 \usepackage{scrextend} % not required with KOMA-script document classes
1130 \deffootnote{1em}{1em}{\thefootnotemark\ }
1131
1132 (See [scrguide]_ for details and other options.)
1133
1134 Example 3:
1135 Place the footnote text where it appears in the source document (instead
1136 of at the page bottom). This can be used to get the effect of endnotes
1137 (requires the hanging_ package)::
1138
1139 \usepackage{hanging}
1140 \newcommand{\DUfootnotetext}[4]{%
1141 \par\noindent\phantomsection\label{#1}\hyperlink{#2}{#3}
1142 \hangpara{\parindent}{1}#4%
1143 }
1144
1145 .. _footnotes: ../ref/rst/restructuredtext.html#footnotes
1146 .. _footnote reference:
1147 .. _footnote references: ../ref/rst/restructuredtext.html#footnote-references
1148 .. _footmisc: https://ctan.org/pkg/footmisc
1149 .. _latex_footnotes: config.html#latex-footnotes
1150 .. _hanging: https://ctan.org/pkg/hanging
1151 .. _symbol footnotes: ../ref/rst/restructuredtext.html#auto-symbol-footnotes
1152
1153
1154 hyphenation
1155 -----------
1156
1157 The amount of hyphenation is influenced by ``\hyphenpenalty``, setting it to
1158 10000 almost prevents hyphenation. As this produces lines with more space
1159 between words one should increase Latex's ``\tolerance`` for this.
1160
1161 Example:
1162 ::
1163
1164 \hyphenpenalty=5000
1165 \tolerance=1000
1166
1167
1168 hyperlinks
1169 ----------
1170
1171 Settings:
1172 hyperlink-color_, hyperref-options_
1173
1174 Hyperlinks are realized using the hyperref_ package. As it re-defines many
1175 standard LaTeX macros, this package is loaded last, *after* the style
1176 sheets.
1177
1178 However, you can load hyperref before a package that requires its
1179 presence in a `style sheet`_ or the `LaTeX preamble`_ (see example
1180 below). This will ignore options set with hyperlink-color_ and
1181 hyperref-options_.
1182
1183 URLs are typeset with the "url" package (loaded implicitly by "hyperref").
1184 The font of URLs can be defined with the ``\urlstyle`` command. Valid
1185 arguments are
1186
1187 .. class:: field-indent-4em
1188
1189 :same: normal text font, Docutils default,
1190 :tt: teletype (monospaced), LaTeX default,
1191 :rm: roman,
1192 :sf: sans serif
1193
1194 Example:
1195 Custom loading of the hyperref package also switches to
1196 the LaTeX default (monospaced fonts for URLs). Reset to use the text
1197 font::
1198
1199 \usepackage[unicode,colorlinks=true,linkcolor=green]{hyperref}
1200 \urlstyle{same}
1201
1202 See also `non-breaking hyperlinks`_.
1203
1204 .. _hyperlink-color: config.html#hyperlink-color
1205 .. _hyperref-options: config.html#hyperref-options
1206
1207
1208 disable hyperlinks
1209 ``````````````````
1210
1211 To suppress the hyper-linking completely (e.g. for printing or to
1212 avoid clashes with other packages), set hyperref-options_ to "draft"
1213 or load the "nohyperref" package that comes with the "hyperref"
1214 bundle.
1215
1216 Setting:
1217 hyperref-options_
1218
1219 `LaTeX code`_::
1220
1221 \usepackage{nohyperref,url}
1222 \urlstyle{same}
1223
1224 .. _hyperref: https://ctan.org/pkg/hyperref
1225
1226
1227 language
1228 --------
1229
1230 The global document language can be set with the language-code_
1231 configuration setting. The language of text parts can be set adding the
1232 language tag prefixed by "language-" to an element's classes_
1233 attribute, e.g. ``language-el`` for a Greek text part.
1234
1235 .. _language-code: config.html#language-code
1236
1237
1238 line blocks
1239 -----------
1240
1241 In `line blocks`__, newlines and leading whitespace are respected.
1242
1243 Environment:
1244 ``DUlineblock``: special list environment for line blocks
1245
1246 Length:
1247 ``\DUlineblockindent``: indentation of indented lineblock parts.
1248
1249 Default:
1250 2.5 times the font height: ``2.5em``
1251
1252 Example:
1253 set to the paragraph indentation::
1254
1255 \newlength{\DUlineblockindent}
1256 \setlength{\DUlineblockindent}{\parindent}
1257
1258 __ ../ref/rst/restructuredtext.html#line-blocks
1259
1260 line spacing
1261 ------------
1262
1263 Commands:
1264 ``\linespread``: for small adjustments
1265
1266 ``\singlespacing``, ``\onehalfspacing``, and ``\doublespacing``: from
1267 package `setspace`
1268
1269 Example 1:
1270 Get document wide double spacing::
1271
1272 \usepackage{setspace}
1273 \doublespacing
1274
1275 Example 2:
1276 Increase line spacing by five percent for better readability::
1277
1278 \linespread{1.05}
1279
1280
1281 literal blocks
1282 --------------
1283
1284 No markup processing is done within a `literal block`__. It is left as-is,
1285 and is typically rendered in a monospaced typeface
1286
1287 Setting:
1288 literal-block-env_
1289
1290 Example:
1291
1292 ``--literal-block-env=lstlisting``
1293
1294 The ``lstlisting`` environment is highly configurable (as documented in
1295 listings.pdf_) and provides syntax highlight for many programming languages,
1296 for instance ::
1297
1298 \renewcommand{\ttdefault}{txtt}
1299 \lstset{language=Python, morekeywords=[1]{yield}}
1300 \lstloadlanguages{Python}
1301 \lstset{
1302 basicstyle=\ttfamily,
1303 keywordstyle=\bfseries,
1304 commentstyle=\rmfamily\itshape,
1305 stringstyle=\slshape,
1306 }
1307 \lstset{showstringspaces=false}
1308 \lstset{columns=fullflexible,
1309 basewidth={0.5em,0.4em}}
1310
1311 and to get LaTeX syntax highlight for a code block with "listings"::
1312
1313 \lstloadlanguages{[LaTeX]TeX} % comma separated list of languages
1314 \newcommand{\DUCLASSlatex}{\lstset{language=[LaTeX]TeX}}
1315
1316 The indentation of literal blocks can be reset with ::
1317
1318 \lstset{resetmargins=true}
1319
1320 and/or configured with e. g.::
1321
1322 \lstset{xleftmargin=-2em}
1323
1324 __ ../ref/rst/restructuredtext.html#literal-blocks
1325 .. _literal-block-env: config.html#literal-block-env
1326 .. _listings.pdf:
1327 https://mirrors.ctan.org/macros/latex/contrib/listings/listings.pdf
1328
1329
1330 lists
1331 -----
1332
1333 Remove extra vertical whitespace between items of bullet lists and
1334 enumerated lists.
1335
1336 Example:
1337 Pass the class argument "compact" to the list::
1338
1339 .. class:: compact
1340
1341 * first item
1342 * second item
1343
1344 The following lines for the `LaTeX preamble`_ use the enumitem_ package to
1345 remove spacing from all lists with class argument "compact"::
1346
1347 \usepackage{enumitem}
1348 \newcommand*{\DUCLASScompact}{\setlist{noitemsep}}
1349
1350
1351 list of figures/tables
1352 ----------------------
1353
1354 Docutils does not support lists of figures or tables.
1355
1356 However, with LaTeX, they can be generated using `raw LaTeX`_ in the
1357 document source.
1358
1359 Commands:
1360 ``\listoffigures``: a list of figures
1361
1362 ``\listoftables``: a list of tables
1363
1364 Example:
1365 ::
1366
1367 .. raw:: latex
1368
1369 \listoffigures
1370
1371
1372 option list
1373 -----------
1374
1375 `Option lists`__ are two-column lists of command-line options and
1376 descriptions, documenting a program's options.
1377
1378 Environment:
1379 ``DUoptionlist``: environment for option lists,
1380
1381 Command:
1382 ``\DUoptionlistlabel``: set appearance of the options
1383
1384 Example:
1385 set command options with a bold monospace font::
1386
1387 \newcommand{\DUoptionlistlabel}{\texttt{\textbf{#1}} \hfill}
1388
1389 __ ../ref/rst/restructuredtext.html#option-lists
1390
1391
1392 page breaks
1393 -----------
1394
1395 * Page breaks before top-level sections are the default with a
1396 documentclass that provides "chapters", e.g. "book", "memoir" or
1397 "scrbook".
1398
1399 * Redefining the \section or \section* command in a
1400 style sheet is possible too.
1401
1402 * `Raw LaTeX`_ or a `custom role`_ can be used.
1403
1404 * The transition element can be re-defined to produce a page break,
1405
1406 Commands
1407 ``\newpage``: hard pagebreak at exactly this position
1408
1409 ``\pagebreak[2]``: recommended page break after line end (precedence 1...4)
1410
1411 Example:
1412 Define the transition command as page break with the `LaTeX code`_::
1413
1414 \newcommand*{\DUtransition}{\pagebreak[4]}
1415
1416 (use ``\renewcommand`` with `raw LaTeX`_).
1417
1418 page layout
1419 -----------
1420
1421 By default, paper size and margin settings are determined by the document
1422 class.
1423
1424 The following packages help to configure the page layout:
1425
1426 a) The `typearea`_ package (part of the `KOMA-script`_ bundle) calculates a
1427 *good* page layout (based on rules and recommendations of typography
1428 experts).
1429
1430 See [scrguide]_ for details on what is a *good* layout and
1431 how this is achieved.
1432
1433 b) The `geometry`_ package is recommended if you have to follow guidelines
1434 with fixed values for the margins.
1435 For details see the `geometry manual`_.
1436
1437 Example 1:
1438 Let `typearea` determine the type area with ``DIV=calc`` in the
1439 documentoptions::
1440
1441 --documentoptions='a4paper,DIV=calc'
1442
1443 The ``DIV`` option can also be specified, like ``DIV=10``. It defines how
1444 "crowded" a page will be: larger values mean larger text area (at the
1445 expense of readability).
1446
1447 Example 2:
1448 `LaTeX code`_ to set margins with the geometry_ package::
1449
1450 \usepackage{geometry}
1451 \geometry{hmargin={3cm,0.8in},height=8in}
1452 \geometry{height=10in}.
1453
1454 .. _typearea: https://ctan.org/pkg/typearea
1455 .. _geometry: https://ctan.org/pkg/geometry
1456 .. _geometry manual:
1457 https://mirrors.ctan.org/macros/latex/contrib/geometry/geometry.pdf
1458
1459
1460 page headers and footers
1461 ------------------------
1462
1463 With the fancyhdr_ package or the `KOMA-script`_ classes, you can define
1464 custom page head- and foot-lines.
1465
1466 The `"header" and "footer" directives`_ save their content in the macros
1467 ``\DUheader`` rsp. ``\DUfooter``. The macros can be used in LaTeX code and
1468 will be replaced by LaTeX with the content of the directives.
1469
1470 Example:
1471 `LaTeX code`_ to place left-aligned "header" and "footer" on every
1472 page with fancyhdr_::
1473
1474 \usepackage{fancyhdr}
1475 \fancyhead[L]{\DUheader}
1476 \fancyfoot{} % reset
1477 \fancyfoot[L]{\DUfooter}
1478 \pagestyle{fancy}
1479
1480
1481 .. _fancyhdr: https://ctan.org/pkg/fancyhdr
1482 .. _"header" and "footer" directives: ../ref/rst/directives.html#header
1483
1484
1485 page numbering
1486 --------------
1487
1488 Example:
1489 Number pages by chapter (using the chappg_ package)::
1490
1491 \usepackage{chappg}
1492
1493 See the `chappg documentation`_ for details.
1494
1495 .. _chappg: https://ctan.org/pkg/chappg
1496 .. _chappg documentation:
1497 https://mirrors.ctan.org/macros/latex/contrib/chappg/chappg.pdf
1498
1499
1500 paper size
1501 ----------
1502
1503 Paper geometry can be changed using documentoptions_ or with the
1504 `geometry`_ package.
1505
1506 `LaTeX code`_::
1507
1508 \usepackage{geometry}
1509 \geometry{OPTIONLIST}
1510
1511 Default:
1512 a4paper
1513
1514 Some possibilities:
1515
1516 * a4paper, b3paper, letterpaper, executivepaper, legalpaper
1517 * landscape, portrait, twoside.
1518
1519 Example:
1520 Choose A5 pager in landscape orientation with command line argument::
1521
1522 --documentoptions=a5paper,landscape
1523
1524 The same with LaTeX commands in the `style sheet`_::
1525
1526 \usepackage{geometry}
1527 \geometry{a5paper,landscape}
1528
1529 For details see the `geometry manual`_.
1530
1531 paragraph indent
1532 ----------------
1533
1534 Default (in most document classes):
1535 Indent the first line in a paragraph unless it is the first line of a
1536 chapter, section, subsection, or subsubsection.
1537
1538 Example 1:
1539 To set paragraph indentation to zero but add a vertical space between
1540 load the `parskip` package with the command line argument::
1541
1542 --stylesheet=parskip
1543
1544 or in a custom `style sheet`_ with::
1545
1546 \usepackage{parskip}
1547
1548 Example 2:
1549 To suppress the indentation of a specific paragraph, you may give it the
1550 class "noindent" with, e.g. ::
1551
1552 .. class:: noindent
1553
1554 This paragraph should not be indented.
1555
1556 and define the `custom role`_ command::
1557
1558 \newcommand{\DUrolenoindent}[1]{\noindent #1}
1559
1560 rubric
1561 ------
1562
1563 A rubric__ is like an informal heading that doesn't correspond to the
1564 document's structure.
1565
1566 Command:
1567 ``\DUrubric``
1568
1569 Default:
1570 subsubsection style (unnumbered), italic
1571
1572 Example1:
1573 Set centred and red::
1574
1575 \newcommand*{\DUrubric}[1]{%
1576 \subsubsection*{\centerline{\color{red}#1}}}
1577
1578 .. note::
1579 Class attribute values are ignored because the "classes_ wrapper"
1580 interferes with LaTeX's formatting (spacing/indentation) of text following
1581 a section heading. Consider using a `topic element`_ or a container_.
1582
1583 __ ../ref/rst/directives.html#rubric
1584 .. _container: ../ref/rst/directives.html#container
1585
1586 section headings
1587 ----------------
1588
1589 Settings: documentclass_, use-part-section_
1590
1591 Section headings are converted into LaTeX macros according to their level,
1592 the document class and the value of the use-part-section_ setting:
1593
1594 ===== ============= ================== ============= ==============
1595 Level article article with part book [#]_ book with part
1596 ===== ============= ================== ============= ==============
1597 1 section part chapter part
1598 2 subsection section section chapter
1599 3 subsubsection subsection subsection section
1600 4 paragraph subsubsection subsubsection subsection
1601 5 subparagraph paragraph paragraph subsubsection
1602 6 DUtitle subparagraph subparagraph paragraph
1603 7 DUtitle DUtitle DUtitle subparagraph
1604 ===== ============= ================== ============= ==============
1605
1606
1607 .. [#] One of the document classes 'book', 'memoir', 'report 'scrbook',
1608 or 'scrreprt'.
1609
1610 .. _use-part-section: config.html#use-part-section
1611
1612 section numbering
1613 -----------------
1614
1615 Sections are numbered if there is a `sectnum directive`_ in the document.
1616
1617 Setting: sectnum_xform_
1618
1619 If sectnum_xform_ is False, section numbers are generated by LaTeX. In this
1620 case the "prefix" and "suffix" arguments of the `sectnum directive`_ are
1621 ignored. The section number style is determined by the `document class`_
1622 and can be configured in a LaTeX `style sheet`_, e.g.::
1623
1624 \setcounter{secnumdepth}{5}
1625
1626 .. note:: The LaTeX name is 'secnumdepth' (without 't').
1627
1628 .. _sectnum directive: ../ref/rst/directives.html#sectnum
1629 .. _sectnum_xform: config.html#sectnum-xform
1630
1631
1632 sidebar
1633 -------
1634
1635 Sidebars__ are like miniature, parallel documents that occur inside other
1636 documents, providing related or reference material. They can be likened to
1637 super-footnotes; their content is outside of the flow of the document's main
1638 text.
1639
1640 __ ../ref/rst/directives.html#sidebar
1641
1642 Command:
1643 ``DUsidebar``
1644
1645 Default:
1646 Box with grey background.
1647
1648 Example:
1649 Use margin notes::
1650
1651 \newcommand{\DUsidebar}[1]{\marginpar{\flushleft #1}}
1652
1653 * Make sure the margin is wide enough to hold the note.
1654 * This fails with some constructs inside the `side bar` and where
1655 \marginpar cannot be used, e.g., inside floats, footnotes, or in frames
1656 made with the framed package (see marginnote_).
1657
1658
1659 size of a "px"
1660 --------------
1661
1662 The `length unit`_ "px" is `defined in pdfTeX and LuaTeX`__, the "XeTeX"
1663 writer uses the ``\pdfpxdimen`` macro as workaround.
1664
1665 Default:
1666 1 px = 1/72 in
1667
1668 Example:
1669 Set the value to match the `CSS3 pixel unit`_ 1 px = 1/96 in
1670 with the `LaTeX code`_::
1671
1672 \pdfpxdimen=1in
1673 \divide\pdfpxdimen by 96
1674
1675 __ https://tex.stackexchange.com/questions/41370/
1676 what-are-the-possible-dimensions-sizes-units-latex-understands
1677 .. _reference pixel: https://www.w3.org/TR/css-values-3/#reference-pixel
1678
1679 table style
1680 ------------
1681
1682 A pre-configured *table style* can be globally selected via the table_style_
1683 setting or set for individual tables via a `class directive`_ or the
1684 ``class`` option of the `table directives`_.
1685
1686 Supported values:
1687
1688 standard
1689 Borders around all cells.
1690
1691 booktabs
1692 Use the booktabs_ package for publication quality tables (no vertical rules).
1693
1694 borderless
1695 No borders around table cells.
1696
1697 _`colwidths-auto`
1698 Column width determination by LaTeX.
1699 Overridden by the `table directive option`_ ``widths``.
1700
1701 .. Caution::
1702 `Auto-sized columns`_ work only with simple cell content.
1703
1704 .. eventually in future
1705
1706 align-left, align-center, align-right
1707 Align tables.
1708
1709 .. _booktabs: https://ctan.org/pkg/booktabs
1710
1711
1712 .. _table width:
1713
1714 table width and column widths
1715 -----------------------------
1716
1717 To support automatic line breaks, standard LaTeX tables need to know the
1718 column widths. Therefore, the LaTeX writer determines default values for
1719 both, relative column widths and the total width of a table from the
1720 table's ``colwidth`` [#fn:colwidth]_ values. [#fn:table-width]_
1721 The algorithm works sufficiently well in typical use cases. However,
1722 there are cases where the table layout requires manual intervention,
1723 for example:
1724
1725 * Tables where the cells contain only numbers or short text look better
1726 with `auto-sized columns`_.
1727
1728 * If the input table contains verbose markup syntax, column widths in the
1729 source may be bad indicators for output column widths.
1730
1731 * Columns may become too narrow in tables that are nested inside lists,
1732 quotes, or similar.
1733
1734 To improve the table layout, you may:
1735
1736 * Use the `table directive option`_ ``width`` to set the table width
1737 to a custom `length <length units_>`__ or percentage_ of the current
1738 line width.
1739
1740 * Adjust the table column widths in the source document or use the
1741 `table directive option`_ ``widths`` to specify column widths.
1742
1743 .. _auto-sized columns:
1744
1745 * Set the `table directive option`_ ``widths`` to the value *"auto"* or
1746 select the `table style`_ "colwidths-auto_" to let LaTeX determine
1747 table and column widths from the table content.
1748
1749 .. Caution::
1750 Auto-sized columns only work with simple cell content.
1751
1752 LaTeX sets cell content in auto-sized columns in one line (merging
1753 paragraphs) and fails with other block level content.
1754
1755 The `legacy_column_widths`_ setting provides backwards compatibility with
1756 the (faulty) legacy algorithm.
1757
1758 .. [#fn:colwidth]
1759 Docutils stores the column widths in the reStructuredText
1760 `table markup`_ (in characters) in the colwidth_ attribute
1761 of the table column specifications.
1762 (The colwidth_\ s of a `list table`_ or `CSV table`_ with :math:`n`
1763 columns default to :math:`w_i = 100\text{⫽}n`.)
1764 The ``widths`` `table directive option`_ can be used to provide custom
1765 values.
1766
1767 .. [#fn:table-width]
1768 The default width :math:`w` of a table with :math:`n` columns and
1769 ``colwidth`` [#fn:colwidth]_ values :math:`w_i` is computed using
1770 the equation
1771
1772 .. math::
1773 w = \frac{100\,\%}{40} \left( n + \sum_{i=1}^n w_i \right)
1774
1775 with an upper limit of 100%.
1776
1777 .. For details see `docutils.writers.latex2e.Table.get_colspecs()`.
1778
1779 .. _colwidth: ../ref/doctree.html#colwidth
1780 .. _CSV table: ../ref/rst/directives.html#csv-table
1781 .. _document tree: ../ref/doctree.html
1782 .. _legacy_column_widths: config.html#legacy-column-widths
1783 .. _list table: ../ref/rst/directives.html#list-table
1784 .. _percentage: ../ref/rst/restructuredtext.html#percentage-unit
1785 .. _table directives: ../ref/rst/directives.html#tables
1786 .. _table directive option: ../ref/rst/directives.html#table-options
1787 .. _table markup: ../ref/rst/restructuredtext.html#tables
1788 .. _table_style: config.html#table-style-latex-writers
1789
1790
1791 table of contents
1792 -----------------
1793
1794 A `contents directive`_ is replaced by a table of contents (ToC).
1795
1796 Setting:: use-latex-toc_
1797
1798 With use-latex-toc (default since release 0.6):
1799
1800 * The ToC is generated by LaTeX (via the ``\tableofcontents`` command).
1801
1802 The layout depends on the chosen document class and can be configured
1803 in a custom `style sheet`_ (see, e.g., [scrguide]_ for the `KOMA-script`_
1804 classes).
1805
1806 * The depth of the ToC and PDF-bookmarks can be configured
1807
1808 + with the ``depth`` option of the `contents directive`_, or
1809
1810 + in a style sheet with e.g. ``\setcounter{tocdepth}{5}``.
1811
1812 * Local ToCs are done with the minitoc_ package. See the `minitoc
1813 documentation`_ for the numerous configuration options.
1814
1815 .. note::
1816 Minitoc supports local ToCs only at "part" and top section level
1817 ("chapter" or "section"). Local "contents" directives at lower levels
1818 are ignored (a warning is issued).
1819
1820 This is an intended feature of the minitoc_ package. If you really
1821 require local ToCs at lower level, turn off the use-latex-toc_ option.
1822
1823 .. _use-latex-toc: config.html#use-latex-toc
1824 .. _contents directive: ../ref/rst/directives.html#table-of-contents
1825 .. _minitoc: https://ctan.org/pkg/minitoc
1826 .. _minitoc documentation:
1827 https://mirrors.ctan.org/macros/latex/contrib/minitoc/minitoc.pdf
1828
1829
1830 title reference role
1831 --------------------
1832
1833 `Title reference`_ is the default `default role`_ for `interpreted text`_.
1834
1835 Command:
1836 ``\DUroletitlereference``
1837
1838 Default:
1839 use slanted font (``\textsl``)
1840
1841 Example:
1842 set title references with a bold monospace font::
1843
1844 \newcommand{\DUroletitlereference}[1]{\texttt{\textbf{#1}}}
1845
1846 .. _title reference: ../ref/rst/roles.html#title-reference
1847 .. _default role:
1848 ../ref/rst/directives.html#setting-the-default-interpreted-text-role
1849 .. _interpreted text: ../ref/rst/restructuredtext.html#interpreted-text
1850
1851
1852 titles
1853 ------
1854
1855 The titles of admonitions_, sidebar_, and `topic element`_ use
1856 the ``\DUtitle`` command which can be re-defined in the corresponding
1857 DUCLASS environment.
1858
1859 * The re-definition is local to the environment, so you don't need to
1860 save/restore the original function.
1861
1862 * In the nested function redefinition, the argument placeholder requires
1863 two hashes, ``#1`` → ``##1``!
1864
1865 Example 1:
1866 a centered and somewhat larger title for topcis::
1867
1868 \newcommand*{\DUCLASStopic}{
1869 \renewcommand*{\DUtitle}[1]{\subsection*{\centering ##1}}
1870 }
1871
1872 Example 2:
1873 a right-pointing hand as title for the "attention" admonition::
1874
1875 \usepackage{pifont}
1876 \newcommand*{\DUCLASSattention}{
1877 \renewcommand*{\DUtitle}[1]{\ding{43}}
1878 }
1879
1880 The title argument is "swallowed" by the command.
1881 To have both, hand and title use::
1882
1883 \usepackage{pifont}
1884 \newcommand*{\DUCLASSattention}{
1885 \renewcommand*{\DUtitle}[1]{\ding{43} ##1}
1886 }
1887
1888
1889 text encoding
1890 -------------
1891
1892 The encoding of the LaTeX source file is Docutils' *output* encoding
1893 but LaTeX' *input* encoding.
1894
1895 Setting: output_encoding_
1896
1897 Default:
1898 "utf-8" (LaTeX's default input encoding)
1899
1900 Example:
1901 Encode the LaTeX source file with the ISO `latin-1` (west european)
1902 8-bit encoding (the default in Docutils versions up to 0.6.)::
1903
1904 --output-encoding=latin-1
1905
1906 Note:
1907 8-bit LaTeX comes with two packages for UTF-8 support,
1908
1909 .. class:: field-indent-4em
1910
1911 :utf8: by the standard `inputenc`_ package with only limited coverage
1912 (mainly accented characters).
1913
1914 :utf8x: supported by the `ucs`_ package covers a wider range of Unicode
1915 characters than does "utf8". It is, however, a non-standard
1916 extension and no longer developed.
1917
1918 .. with utf8x:
1919 If LaTeX issues a Warning about unloaded/unknown characters adding ::
1920
1921 \PreloadUnicodePage{n}
1922
1923 (where *n* is the Unicode page-number) to the style sheet might help.
1924
1925 .. _output_encoding: config.html#output-encoding
1926 .. _inputenc: https://ctan.org/pkg/inputenc
1927 .. _ucs: https://ctan.org/pkg/unicode
1928
1929
1930 topic element
1931 -------------
1932
1933 A topic_ is like a block quote with a title, or a self-contained section
1934 with no subsections. Topics and rubrics can be used at places where a
1935 `section title`_ is not allowed (e.g. inside a directive).
1936
1937 Example:
1938 Use a standard paragraph for a topic::
1939
1940 \newcommand{\DUCLASStopic}{%
1941 \renewenvironment{quote}{}{}%
1942 }
1943
1944 .. _topic: ../ref/rst/directives.html#topic
1945 .. _section title: ../ref/rst/restructuredtext.html#sections
1946
1947
1948 transition element
1949 ------------------
1950
1951 Transitions__ are commonly seen in novels and short fiction, as a gap
1952 spanning one or more lines, marking text divisions or signaling changes in
1953 subject, time, point of view, or emphasis.
1954
1955 Command:
1956 ``\DUtransition``
1957
1958 Default:
1959 A horizontal line, 1/3 of text width
1960
1961 Example 1:
1962 Use three stars::
1963
1964 \newcommand*{\DUtransition}{\centering{}*\quad*\quad*}
1965
1966 Alternatively use the more elaborated version in `transition-stars.sty`_.
1967
1968 Example 2:
1969 If paragraphs are separated by indentation, you can simply use a vertical
1970 space::
1971
1972 \newcommand*{\DUtransition}{\vspace{2ex}}
1973
1974 __ https://docutils.sourceforge.io/docutils/docs/ref/rst/restructuredtext.html#transitions
1975 .. _transition-stars.sty: ../../../sandbox/stylesheets/transition-stars.sty
1976
1977
1978 Changes
1979 =======
1980
1981 * The Docutils HISTORY_ lists all changes during the history of docutils.
1982 Important changes are summarized in the RELEASE-NOTES_.
1983
1984 .. _HISTORY: ../../HISTORY.html
1985 .. _RELEASE-NOTES: ../../RELEASE-NOTES.html
1986
1987
1988 Problems
1989 ========
1990
1991 Troubleshooting
1992 ---------------
1993
1994 Bad looking PDF output
1995 ``````````````````````
1996
1997 What I am looking for when I try Docutils is PDF files of high quality.
1998 Unfortunately that never is the case.
1999
2000 So am I just stupid or is there a way to get really high quality PDF
2001 from Docutils?
2002
2003 Make sure the default font is not a bitmap font.
2004
2005 There is `Latin Modern`_ if you like the look of the standard font on paper,
2006 but want nice pdf. Or select something else like Times, Palatino, ... via
2007 configuration settings_. See font_ and font-encoding_.
2008
2009
2010 footnote mark and text at different pages
2011 `````````````````````````````````````````
2012
2013 Docutils stores the footnote text in a separate node, at the position where
2014 it is specified in the input document. With the default settings, the
2015 footnote is put at the bottom of the page where the footnote text is located,
2016 maybe far away from the footnote mark (see e.g. `<rst/demo.rst>`_).
2017
2018 To get footnote mark and text at the same page, keep footnote mark and
2019 footnote text close together or use the latex_footnotes_ setting.
2020
2021 empty line before footnote content
2022 ``````````````````````````````````
2023
2024 If footnotes_ start with any `body element`_ other than a paragraph,
2025 there is a spurious vertical space after the footnote number/symbol.
2026 `This is a LaTeX limitation.`__
2027
2028 __ https://tex.stackexchange.com/a/237391/288060
2029
2030 non-breaking hyperlinks
2031 ```````````````````````
2032
2033 If you convert with ``latex`` (as opposed to ``pdflatex``), hyperlinks will
2034 not wrap and sometimes stick into the margin.
2035
2036 Wrong:
2037 ::
2038
2039 \usepackage[breaklinks=true]{hyperref}
2040
2041 "breaklinks" is an internal option that indicates whether the chosen
2042 driver can handle split links. (It might work to *disable* link breaking.)
2043
2044 Right:
2045 Use one of the following:
2046
2047 a) compile with pdflatex_,
2048
2049 b) use the package breakurl_,
2050
2051 c) (for printout) `disable hyperlinks`_ using the package "nohyperref".
2052
2053 See also the `Link text doesn’t break at end line`_ LaTeX FAQ entry.
2054
2055 .. _breakurl: https://ctan.org/pkg/breakurl
2056 .. _Link text doesn’t break at end line: https://texfaq.org/FAQ-breaklinks
2057
2058
2059 Glyph not defined in PD1 encoding
2060 `````````````````````````````````
2061
2062 If a section title or other link contains non-Latin (e.g. Cyrillic)
2063 characters, the LaTeX log contains lots of warnings like::
2064
2065 Package hyperref Warning: Glyph not defined in PD1 encoding,
2066 (hyperref) removing `\CYRZ' on input line 6.
2067 ...
2068
2069 This can be solved with the "unicode" hyperref_option_ setting::
2070
2071 --hyperref-option=unicode
2072
2073 (works also with non-unicode input/output encoding (e.g. "koi8r" or
2074 "latin1"). Newer versions of hyperref default to "unicode=true".
2075
2076 .. _hyperref_option: config.html#stylesheet-latex-writers
2077
2078
2079 image inclusion
2080 ```````````````
2081
2082 Images_ are included in LaTeX with the help of the `graphicx`_ package.
2083 The supported graphic formats depend on the postprocessor:
2084
2085 * pdflatex_, lualatex_, and xelatex_ work with PNG, JPG, and PDF
2086 but *not EPS*.
2087
2088 * When compiling to DVI with the ``latex`` command, support depends on
2089 the viewer or post-processor:
2090
2091 - dvips supports EPS but not other format,
2092 - dvipdfmx works with EPS and JPG (add 'dvipdfmx' to the documentoptions_
2093 or graphicx-option_ setting and 'bmpsize' to the stylesheet_ setting).
2094
2095 * SVG images are supported if the `"svg" package`_ is listed in the
2096 stylesheet_ setting. Pass the ``--shell-escape`` option to the LaTeX
2097 compiler to enable image conversion on the fly by Inkscape_.
2098 (New in Docutils 0.22.)
2099
2100 * The Rubber_ wrapper can be used for automatic image conversion.
2101
2102 For details see [grfguide]_.
2103
2104 Docutils expects a URI-reference_ as pointer to the image ressource.
2105 The LaTeX writer transforms it to a filesystem path.
2106 By default, LaTeX does not accept spaces and more than one dot in the
2107 filename. If using "traditional" filenames is not an option, loading the
2108 grffile_ package may help.
2109
2110 .. _images: ../ref/rst/directives.html#images
2111 .. _graphicx: https://ctan.org/pkg/graphicx
2112 .. _graphicx-option: config.html#graphicx-option
2113 .. _URI-reference: https://www.rfc-editor.org/rfc/rfc3986.html#section-4.1
2114 .. _"svg" package: https://ctan.org/pkg/svg
2115 .. _Inkscape: https://inkscape.org/
2116 .. _grffile: https://ctan.org/pkg/grffile
2117
2118
2119 Why are my images too big?
2120 ``````````````````````````
2121
2122 In LaTeX, the size of the *pixel unit* defaults to 1 px = 1/72 in
2123 while the `CSS3 pixel unit`_ is defined as 1 px = 1/96 in.
2124
2125 This is why pixmap images without size specification or objects with a size
2126 specified in ``px`` tend to come out too large in the PDF.
2127
2128 Solution:
2129 Specify the image size in fixed `length units`_ (``pt``, ``cm``, ``in``, …)
2130 or configure the `size of a "px"`_.
2131
2132
2133 Error ``illegal unit px``
2134 `````````````````````````
2135
2136 If you convert the LaTeX source with a legacy program, you might get this
2137 error.
2138
2139 The unit "px" was introduced by the `pdfTeX` converter on 2005-02-04.
2140 `pdfTeX` is used also for conversion into DVI format in all modern LaTeX
2141 distributions (since ca. 2006).
2142
2143
2144 Error ``Symbol \textcurrency not provided`` ...
2145 ```````````````````````````````````````````````
2146
2147 The currency sign (\\u00a4) is not supported by all fonts (some have
2148 an Euro sign at its place). You might see an error like::
2149
2150 ! Package textcomp Error: Symbol \textcurrency not provided by
2151 (textcomp) font family ptm in TS1 encoding.
2152 (textcomp) Default family used instead.
2153
2154 (which in case of font family "ptm" is a false positive).
2155
2156 Add either ``warn`` (turn the error in a warning, use the default (bitmap)
2157 symbol), or ``force,almostfull`` (use the symbol provided by the font at
2158 the users risk) to the document options or use a different font package.
2159
2160
2161 Warning: language … not supported
2162 `````````````````````````````````
2163
2164 The "latex" writer uses the LaTeX package Babel_ and the "xetex" writer
2165 uses Polyglossia_ for language_ support (hyphenation rules, auto-text
2166 localisations and typographic rules). Polyglossia_ supports more
2167 languages, so switching to the "xetex" writer may help.
2168
2169 For short quotes or if language support is provided by the user via other
2170 `LaTeX document classes and packages`_, the warning can be ignored.
2171
2172 .. _Babel: https://ctan.org/pkg/babel
2173 .. _Polyglossia: https://ctan.org/pkg/polyglossia
2174
2175
2176 Search and text extraction
2177 ``````````````````````````
2178
2179 Search for text that contains characters outside the ASCII range might
2180 fail. See font_ and `font encoding`_ (as well as `Searching PDF files`_
2181 for background information).
2182
2183 It may help to load the `cmap` package (via `style sheets`_ or the custom
2184 `LaTeX preamble`_ (see also `Proper use of cmap and mmmap`_).
2185
2186 .. _Searching PDF files: https://texfaq.org/FAQ-cpy-srchpdf
2187 .. _Proper use of cmap and mmmap:
2188 https://tex.stackexchange.com/questions/64409/proper-use-of-cmap-and-mmap
2189
2190
2191 Unicode box drawing and block characters
2192 ````````````````````````````````````````
2193
2194 The easiest solution is to use xelatex_ or lualatex_ which directly
2195 support all Unicode characters (if included in the used font).
2196
2197 With "traditional" TeX engines (e.g. pdflatex_):
2198
2199 - Generate LaTeX code with the default `output_encoding`_ "utf-8".
2200
2201 - Add the pmboxdraw_ package to the `style sheets`_.
2202 (For shaded boxes also add the `color` package.)
2203
2204 Unfortunately, this defines only a subset of the characters
2205 (see pmboxdraw.pdf_ for a list).
2206
2207 .. _pmboxdraw: https://ctan.org/pkg/pmboxdraw
2208 .. _pmboxdraw.pdf:
2209 https://mirrors.ctan.org/macros/latex/contrib/pmboxdraw/pmboxdraw.pdf
2210
2211
2212 Bugs and open issues
2213 --------------------
2214
2215 Open to be fixed or open to discussion.
2216
2217 See also the entries in the `Docutils TODO list`_,
2218 the BUGS_ documentation and the `SourceForge Bug Tracker`_.
2219
2220 .. _Docutils TODO list: ../dev/todo.html#latex-writer
2221 .. _bugs: ../../BUGS.html
2222 .. _SourceForge Bug Tracker: https://sourceforge.net/p/docutils/bugs/
2223
2224
2225 Citations
2226 `````````
2227
2228 Initially citations were implemented using figure floats, because hyperlinking
2229 back and forth seemed to be impossible. Later the `figure directive`_ was
2230 added that puts images into figure floats.
2231
2232 This results in citations and figures possibly being mixed at page foot.
2233
2234 Solution:
2235 Select citation handling with the use_latex_citations_ setting.
2236
2237 If ``use_latex_citations`` is True, a bibliography is inserted right at
2238 the end of the document. *TODO: This should be customizable*.
2239
2240 If ``use-latex-citations`` is used adjacent citation references (separated
2241 only by a single space or a newline) are combined to a single citation
2242 group, i.e. ``[cite1]_ [cite2]_`` results in ``\cite{cite1,cite2}``.
2243 The appearance in the output can be configured in a `style sheet`_.
2244
2245 .. _figure directive: ../ref/rst/directives.html#figure
2246 .. _use_latex_citations: config.html#use-latex-citations
2247
2248
2249 Tables
2250 ``````
2251
2252 * Too wide tables:
2253
2254 - Turn off the legacy_column_widths_ setting (cf. `bug #422`_)
2255 or manually set the `table width`_.
2256
2257 * Table cells with both multirow and multicolumn are currently not possible.
2258
2259 .. _bug #422: https://sourceforge.net/p/docutils/bugs/422/
2260
2261
2262 Figures
2263 ```````
2264
2265 * Figures are always as wide as the containing text. The "figwidth" argument
2266 is currently not supported. As a consequence, the "align" argument has no
2267 effect.
2268
2269 * Wrapping text around figures is currently not supported. (Requires the
2270 `wrapfig`_ package.)
2271
2272 .. _wrapfig: https://ctan.org/pkg/wrapfig
2273
2274
2275 Miscellaneous
2276 `````````````
2277
2278 * Pdfbookmark level 4 (and greater) does not work (might be settable but
2279 complicated).
2280
2281 * Hyperlinks are not hyphenated; this leads to bad spacing.
2282 See ``docs/user/rst/demo.rst`` section 2.14 "directives".
2283
2284
2285 References
2286 ==========
2287
2288 .. [clsguide] `LaTeX for package and class authors`,
2289 https://mirrors.ctan.org/macros/latex/base/clsguide.pdf
2290 .. [encguide] `LaTeX font encodings`,
2291 https://mirrors.ctan.org/macros/latex/base/encguide.pdf
2292 .. [grfguide] `Packages in the ‘graphics’ bundle`
2293 https://mirrors.ctan.org/macros/latex/required/graphics/grfguide.pdf
2294 .. [scrguide] `KOMA - Script a versatile LATEX 2ε bundle`,
2295 https://mirrors.ctan.org/macros/latex/contrib/koma-script/doc/scrguide-en.pdf
2296 .. [usrguide] `LaTeX2e for authors`,
2297 https://www.latex-project.org/guides/usrguide.pdf