1   Generating LaTeX with Docutils

Author:Engelbert Gruber, Guenter Milde
Revision:$Revision: 7904 $
Date:$Date: 2015-08-12 15:22:32 +0000 (Wed, 12 Aug 2015) $

このドキュメントは、パブリック ドメインで公開されています。


1.1   Introduction

This document covers topics specific to Docutils' LaTeX export. For an introduction to LaTeX see, e.g., LaTeX2e for authors. There exists a wide selecton of LaTeX Documentation on the net and books on LaTeX and related topics.

There are two approaches to typeset documents from reStructuredText sources via LaTeX:

  1. treat LaTeX as a document format (like HTML):

    Transform the internal markup into corresponding LaTeX markup. For example, a section title would be written with the LaTeX section command: \section{this section title}.

    This keeps the document structure and semantic markup produing a readable LaTeX file, but may require hacking around Docutils — LaTeX incompatibilities.

    As with HTML, styling is mostly done via style sheets or LaTeX packages.

    If you prefer this approach, try the latex2e or the xetex writer.

  2. treat LaTeX as a page description format (like Postscript):

    Use LaTeX as a typesetting system to produce the desired output without representing document structure in the LaTeX source. This will work around Docutils-incompatible features in LaTeX but produces a hard to read LaTeX file. Styling is done via options to the latex writer.

    The (orphaned) newlatex writer (rst2newlatex.py) uses LaTeX as a typesetter without caring about producing readable/stylable LaTeX files.

This documents describes the first approach used by the latex2e and xetex writers.

1.2   LaTeX

Unlike HTML/CSS, LaTeX provides one common language for markup and style definitions. Separation of content and style is realized by collecting style definitions in the documentclass, LaTeX packages, or the document preamble.

1.2.1   LaTeX packages

LaTeX packages (similar to Python modules or C libraries) provide means to extend or modify the LaTeX language by redefining macros or providing new ones. There is a huge selection of packages (standard as well as user contributed) coming with your TeX distribution or available at CTAN (see the TeX Catalogue).

1.2.2   Docutils special LaTeX macros

Some Docutils objects have no LaTeX counterpart, they will be typeset using a Docutils specific LaTeX macro (command, environment, or length) to allow customization. By convention, special macros use the prefix \DU[1].

The generated LaTeX documents should be kept processable by a standard LaTeX installation. Therefore fallback definitions are included after the custom style sheets, if a macro is required in the document.

  • Custom style sheets can define alternative implementations with \newcommand, \newenvironment, and \newlength followed by \setlength.
  • Definitions with raw LaTeX are part of the document body. Use \def, \renewcommand or \renewenvironment, and \setlength.

See the test output standalone_rst_latex.tex for an example of the fallback definitions and their use in the document.

[1]DU for Documentation Utilities = Docutils

1.2.3   Length units

LaTeX supports all length units defined for Docutils plus the following less common units:

pt:typewriter's (or LaTeX) point (1 pt = 1/72.27 in)
dd:didôt (1 dd = 1238/1157 pt)
cc:cîcero (1 cc = 12 dd)
sp:scaled point (1sp = 1/65536pt)


Different definitions of the unit "pt"!

  • In Docutils (as well as CSS) the unit symbol "pt" denotes the Postscript point or DTP point.

  • LaTeX uses "pt" for the LaTeX point, which is unknown to Docutils and 0.3 % smaller.

  • The DTP point is available in LaTeX as "bp" (big point):

    1 pt = 1/72.25 in < 1 bp = 1/72 in

Lengths specified in the document with unit "pt" will be given the unit "bp" in the LaTeX source.

In raw LaTeX and custom style sheets, the DTP point must be specified as "bp", while "pt" is interpreted as LaTeX point.

The default length unit (added by Docutils to length specifications without unit) is the "DTP point".

For more on lengths in LaTeX, see e.g. Hypertext Help with LaTeX: Lengths

1.3   PDF generation

In most cases, LaTeX code is not the desired end-format of the document. LaTeX offers many ways to generate PDF documents from the LaTeX source, including:

