Engelbert Gruber, Günter Milde
Abstract
This document covers topics specific to Docutils' LaTeX export.
LaTeX, is a document preparation system for high-quality typesetting. It is most often used for medium-to-large technical or scientific documents but it can be used for almost any form of publishing. There exists a wide selection of LaTeX Documentation on the net and books on LaTeX and related topics. For an introduction to LaTeX see, e.g., LaTeX2e for authors.
1.1 LaTeX document classes and packagesUnlike HTML with CSS, LaTeX uses one common language for markup and style definitions. Separation of content and style is realized by collecting style definitions in LaTeX classes and packages, or the document preamble.
LaTeX document classes and packages (similar to Python modules or C libraries) provide means to extend or modify the LaTeX language by redefining macros or providing new ones.
Using the document class and style sheet configuration settings, you can select from a huge selection of classes and packages (standard as well as user contributed) coming with your TeX distribution or available at CTAN as well as custom style sheets.
1.2 Docutils specific LaTeX macrosSome 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, these macros use the prefix \DU[1]. Fallback definitions are included after the custom style sheets, for all macros required in the document. Alternatively, you may list "docutils" in the stylesheet setting to use the "docutils" package instead.
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 docutils.sty and the test output standalone_rst_latex.tex for an example of the fallback definitions and their use in the document.
1.3 Length unitsThe LaTeX writer supports all reStructuredText length units with the following peculiarities:
In LaTeX, the size of the pixel unit defaults to 1â¯px = 1/72â¯in while the CSS3 pixel unit is defined as 1â¯px = 1/96â¯in. The LaTeX conversion factor can be configured, see below for the size of a "px".
LaTeX uses "pt" for the American point (TeX point), 1â¯pt = 1/72.25â¯in. The DTP point (Postscript point) used in CSS is available in LaTeX as big point, 1â¯bp = 1/72â¯in.
Lengths specified in the source with unit "pt" are written with unit "bp" by the LaTeX writer. In raw LaTeX and custom style sheets, the DTP point must be specified as "bp", while "pt" is interpreted as TeX point.
The default length unit (added by the latex writer to length values without unit) is the DTP point "bp". It will change to "px" in Docutils 1.0.
The TeX units:
bp
"big" point (DTP point)
1 bp = 1/72 in
cc
cîcero
1 cc = 12 dd
dd
didôt
1 dd = 1238/1157 pt
sp
scaled point
1sp = 1/65536pt
can be used in raw LaTeX and custom style sheets but not in reStructuredText.
2 PDF generationIn most cases, LaTeX code is not the desired end-format of the document. There are several programs to generate PDF documents from the LaTeX source, including:
Generates a PDF document directly from the LaTeX file. Export your document with the LaTeX2e writer (writer name "latex", frontend tool rst2latex).
The XeTeX and LuaTeX engines work with input files in UTF-8 encoding and system fonts. Export your document with the XeLaTeX writer (writer name "xetex", frontend tool rst2xetex).
You may need to call the respective command two or 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.
Docutils configuration settings can be specified as command-line options or configuration settings.
Run rst2latex --help to get a list of available options or see Docutils Configuration for details.
3.2 ClassesThe "classes" attribute is one of the common attributes, shared by all Docutils elements. In HTML, the common use is to provide selection criteria for style rules in CSS stylesheets. As there is no comparable framework for LaTeX, Docutils emulates some of this behaviour via Docutils specific LaTeX macros. Due to LaTeX limitations, class arguments are ignored for some elements (e.g. a rubric).
are handled via the \DUrole{} macro that calls the optional styling command \DUrole«classargument» with one argument (the role content). See custom interpreted text roles.
are wrapped in "class environments": \begin{DUclass} calls the optional styling command \DUCLASS«classargument»{}, \end{DUclass} tries \endDUCLASS«classargument».
Customization is done by defining matching macros or environments.
Use small caps font inside elements with class value "custom".
The LaTeX function \textsc sets the argument in small caps:
\newcommand{\DUrolecustom}[1]{\textsc{#1}}
The LaTeX directive (macro without argument) \scshape switches to the small caps font. Its effect is confined to the wrapper DUclass environment:
\newcommand*{\DUCLASScustom}{\scshape}
It is even possible to locally redefine other LaTeX macros, e.g. to turn bullet lists with class value "enumerateitems" into enumerated lists:
\newcommand*{\DUCLASSenumerateitems}{% \renewenvironment{itemize}{\begin{enumerate}}% {\end{enumerate}}% }
Notes
Class arguments may contain numbers and hyphens, which need special treatment in LaTeX command names (see class directive). The commands \csname and \endcsname or the special command \@namedef can help with the definition of corresponding macros or environments, e.g.:
\expandafter\newcommand\csname gg1\endcsname{Definition of gg1.}
or
\makeatletter \@namedef{DUCLASSadmonition-test}{â¦} \makeatother
Elements can have multiple class arguments. In contrast to HTML/CSS, the order of the class arguments cannot be ignored in LaTeX
Class handling differs for some elements and class values:
Class argument values starting with align- are transformed to "align" argument values. Class argument values starting with language- set the elements language property.
The table element recognizes some special class values. See section table style.
If the legacy-class-functions setting is True, the special macros \DUadmonition and \DUtitle are written with a comma separated list of class values as optional argument.
Custom LaTeX code can be placed in style sheets, the LaTeX preamble, the document body (raw LaTeX), or custom templates.
The functional tests that come with Docutils, can serve as example.
standalone_rst_latex.rst (includes files from tests/functional/input/data)
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.
Select Latin Modern fonts with the lmodern package:
--stylesheet=lmodern
Use the preamble.tex home-made custom style sheet together with the package kerkis (Bookman fonts):
--stylesheet=kerkis,preamble.tex
Select Palatino fonts with old-style numbers and true small-caps with the LaTeX command
\usepackage[osf,sc]{mathpazo}
in the LaTeX preamble or custom style sheets.
There is a repository of user-contributed style sheets in the Docutils Sandbox.
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 alternatives 'titlepage.tex' (separate title page) and 'titlingpage.tex'" (separate title page with the memoir document class).
Print a title page including docinfo, dedication, and abstract:
--template=titlepage.tex
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. Better use the math directive)
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 specific LaTeX macros with raw LaTeX.
Define the transition command as page break:
.. raw:: latex \renewcommand*{\DUtransition}{\pagebreak[4]}
Defining a macro for a custom role.
Forcing page breaks.
Admonitions are specially marked "topics" that can appear anywhere an ordinary body element can.
DUadmonition
(Command \DUadmonition with legacy-class-functions.)
Typeset in a frame (90â¯% of text width).
The admonition title is typeset with the \DUtitle command (see titles).
A lighter layout without the frame:
\newenvironment{DUadmonition}% {\begin{quote}} {\end{quote}}
Print all admonitions in the margin:
\usepackage{environ} \NewEnviron{DUadmonition}{\marginpar{\BODY}}
Use the .. note:: admonition for a margin note:
\usepackage{environ} \newcommand{\DUCLASSnote}{% \RenewEnviron{DUadmonition}{\marginpar{\BODY}}% \renewcommand{\DUtitle}[1]{}% suppress title ("Note") }
Caution!
Make sure there is enough space in the margin. \marginpar fails in some places or with some content. See also the environ and marginnote packages.
4.2 custom interpreted text rolesThe rst role directive allows defining custom text roles that mark parts of inline text (spans) with class arguments (see section classes).
\DUrole: dispatcher command
\DUrole«classargument»: optional styling command with 1 argument (the role content).
The default definition of \DUrole{«classargument»}{} calls the macro named \DUrole«classargument»{} if it is defined and silently ignores this class argument if not.
Typeset text in small caps:
.. role:: smallcaps :smallcaps:`Fourier` transformation
This is transformed to the LaTeX code:
\DUrole{smallcaps}{Fourier} transformation
The definition
\newcommand{\DUrolesmallcaps}{\textsc}
as raw LaTeX or in the custom style sheet will give the expected result (if the text font supports small caps).
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:
\newcommand{\DUrolesub}{\normalsize\itshape}
A role with several classes and a converted class name:
.. role:: custom4 :class: argI argII arg_3
is translated to the nested commands:
\DUrole{argi}{\DUrole{argii}{\DUrole{arg-3}{<content>}}}
With the definitions:
\newcommand{\DUroleargi}[1]{\textsc} \newcommand{\DUroleargii}[1]{{\large #1}} \makeatletter \@namedef{DUrolearg-3}{\textbf} \makeatother
in a style sheet[2] or as raw LaTeX in the document source, text styled with :custom4:`large bold small-caps` will be typeset accordingly.
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}
There are hundreds of LaTeX document classes installed by modern LaTeX distributions, provided by publishers, or available at CTAN.
Standard document classes: article, report, book
KOMA-script classes: scrartcl, scrrprt, scrbook
memoir: a highly configurable document class for larger documents
The bibliographic fields at the top of a document specify document information like author name(s) and copyright info. By default, they are typeset as a table.
use-latex-docinfo, use-latex-abstract
If use-latex-docinfo is True, the content of the "Author", "Authors", "Address", "Contact", "Organization", and "Date" fields is attached to the document title (see below).
If use-latex-abstract is True, the "Abstract" field content is placed in an "abstract" environment. The "abstract" environment can be customized or set up (for the "book" documentclass) with the "abstract" LaTeX package.
\DUdocinfowidth (width of the docinfo table).
Default: 0.9\textwidth (90â¯% of text width)
Change the width of the docinfo table to 70â¯% of text width:
\newlength{\DUdocinfowidth} \setlength{\DUdocinfowidth}{0.7\textwidth}
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 and can be modified by latex packages. The "article" document class uses an in-page title while the "report" and "book" classes use a separate title page. See section Templates and the TeX FAQ on how to customize the style of document titles.
With use-latex-docinfo, author information and date are typeset as part of the document title instead of the document info table.
Paper by three authors, two of them from the same organisation:
Shop Sketches ============= :authors: * Mr. Mousebender * Mr. Arthur Wensleydale :organization: Ye National Cheese Emporium :author: Hr. Hallmackenreuther :organization: Bettengeschäft
With --use-latex-docinfo, authors and their affiliations are typeset below the title using the standard LaTeX command \author with a simple hack for the common affiliation. [3]
Field lists may be used as generic two-column table constructs in documents.
DUfieldlist
Indented description list.
Use a description list customized with enumitem:
\usepackage{enumitem} \newenvironment{DUfieldlist}% {\description[font=,style=sameline,leftmargin=8em]} {\enddescription} }
The KOMA-script classes provide a similar environment under the name labeling.
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. See also The style of captions in the LaTeX FAQ.
\usepackage{caption} \captionsetup{justification=raggedleft,singlelinecheck=false}
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.
\floatplacement
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).
In a custom style sheet, set the default to let LaTeX find a suitable place for figure floats:
\usepackage{float} \floatplacement{figure}{htbp} % here, top, bottom, extra-page
To move all following figures to the top or bottom of the page write in the document source:
.. raw:: latex \floatplacement{figure}{tb}
The selected text font influences the look, the feel, and the readability of the document (cf. Typography on the information highway). Selecting a suitable font also solves the problem with bad looking PDF output.
Font selection is one of the main differences between pdflatex and xelatex/lualatex:
requires specially installed fonts in a set of legacy font encodings.
can use system fonts and provide 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
specifying the corresponding LaTeX package(s) as argument to the stylesheet setting or with the \usepackage LaTeX command.
packages can be combined,
passing options to a package is only possible in a style sheet or the LaTeX preamble.
changing the font-default macros \rmdefault, \sfdefault and/or \ttdefault in a custom style sheet, the LaTeX preamble or raw LaTeX.
Use Latin Modern. LaTeX code:
\usepackage{lmodern}
Command line argument:
--stylesheet=lmodern
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 setting.
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:
\renewcommand{\ttdefault}{txtt}
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}
With xelatex/lualatex, you may use any of the system fonts.
The LaTeX Font Catalogue provides information and examples for a wide range of fonts available for use with PdfLaTeX. Here is just a selection:
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
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, bigger download size than Latin Modern (64 MB).
Bera (Bitstream Vera)
simple invocation: --stylesheet=bera
optimized for on-screen viewing with goot hinting
not part of a minimal standard TeX installation
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
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
Package
Roman
Sans Serif
Typewriter
Math
(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
fourier
Utopia
Fourier
LaTeX font encodings are described in detail in the encguide which is part of the LaTeX base documentation.
"T1"
Use the (obsolete) LaTeX default encoding "OT1":
--font-encoding=OT1
or (without loading the fontenc package):
--font-encoding=""
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
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
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].
4.14 hyphenationThe 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.
\hyphenpenalty=5000 \tolerance=1000
Hyperlinks are realized using the hyperref package. As it re-defines many standard LaTeX macros, this package is loaded last, after the style sheets.
However, you can load hyperref before a package that requires its presence in a style sheet or the LaTeX preamble (see example below). This will ignore options set with hyperlink-color and hyperref-options.
URLs are typeset with the "url" package (loaded implicitly by "hyperref"). The font of URLs can be defined with the \urlstyle command. Valid arguments are
normal text font, Docutils default,
teletype (monospaced), LaTeX default,
roman,
sans serif
Custom loading of the hyperref package also switches to the LaTeX default (monospaced fonts for URLs). Reset to use the text font:
\usepackage[unicode,colorlinks=true,linkcolor=green]{hyperref} \urlstyle{same}
See also non-breaking hyperlinks.
4.15.1 disable hyperlinksTo suppress the hyper-linking completely (e.g. for printing or to avoid clashes with other packages), set hyperref-options to "draft" or load the "nohyperref" package that comes with the "hyperref" bundle.
\usepackage{nohyperref,url} \urlstyle{same}4.16 language
The global document language can be set with the language-code configuration setting. The language of text parts can be set adding the language tag prefixed by "language-" to an element's classes attribute, e.g. language-el for a Greek text part.
4.17 line blocksIn 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 height: 2.5em
set to the paragraph indentation:
\newlength{\DUlineblockindent} \setlength{\DUlineblockindent}{\parindent}
\linespread: for small adjustments
\singlespacing, \onehalfspacing, and \doublespacing: from package setspace
Get document wide double spacing:
\usepackage{setspace} \doublespacing
Increase line spacing by five percent for better readability:
\linespread{1.05}
No markup processing is done within a literal block. It is left as-is, and is typically rendered in a monospaced typeface
Example:
4.20 lists--literal-block-env=lstlisting
The lstlisting environment is highly configurable (as documented in listings.pdf) and provides syntax highlight for many programming languages, for instance
\renewcommand{\ttdefault}{txtt} \lstset{language=Python, morekeywords=[1]{yield}} \lstloadlanguages{Python} \lstset{ basicstyle=\ttfamily, keywordstyle=\bfseries, commentstyle=\rmfamily\itshape, stringstyle=\slshape, } \lstset{showstringspaces=false} \lstset{columns=fullflexible, basewidth={0.5em,0.4em}}and to get LaTeX syntax highlight for a code block with "listings":
\lstloadlanguages{[LaTeX]TeX} % comma separated list of languages \newcommand{\DUCLASSlatex}{\lstset{language=[LaTeX]TeX}}The indentation of literal blocks can be reset with
\lstset{resetmargins=true}and/or configured with e. g.:
\lstset{xleftmargin=-2em}
Remove extra vertical whitespace between items of bullet lists and enumerated lists.
Pass the class argument "compact" to the list:
.. class:: compact * first item * second item
The following lines for the LaTeX preamble use the enumitem package to remove spacing from all lists with class argument "compact":
\usepackage{enumitem} \newcommand*{\DUCLASScompact}{\setlist{noitemsep}}
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 \listoffigures
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}
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:
\newcommand*{\DUtransition}{\pagebreak[4]}
(use \renewcommand with raw LaTeX).
By default, paper size and margin settings are determined by the document class.
The following packages help to configure the page layout:
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.
The geometry package is recommended if you have to follow guidelines with fixed values for the margins. For details see the geometry manual.
Let typearea determine the type area with DIV=calc in the documentoptions:
--documentoptions='a4paper,DIV=calc'
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).
LaTeX code to set margins with the geometry package:
\usepackage{geometry} \geometry{hmargin={3cm,0.8in},height=8in} \geometry{height=10in}.
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:
\usepackage{fancyhdr} \fancyhead[L]{\DUheader} \fancyfoot{} % reset \fancyfoot[L]{\DUfooter} \pagestyle{fancy}
Number pages by chapter (using the chappg package):
\usepackage{chappg}
See the chappg documentation for details.
Paper geometry can be changed using documentoptions or with the geometry package.
\usepackage{geometry} \geometry{OPTIONLIST}
a4paper
Some possibilities:
a4paper, b3paper, letterpaper, executivepaper, legalpaper
landscape, portrait, twoside.
Choose A5 pager in landscape orientation with command line argument:
--documentoptions=a5paper,landscape
The same with LaTeX commands in the style sheet:
\usepackage{geometry} \geometry{a5paper,landscape}
For details see the geometry manual.
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:
--stylesheet=parskip
or in a custom style sheet with:
\usepackage{parskip}
To suppress the indentation of a specific paragraph, you may give it the class "noindent" with, e.g.
.. class:: noindent This paragraph should not be indented.
and define the custom role command:
\newcommand{\DUrolenoindent}[1]{\noindent #1}
A rubric is like an informal heading that doesn't correspond to the document's structure.
\DUrubric
subsubsection style (unnumbered), italic
Set centred and red:
\newcommand*{\DUrubric}[1]{% \subsubsection*{\centerline{\color{red}#1}}}
Note
Class attribute values are ignored because the "classes wrapper" interferes with LaTeX's formatting (spacing/indentation) of text following a section heading. Consider using a topic element or a container.
4.30 section headingsSettings: documentclass, use-part-section
Section headings are converted into LaTeX macros according to their level, the document class and the value of the use-part-section setting:
Level
article
article with part
book [6]
book with part
1
section
part
chapter
part
2
subsection
section
section
chapter
3
subsubsection
subsection
subsection
section
4
paragraph
subsubsection
subsubsection
subsection
5
subparagraph
paragraph
paragraph
subsubsection
6
DUtitle
subparagraph
subparagraph
paragraph
7
DUtitle
DUtitle
DUtitle
subparagraph
4.31 section numberingSections are numbered if there is a sectnum directive in the document.
Setting: sectnum_xform
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.:
\setcounter{secnumdepth}{5}
Note
The LaTeX name is 'secnumdepth' (without 't').
4.33 size of a "px"The length unit "px" is defined in pdfTeX and LuaTeX, the "XeTeX" writer uses the \pdfpxdimen macro as workaround.
1â¯px = 1/72â¯in
Set the value to match the CSS3 pixel unit 1â¯px = 1/96â¯in with the LaTeX code:
\pdfpxdimen=1in \divide\pdfpxdimen by 96
A pre-configured table style can be globally selected via the table_style setting or set for individual tables via a class directive or the class option of the table directives.
Supported values:
Borders around all cells.
Use the booktabs package for publication quality tables (no vertical rules).
No borders around table cells.
Column width determination by LaTeX. Overridden by the table directive option widths.
Caution!
Auto-sized columns work only with simple cell content.
To support automatic line breaks, standard LaTeX tables need to know the column widths. Therefore, the LaTeX writer determines default values for both, relative column widths and the total width of a table from the table's colwidth [7] values. [8] The algorithm works sufficiently well in typical use cases. However, there are cases where the table layout requires manual intervention, for example:
Tables where the cells contain only numbers or short text look better with auto-sized columns.
If the input table contains verbose markup syntax, column widths in the source may be bad indicators for output column widths.
Columns may become too narrow in tables that are nested inside lists, quotes, or similar.
To improve the table layout, you may:
Use the table directive option width to set the table width to a custom length or percentage of the current line width.
Adjust the table column widths in the source document or use the table directive option widths to specify column widths.
Set the table directive option widths to the value "auto" or select the table style "colwidths-auto" to let LaTeX determine table and column widths from the table content.
Caution!
Auto-sized columns only work with simple cell content.
LaTeX sets cell content in auto-sized columns in one line (merging paragraphs) and fails with other block level content.
The legacy_column_widths setting provides backwards compatibility with the (faulty) legacy algorithm.
4.36 table of contentsA contents directive is replaced by a table of contents (ToC).
Setting:: use-latex-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 chosen 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 option 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.
Note
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.
4.37 title reference roleTitle reference is the default default role for interpreted text.
\DUroletitlereference
use slanted font (\textsl)
set title references with a bold monospace font:
\newcommand{\DUroletitlereference}[1]{\texttt{\textbf{#1}}}
The titles of admonitions, sidebar, and topic element use the \DUtitle command which can be re-defined in the corresponding DUCLASS environment.
The re-definition is local to the environment, so you don't need to save/restore the original function.
In the nested function redefinition, the argument placeholder requires two hashes, #1 â ##1!
a centered and somewhat larger title for topcis:
\newcommand*{\DUCLASStopic}{ \renewcommand*{\DUtitle}[1]{\subsection*{\centering ##1}} }
a right-pointing hand as title for the "attention" admonition:
\usepackage{pifont} \newcommand*{\DUCLASSattention}{ \renewcommand*{\DUtitle}[1]{\ding{43}} }
The title argument is "swallowed" by the command. To have both, hand and title use:
\usepackage{pifont} \newcommand*{\DUCLASSattention}{ \renewcommand*{\DUtitle}[1]{\ding{43} ##1} }
The encoding of the LaTeX source file is Docutils' output encoding but LaTeX' input encoding.
Setting: output_encoding
"utf-8" (LaTeX's default input 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.):
--output-encoding=latin-1
8-bit LaTeX comes with two packages for UTF-8 support,
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).
Use a standard paragraph for a topic:
\newcommand{\DUCLASStopic}{% \renewenvironment{quote}{}{}% }
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.
\DUtransition
A horizontal line, 1/3 of text width
Use three stars:
\newcommand*{\DUtransition}{\centering{}*\quad*\quad*}
Alternatively use the more elaborated version in transition-stars.sty.
If paragraphs are separated by indentation, you can simply use a vertical space:
\newcommand*{\DUtransition}{\vspace{2ex}}
The Docutils HISTORY lists all changes during the history of docutils. Important changes are summarized in the RELEASE-NOTES.
What I am looking for when I try Docutils is PDF files of high quality. Unfortunately 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 settings. See font and font-encoding.
6.1.2 footnote mark and text at different pagesDocutils 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.rst).
To get footnote mark and text at the same page, keep footnote mark and footnote text close together.
6.1.3 non-breaking hyperlinksIf you convert with latex (as opposed to pdflatex), hyperlinks will not wrap and sometimes stick into the margin.
\usepackage[breaklinks=true]{hyperref}
"breaklinks" is an internal option that indicates whether the chosen driver can handle split links. (It might work to disable link breaking.)
Use one of the following:
compile with pdflatex,
use the package breakurl,
(for printout) disable hyperlinks using the package "nohyperref".
See also the Link text doesnât break at end line LaTeX FAQ entry.
6.1.4 Glyph not defined in PD1 encodingIf 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:
--hyperref-option=unicode
(works also with non-unicode input/output encoding (e.g. "koi8r" or "latin1"). Newer versions of hyperref default to "unicode=true".
6.1.5 image inclusionImages are included in LaTeX with the help of the graphicx package. The supported graphic formats depend on the postprocessor:
pdflatex, lualatex, and xelatex work with PNG, JPG, and PDF but not EPS.
When compiling to DVI with the latex command, support depends on the viewer or post-processor:
dvips supports EPS but not other format,
dvipdfmx works with EPS and JPG (add 'dvipdfmx' to the documentoptions or graphicx-option setting and 'bmpsize' to the stylesheet setting).
SVG images are supported if the "svg" package is listed in the stylesheet setting. Pass the --shell-escape option to the LaTeX compiler to enable image conversion on the fly by Inkscape. (New in Docutils 0.22.)
The Rubber wrapper can be used for automatic image conversion.
For details see grfguide.pdf.
Docutils expects a URI-reference as pointer to the image ressource. The LaTeX writer transforms it to a filesystem path. By default, LaTeX does not accept spaces and more than one dot in the filename. If using "traditional" filenames is not an option, loading the grffile package may help.
6.1.6 Why are my images too big?In LaTeX, the size of the pixel unit defaults to 1â¯px = 1/72â¯in while the CSS3 pixel unit is defined as 1â¯px = 1/96â¯in.
This is why pixmap images without size specification or objects with a size specified in px tend to come out too large in the PDF.
Specify the image size in fixed length units (pt, cm, in, â¦) or configure the size of a "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).
6.1.8 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 (bitmap) symbol), or force,almostfull (use the symbol provided by the font at the users risk) to the document options or use a different font package.
6.1.9 Warning: language ⦠not supportedThe "latex" writer uses the LaTeX package Babel and the "xetex" writer uses Polyglossia for language support (hyphenation rules, auto-text localisations and typographic rules). Polyglossia supports more languages, so switching to the "xetex" writer may help.
For short quotes or if language support is provided by the user via other LaTeX document classes and packages, the warning can be ignored.
6.1.10 Search and text extractionSearch for text that contains characters outside the ASCII range might fail. See font and font encoding (as well as Searching PDF files for background information).
It may help to load the cmap package (via style sheets or the custom LaTeX preamble (see also Proper use of cmap and mmmap).
6.1.11 Unicode box drawing and block charactersThe easiest solution is to use xelatex or lualatex which directly support all Unicode characters (if included in the used font).
With "traditional" TeX engines (e.g. pdflatex):
Generate LaTeX code with the default output_encoding "utf-8".
Add the pmboxdraw package to the style sheets. (For shaded boxes also add the color package.)
Unfortunately, this defines only a subset of the characters (see pmboxdraw.pdf for a list).
6.2 Bugs and open issuesOpen to be fixed or open to discussion.
See also the entries in the Docutils TODO list, the BUGS documentation and the SourceForge Bug Tracker.
6.2.1 Footnotes and citationsInitially 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 citation handling with the use_latex_citations setting.
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.
6.2.2 TablesToo wide tables:
Turn off the legacy_column_widths setting (cf. bug #422) or manually set the table width.
Table cells with both multirow and multicolumn are currently not possible.
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.)
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.rst section 2.14 "directives".
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4