Generates a PDF document directly from the LaTeX file.
latex + dvipdfmx
Use latex to generate a DVI file and dvipdfmx to produce a PDF file. If you take this approach, add dvipdfmx to the _documentoptions.
latex + dvips + ps2pdf
Produce a DVI file with latex, postscript with dvips and PDF with ps2pdf.
The XeTeX engine works with input files in UTF-8 encoding and system fonts. Export your document with the xetex writer (rst2xetex), if you want to go this route.

You need to call latex (or pdflatex/xelatex) twice (or even three times) to get internal references correct.

The Rubber wrapper for LaTeX and friends can be used to automatically run all programs the required number of times and delete "spurious" files. This includes processing bibliographic references or indices, as well as compilation or conversion of figures.

1.4   Configuration

The LaTeX code generation can be configured via

1.4.1   Options

Options can be specified as

  • command-line options (run rst2latex.py --help to get a list of available options), or
  • configuration settings (see Docutils Configuration for details).

1.4.2   LaTeX code

Custom LaTeX code can be placed in style sheets, the LaTeX preamble, the document body (raw LaTeX), or custom templates_.   Style sheets

A common way of LaTeX customization is the preparation of custom style sheets, either as simple files with LaTeX code snippets or as home-made LaTeX packages (see the clsguide for an introduction on LaTeX package writing).



It is possible to specify multiple style sheets and mix LaTeX packages with custom style sheets.

You cannot specify package options with the stylesheet setting. If you need to pass options to the package, use the \usepackage command in the LaTeX preamble or a custom style sheet.

Example 1:

Select Latin Modern fonts with the lmodern package:

Example 2:

Use the preamble.tex home-made custom style sheet together with the package kerkis (Bookman fonts):

Example 3:

Select Palatino fonts with old-style numbers and true small-caps with the LaTeX command


in the LaTeX preamble or custom style sheets.

Stylesheet Repository
There is a repository of user-contributed style sheets in the Docutils Sandbox.   LaTeX preamble

Configuration by LaTeX code in the document preamble is also possible without a separate stylesheet. This way, packages can be loaded with options or commands re-defined without the need to create a separate file (new in Docutils 0.7).

used for font setup

To use the better looking txtt font for monospaced text define the latex-preamble setting in a configuration file:

latex-preamble: \renewcommand{\ttdefault}{txtt}
                \usepackage{mathptmx}          % Times
                \usepackage[scaled=.92]{helvet}  % Helvetica   テンプレート

Some customizations require commands at places other than the insertion point of stylesheets or depend on the deletion/replacement of parts of the document. This can be done via a custom template. See the publisher documentation for a description of the document parts available in a template file.


In addition to the 'default.tex' template, the latex writer directory contains the alternative 'titlepage.tex'.


Print a title page including docinfo, dedication, and abstract:

--template=titlepage.tex   Raw LaTeX

By means of the raw directive or a derived custom role, one can give commands directly to LaTeX. These can be both, styling as well as printing commands.


Math formula:

.. raw:: latex

   \[x^3 + 3x^2a + 3xa^2 + a^3,\]

(Drawback: the formula will be invisible in other output formats.)

Most LaTeX code examples also work as raw LaTeX inside the document. An exception are commands that need to be given in the document preamble (e.g. package loading with \usepackage, which can be achieved with the --style-sheet or --latex-preamble command line options instead). Remember to use re-defining commands for customizing Docutils special LaTeX macros with raw LaTeX.


Define the transition command as page break:

.. raw:: latex

See also:

1.5   How to configure the ...

1.5.1   admonitions

Admonitions are specially marked "topics" that can appear anywhere an ordinary body element can.

Typeset in a frame (90 % of text width).

The admonition title is typeset with the \DUtitle command which also takes a class argument. See topic title

Example 1:

A lighter layout without the frame:

  % try \DUadmonition#1{#2}:
  \ifcsname DUadmonition#1\endcsname%
    \csname DUadmonition#1\endcsname{#2}%

The first part of this definition acts as a "dispatcher". This way it is possible to define a special handling of specific admonitions based on the "class" argument.

Example 2:

Use .. note:: for a margin note:


Make sure there is enough space to fit the note. See also the marginnote and pdfcomment packages.

1.5.2   custom interpreted text roles

The rst role directive allows defining custom text roles that mark parts of inline text (spans) with a class argument.

  • Role names and class arguments are converted to conform to the regular expression [a-z][-a-z0-9]* (see class directive).

  • Class arguments may contain numbers and hyphens, which need special treatment in LaTeX command names. (The special command \@namedef can help with the definition of corresponding commands.)

  • Custom roles can have multiple class arguments.

    In contrast to HTML/CSS, the order of the class arguments might matter.


\DUrole: dispatcher command

\DUroleCLASSARGUMENT: optional styling command

The definition of \DUrole{CLASSARGUMENT}{} calls the macro named \DUroleCLASSARGUMENT{}[2] if it is defined (but silently ignores this class argument if a corresponding macro is not defined).
[2]For backwards compatibility, the prefix \docutilsrole... in the styling commands also recognized.
Example 1:

Typeset text in small caps:

.. role:: smallcaps

:smallcaps:`Fourier` transformation

This is transformed to the LaTeX code:

\DUrole{smallcaps}{Fourier} transformation

The definition


as raw LaTeX or in the custom style sheet will give the expected result (if the text font supports small caps).

Example 2:

Subscript text in normal size and italic shape:

.. role:: sub(subscript)

As "sub" inherits from the standard "subscript" role, the LaTeX macro only needs to set the size and shape:

Example 3:

A role with several classes and a converted class name:

.. role:: custom4
   :class: argI argII arg_3

is translated to the nested commands:


With the definitions:

\newcommand{\DUroleargii}[1]{{\large #1}}

in a style sheet[3] or as raw LaTeX in the document source, text styled with :custom4:`large bold small-caps` will be typeset accordingly.

[3]Leave out the \makeatletter - \makeatother pair if the style sheet is a LaTeX package (*.sty).

1.5.3   definition lists

ReStructuredText definition lists correspond to HTML <dl> list objects.

description: LaTeX standard environment
\descriptionlabel: styling macro for the description term
bold label text, hanging indent

A non-bold label can be achieved with:

\renewcommand\descriptionlabel[1]{\hspace\labelsep \normalfont #1}

1.5.4   document class

There are hundreds of LaTeX document classes installed by modern LaTeX distributions, provided by publishers, or available at CTAN. The TeX Catalogue lists most of them.

Popular document classes:
  • article, report, book: standard document classes
  • scrartcl, scrrprt, scrbook: KOMA-script classes
  • memoir: highly configurable class for larger documents

1.5.5   document info

Content of the bibliographic fields at the top of a document. By default, docinfo items are typeset as a table.

use-latex-docinfo, use-latex-abstract
\DUdocinfowidth: the width for the docinfo table.
90 % of text width: 0.9\textwidth

set to 70 % of text width:


1.5.6   document title

A lone top-level section title is (usually) transformed to the document title (see section structure).

The format of the document title is defined by the document class. The "article" document class uses an in-page title and the "report" and "book" classes write a separate title page. See the TeX FAQ on how to customize the style of document titles.

The default title page shows only title and subtitle, date and author are shown in the document info table.



--template=titlepage.tex Put docinfo and abstract into the title page. A separate title page is used also with the "abstract" document class.

1.5.7   field lists

Field lists may be used as generic two-column table constructs in documents.

Indented description list.

Use a description list customized with enumitem:


The KOMA-script classes provide a similar environment under the name labeling.

1.5.8   figure and table captions

The caption package provides many ways to customise the captions in floating environments like figure and table.

The chngcntr package helps to configure the numbering of figure and table caption numberings.

Some document classes (e.g. KOMA-script) provide additional configuration. Also see the related LaTeX FAQ entry


1.5.9   figure placement

Figures might be typeset at the place of definition (default) or "float" to a suitable place at the top or bottom of a page. This is implemented using the float package.


The placement setting is valid from the point of definition until the next \floatplacement command or the end of the document. See float.pdf for details.

\floatplacement{figure}{H} (here definitely). This corresponds most closely to the source and HTML placement (principle of least surprise).
Example 1:

In a custom style sheet, set the default to let LaTeX find a suitable place for figure floats:

\floatplacement{figure}{htbp} % here, top, bottom, extra-page
Example 2:

To move all following figures to the top or bottom of the page write in the document source:

.. raw:: latex


1.5.10   font

The selected text font influences the look, the feel, and the readability of the document (cf. http://www.csarven.ca/web-typography). Selecting a suitable font also solves the problem with bad looking PDF output.

Font selection is one of the main differences between LaTeX and XeTeX:

cannot use the fonts of the operating system directly but needs specially installed fonts with additional supporting files.
can use system fonts and provides access to the full feature set of modern OpenType fonts.

The default font setup is done in the latex-preamble:

PDF standard fonts (Times, Helvetica, Courier)

Linux Libertine, a free, high quality alternative to Times with a wide coverage of glyphs, styles, and OpenType features.

Despite its name, Linux Libertine can be used on any operating system that can handle OpenType fonts.

Alternative fonts can be selected by

  1. specifying the corresponding LaTeX package(s) as argument to the stylesheet option or with the \usepackage LaTeX command.
  2. changing the font-default macros \rmdefault, \sfdefault and/or \ttdefault in a custom style sheet, the LaTeX preamble or raw LaTeX.
Example 1:

Use Latin Modern. LaTeX code:


Command line argument:

Example 2:

The Times/Helvetica/Courier PDF standard fonts are selected by the LaTeX code [4]:

\usepackage{mathptmx}            % Times for serif and math
\usepackage[scaled=.90]{helvet}  % downscaled Helvetica for sans serif
\usepackage{courier}             % Courier for teletype (mono-space)

Since Docutils 0.7, this is the default value of the latex-preamble option.

[4]When generating PDF-files from LaTeX, the PDF standard fonts do not need to be embedded in the document. While this results in smaller files, the actually used fonts on screen and in print might differ! (For details see, e.g., the testflow package documentation.)
Example 3:

Use the teletype font from the txfonts package. As there is no package for this, we re-define the font macro with the LaTeX code:


using the macros of the fontspec package. Use some font-viewer or -manager (e.g. fontmatrix) to find out the correct names of the fonts on your system.


DejaVu, very wide coverage, screen optimized. As this font runs wide, add DIV=10 to the documentoptions:

\setmainfont{DejaVu Serif}
\setsansfont{DejaVu Sans}
\setmonofont[HyphenChar=None]{DejaVu Sans Mono}   choice of suitable fonts

High quality free fonts suitable for use with XeTeX are, e.g., listed at Good Libre Fonts, 25 Best Free Quality Fonts and the update 19 More Free Quality Fonts.

The LaTeX Font Catalogue provides information and examples for a wide range of fonts available for use with LaTeX. Here is just a selection:

  1. The Latin Modern (LM) fonts are extended outline versions of the standard TeX font Computer Modern (CM).


    simple invocation: --stylesheet=lmodern


    keeps the traditional TeX "look and feel":


    generally accepted as high quality CM replacement,


    comprehensive math support,


    including optical sizes,


    compatible with extensions made to match CM,


    modern types are hard to read at low (screen) resolutions.


    not part of a minimal standard TeX installation


    might not work out-of-the-box


    large additional download (ca. 12 ... 17 MB)

  2. CM-Super is another outline CM replacement.


    simple invocation: modern LaTeX distributions use CM-Super automatically instead of CM if it is installed.


    said to be of inferior quality compared to LM.


    not part of a minimal standard TeX installation, even bigger download size than Latin Modern.

  3. Bera (Bitstream Vera)


    simple invocation: --stylesheet=bera


    optimized for on-screen viewing with goot hinting


    not part of a minimal standard TeX installation

  4. PSNFSS Postscript fonts


    part of every standard TeX installation


    smaller PDF/Postscript document size if standard fonts are not embedded


    restricted set of glyphs in the free versions [5]


    different fonts for roman, sans-serif and typewriter fonts.


    invocation somewhat more complex, as several packages are required for a complete font set, sometimes including package options.

    Roman (serif) PSNFSS fonts:


    good legibility but very wide.


    bread-and-butter type optimized for printing on low-resolution printers

    New Century Schoolbook

    good legibility but very wide.


    recommended by font experts


    good LaTeX support including matching math fonts, small caps, old-style figures


    bad rendering in xpdf viewer (auto-hinting leads to different x-hight for different characters at some magnifications) (this is fixed in recent versions).


    the serif PDF Standard Font,


    overused and quite narrow (devised for multi-column layouts).


    recommended by font experts

    Font packages for standard Postscript fonts (cf. Using common Postscript fonts with LaTeX)
    Package Roman Sans Serif Typewriter


    (none) CM Roman CM Sans Serif CM Typewriter CM Math
    mathpazo Palatino     Palatino
    mathptmx Times     Times
    helvet   Helvetica    
    avant   Avant Garde    
    courier     Courier  
    chancery Zapf Chancery      
    bookman Bookman Avant Garde Courier  
    newcent New Century Schoolbook Avant Garde Courier  
    charter Charter      
    utopia Utopia      
[5]Extended versions of the standard Postscript fonts including accented chars, Greek and Cyrillic as well as real small-caps and old-style numbers are available with the TeX Gyre bundle which is part of, e.g., TeX Live.

1.5.11   font encoding

LaTeX font encodings are described in detail in the encguide which is part of the LaTeX base documentation.

Example 1:

Use the (obsolete) LaTeX default encoding "OT1":


or (without loading the fontenc package):


This will improve the look on screen with the default Computer Modern fonts at the expense of problems with search and text extraction The recommended way is to select a T1-encoded "Type 1" (vector) font, for example Latin Modern

Example 2:

Support for characters in the Unicode blocks Latin, Latin-1 Supplement, and Greek together with a T1-encoded "Type 1" (vector) font, for example Latin Modern:

--font-encoding=LGR,T1 --stylesheet=lmodern

1.5.12   font size

Add font size in points to the document options, e.g. --documentoptions=12, use e.g. the document classes provided by extsizes for values other than [10,11,12].

1.5.13   footnotes

By default, footnotes are set with Docutils-specific wrappers around the standard \footnotemark and \footnotetext commands. You can configure the footnote layout similar to standard LaTeX footnotes in a custom style sheet or the LaTeX preamble.

Further configuration is possible by alternative definitions of \DUfootnotemark and \DUfootnotetext

Example 1:

Set footnote text with a hanging indent.

  • This is the default with KOMA-script classes, e.g:


    (for further configuration, see the KOMA-script Guide),

  • with package footmisc:


    (play with the \footnotemargin setting),

  • redefine \DUfootnotetext inserting hangindent:

        \footnotetext{\hangindent=2em #4}%

    (adapt the \hangindent value).

Example 2:

Footnote marks in normal font size, not superscript:

\usepackage{scrextend} % not required with KOMA-script document classes
\deffootnote{1em}{1em}{\thefootnotemark\ }

(See the KOMA-script Guide for details and other options.)

Example 3:

Place the footnote text where it appears in the source document (instead of at the page bottom). This can be used to get the effect of endnotes (needs the hanging package):


1.5.14   hyphenation

The amount of hyphenation is influenced by \hyphenpenalty, setting it to 10000 almost prevents hyphenation. As this produces lines with more space between words one should increase Latex's \tolerance for this.


1.5.16   line blocks

In line blocks, newlines and leading whitespace are respected.

DUlineblock: special list environment for line blocks
\DUlineblockindent: indentation of indented lineblock parts.
2.5 times the font hight: 2.5em

set to the paragraph indentation:


1.5.17   line spacing


\linespread: for small adjustments

\singlespacing, \onehalfspacing, and \doublespacing: from package setspace

Example 1:

Get document wide double spacing:

Example 2:

Increase line spacing by five percent for better readability:


1.5.18   literal blocks

No markup processing is done within a literal block. It is left as-is, and is typically rendered in a monospaced typeface




The lstlisting environment is highly configurable (as documented in listings.pdf), for instance

\lstset{language=Python, morekeywords=[1]{yield}}

The indentation of literal blocks can be reset with


and/or configured with e. g.:


1.5.19   list of figures/tables

Docutils does not support lists of figures or tables.

However, with LaTeX, they can be generated using raw LaTeX in the document source.


\listoffigures: a list of figures

\listoftables: a list of tables

.. raw:: latex


1.5.20   option list

Option lists are two-column lists of command-line options and descriptions, documenting a program's options.

DUoptionlist: environment for option lists,
\DUoptionlistlabel: set appearance of the options

set command options with a bold monospace font:

\newcommand{\DUoptionlistlabel}{\texttt{\textbf{#1}} \hfill}

1.5.21   page breaks

  • Page breaks before top-level sections are the default with a documentclass that provides "chapters", e.g. "book", "memoir" or "scrbook".
  • Redefining the section or section* command in a style sheet is possible too.
  • Raw LaTeX or a custom role can be used.
  • The transition element can be re-defined to produce a page break,

\newpage: hard pagebreak at exactly this position

\pagebreak[2]: recommended page break after line end (precedence 1...4)


Define the transition command as page break with the LaTeX code:


(use \renewcommand with raw LaTeX).

1.5.22   page layout

By default, paper size and margin settings are determined by the document class.

The following packages help to configure the page layout:

  1. The typearea package (part of the KOMA-script bundle) calculates a good page layout (based on rules and recommendations of typography experts).

    See the KOMA-Script Guide for details on what is a good layout and how this is achieved.

  2. The geometry package is recommended if you have to follow guidelines with fixed values for the margins. For details see the geometry manual.

Example 1:

Let typearea determine the type area with DIV=calc in the documentoptions:


The DIV option can also be specified, like DIV=10. It defines how "crowded" a page will be: larger values mean larger text area (at the expense of readability).

Example 2:

LaTeX code to set margins with the geometry package:


1.5.23   page headers and footers

With the fancyhdr package or the KOMA-script classes, you can define custom page head- and foot-lines.

The "header" and "footer" directives save their content in the macros \DUheader rsp. \DUfooter. The macros can be used in LaTeX code and will be replaced by LaTeX with the content of the directives.


LaTeX code to place left-aligned "header" and "footer" on every page with fancyhdr:

\fancyfoot{} % reset

1.5.24   page numbering


Number pages by chapter (using the chappg package):


See the chappg documentation for details.

1.5.25   paper size

Paper geometry can be changed using --documentoptions or with the geometry package.

LaTeX code:


Some possibilities:

  • a4paper, b3paper, letterpaper, executivepaper, legalpaper
  • landscape, portrait, twoside.

Choose A5 pager in landscape orientation with command line argument:


The same with LaTeX commands in the style sheet:


For details see the geometry manual.

1.5.26   paragraph indent

Default (in most document classes):
Indent the first line in a paragraph unless it is the first line of a chapter, section, subsection, or subsubsection.

To set paragraph indentation to zero but add a vertical space between load the parskip package with the command line argument:


or in a custom style sheet with:


1.5.27   rubric

A rubric is like an informal heading that doesn't correspond to the document's structure.

subsubsection style, italic, centred

set flushleft and red:


1.5.28   section numbering

Sections are numbered if there is a sectnum directive in the document.

Option: sectnum_xform
--section-numbering, --no-section-numbering

If sectnum_xform is False, section numbers are generated by LaTeX. In this case the "prefix" and "suffix" arguments of the sectnum directive are ignored. The section number style is determined by the document class and can be configured in a LaTeX style sheet, e.g.:



The LaTeX name is 'secnumdepth' (whithout 't').

1.5.30   size of a pixel

The length unit px is a "relative length" whose value depends on the resolution of the output device (usually specified in dots per inch (DPI). However, when producing a PDF, the resolution of the output device (printer, screen (for PDF-viewer)) is generally not known.

With pdftex, the "resolution" is a configuration setting.

72 DPI, i.e. 1 px = 1/72 in.

Set a resolution of 96 DPI with the LaTeX code:

\pdfpxdimen=1in % 1 DPI
\divide\pdfpxdimen by 96 % 96 DPI

1.5.31   topic element

A topic is like a block quote with a title, or a self-contained section with no subsections.

Topics and rubrics can be used at places where a section title is not allowed (e.g. inside a directive).

"quote" environment
Example 1:

If you generally prefer a "normal" section over a block quote, define:

  \ifcsname DUtopic#1\endcsname%
    \csname DUtopic#1\endcsname{#2}%
Example 2:

If you want a "normal" section for topics with class argument "noquote", define:


1.5.32   topic title

The titles of admonitions, sidebar, and topic element are defined with the \DUtitle command that also takes a "class" argument.

Example 1:

a centered and somewhat larger title for topcis:

\newcommand*{\DUtitletopic}[1]{\subsection*{\centering #1}
Example 2:

a right-pointing hand as title for the "attention" directive:


The title argument is "swallowed" by the command. To have both, hand and title use:

\newcommand{\DUtitleattention}[1]{\ding{43} #1}

1.5.33   table of contents

A contents directive is replaced by a table of contents (ToC).

Option: use-latex-toc
--use-latex-toc, --use-docutils-toc

With use-latex-toc (default since release 0.6):

  • The ToC is generated by LaTeX (via the \tableofcontents command).

    The layout depends on the choosen document class and can be configured in a custom style sheet (see e.g. the KOMA-Script Guide for the KOMA-script classes).

  • The depth of the ToC and PDF-bookmarks can be configured

    • with the "depth" argument of the contents directive, or
    • in a style sheet with e.g. \setcounter{tocdepth}{5}.
  • Local ToCs are done with the minitoc package. See the minitoc documentation for the numerous configuration options.


Minitoc supports local ToCs only at "part" and top section level ("chapter" or "section"). Local contents directives at lower levels are ignored (a warning is issued).

This is an intended feature of the minitoc package. If you really require local ToCs at lower level, turn off the use-latex-toc option.

1.5.34   title reference role

Title reference is the default default role for interpreted text.

use slanted font (\textsl)

set title references with a bold monospace font:


1.5.35   text encoding

The encoding of the LaTeX source file is Docutils' output encoding but LaTeX' input encoding.

Option: output-encoding

Encode the LaTeX source file with the ISO latin-1 (west european) 8-bit encoding (the default in Docutils versions up to 0.6.):


LaTeX comes with two options for UTF-8 support,

utf8:by the standard inputenc package with only limited coverage (mainly accented characters).
utf8x:supported by the ucs package covers a wider range of Unicode characters than does "utf8". It is, however, a non-standard extension and no longer developed.

Currently (in version 0.6), "utf8" is used if the output-encoding is any of "utf_8", "U8", "UTF", or "utf8".

1.5.36   transition element

Transitions are commonly seen in novels and short fiction, as a gap spanning one or more lines, marking text divisions or signaling changes in subject, time, point of view, or emphasis.

A horizontal line, 1/3 of text width
Example 1:

Use three stars:


Alternatively use the more elaborated version in transition-stars.sty.

Example 2:

If paragraphs are separated by indentation, you can simply use a vertical space:


1.6   Changes

1.7   Problems

1.7.1   Troubleshooting   Bad looking PDF output

What I am looking for when I try Docutils is if the PDF files I can get are of high quality. Unfortunaltely that never is the case.

So am I just stupid or is there a way to get really high quality pdf from Docutils?

Make sure the default font is not a bitmap font.

There is Latin Modern if you like the look of the standard font on paper, but want nice pdf. Or select something else like Times, Palatino, ... via configuration options to the Docutils tool. See font and font-encoding.   footnote mark and text at different pages

Docutils stores the footnote text in a separate node, at the position where it is specified in the input document. With the default settings, the footnote is put at the bottom of the page where the footnote text is located, maybe far away from the footnote mark (see e.g. rst/demo.txt).

To get footnote mark and text at the same page, keep footnote mark and footnote text close together!   Glyph not defined in PD1 encoding

If a section title or other link contains non-Latin (e.g. Cyrillic) characters, the LaTeX log contains lots of warnings like:

Package hyperref Warning: Glyph not defined in PD1 encoding,
(hyperref)                removing `\CYRZ' on input line 6.

This can be solved with the "unicode" hyperref_option setting:


(works also with non-unicode input/output encoding (e.g. "koi8r" or "latin1"). Newer versions of hyperref default to "unicode=true" if the document language is "russian".

However, this setting leads to "strange" characters in the bookmarks if used with xelatex in hyperref versions before v6.79g (2009/11/20). (cf bugreport 3100778).

If updating the hyperref package is not an option, the workaround is to set


or (in the config file):

[xetex writer]

hyperref-option: unicode=false   image inclusion

Images are included in LaTeX with the help of the graphicx package. The supported file formats depend on the used driver:

If PDF-image inclusion in PDF files fails, specifying --graphicx-option=pdftex or --graphicx-option=auto might help.

For details see grfguide.pdf.

The Rubber wrapper can be used for automatic image conversion.

Docutils expects an URI as pointer to the image file. The latex writer transforms this URI to a local path. By default, LaTeX does not accept spaces and more than one dot in the filename. If using "traditional" filenames is not an option, the adding grffile to the style sheets can help.   Why are my images too big?

HTML-browsers use the actual screen resolution (usually around 100 DPI).

The CSS specification suggests:

It is recommended that the reference pixel be the visual angle of one pixel on a device with a pixel density of 96 DPI and a distance from the reader of an arm's length.


This is why pixmap images without size specification or objects with a size specified in px tend to come too large in the PDF.

Specify the image size in fixed units (pt, cm, in) or configure the size of a pixel (length unit px).   Error illegal unit px

If you convert the LaTeX source with a legacy program, you might get this error.

The unit "px" was introduced by the pdfTeX converter on 2005-02-04. pdfTeX is used also for conversion into DVI format in all modern LaTeX distributions (since ca. 2006).

If updating LaTeX is not an option, just remove the "px" from the length specification. HTML/CSS will default to "px" while the latexe2 writer will add the fallback unit "bp".   Error Symbol \textcurrency not provided ...

The currency sign (\u00a4) is not supported by all fonts (some have an Euro sign at its place). You might see an error like:

! Package textcomp Error: Symbol \textcurrency not provided by
(textcomp)                font family ptm in TS1 encoding.
(textcomp)                Default family used instead.

(which in case of font family "ptm" is a false positive). Add either

warn:turn the error in a warning, use the default symbol (bitmap), or
 use the symbol provided by the font at the users risk,

to the document options or use a different font package.   Search and text extraction

Search for text that contains characters outside the ASCII range (e.g. umlauts) might fail. See font and font encoding (as well as Searching PDF files for background information).   Unicode box drawing and block characters

The easiest solution is to use xelatex for PDF generation.

With "traditional" TeX engines (e.g. pdflatex):

Unfortunately, this defines only a subset of the characters (see pmboxdraw.pdf for a list).

1.7.2   Bugs and open issues

Open to be fixed or open to discussion.

See also the entries in the Docutils TODO list, the BUGS documentation and the SourceForge Bug Tracker.   Footnotes and citations

Initially both were implemented using figure floats, because hyperlinking back and forth seemed to be impossible. Later the figure directive was added that puts images into figure floats.

This results in footnotes, citations, and figures possibly being mixed at page foot.

Select footnote and citation handling with the docutils-footnotes and use-latex-citations options.

If use-latex-citations is used, a bibliography is inserted right at the end of the document. This should be customizable.

If use-latex-citations is used adjacent citation references (separated only by a single space or a newline) are combined to a single citation group, i.e. [cite1]_ [cite2]_ results in \cite{cite1,cite2}. The appearance in the output can be configured in a style sheet.   テーブル


reST-documents line length is assumed to be 80 characters. The tablewidth is set relative to this value. If someone produces documents with line length of 132 this will fail.

Table width is tried to fit in page even if it is wider than the assumed linewidth, still assumed linewidth is a hook.

  • Table: multicol cells are always left aligned.
  • The contents of a rowspan cell do not influence table height. (multirow "feature", use a phantom or strut?)
  • Multirow cells might mix up the following table rows.
  • Table cells with both multirow and multicolumn are currently not possible.
  • literal-blocks in table cells:
    • If verbatim or flushleft is used one gets vertical space above and below.
    • This is bad for the topmost paragraph in a cell, therefore the writer uses raggedright.
    • Ragged right fails on followup paragraphs as the vertical space would be missing.
  • --table-style=booktabs, ..class:: booktab: booktabs version 1.00 does not work with longtable. This is solved in newer versions (current is 2005/04/14 v1.61803).   Figures

  • Figures are always as wide as the containing text. The "figwidth" argument is currently not supported. As a consequence, the "align" argument has no effect.
  • Wrapping text around figures is currently not supported. (Requires the wrapfig package.)   Miscellaneous

  • Pdfbookmark level 4 (and greater) does not work (might be settable but complicated).
  • Hyperlinks are not hyphenated; this leads to bad spacing. See docs/user/rst/demo.txt 2.14 directives.
  • Pagestyle headings does not work, when sections are starred. Use LaTeX for the section numbering with the options --no-section-numbers (command line) or sectnum_xform: False (config file).