Author: | Guenter Milde |
---|---|
Contact: | docutils-develop@lists.sourceforge.net |
Revision: | 7302 |
Date: | 2012-01-03 |
Copyright: | © 2009 Günter Milde, |
License: | Released under the terms of the 2-Clause BSD license, in short: Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty. |
Abstract
This file documents changes and provides a style for best possible compatibility to the behaviour of the latex2e writer of Doctutils release 0.5.
\NeedsTeXFormat{LaTeX2e} \ProvidesPackage{docutils-05-compat} [2009/03/26 v0.1 compatibility with rst2latex from Docutils 0.5]
Contents
Tip
As the changes include bug fixes that are partly reverted by this style, it is recommended to adapt the stylesheets to the new version or copy just the relevant parts of this style into them.
Newlines around comments, targets and references prevent run-together paragraphs.
Fixed missing and spurious internal links/targets. Internal links now take you to the correct place.
Verbose and linked system messages.
Figure and image alignment now conforms to the rst definition.
Put header and footer directive content in DUheader respective DUfooter macros (ignored by the default style/template).
(They were put inside hard-coded markup at the top/bottom of the document without an option to get them on every page.)
Render doctest blocks as literal blocks (fixes bug [1586058] doctest block nested in admonition). I.e.
Warning
(--literal-block-env=verbatim and --literal-block-env=lstlistings fail with literal or doctest blocks nested in an admonition.
Two-way hyperlinked footnotes and support for symbol footnotes and --footnote-references=brackets with --use-latex-footnotes.
The packages fixltx2e (providing LaTeX patches and the textsubscript command) and cmap (including character maps in the generated PDF for better search and copy-and-paste operations) are now always loaded (configurable with custom templates).
Reset to the former defaults with:
(in the config file) or the command line options:
--figure-footnotes --use-docutils-toc --font-encoding=''
Up to Docutils 0.5, if no filename extension is given in the stylesheet argument, .tex is assumed (by latex).
Since Docutils 0.6, a stylesheet without filename extension is assumed to be a LaTeX package (*.sty) and referenced with the \usepackage command.
Important
Always specify the extension if you want the style sheet to be \input by LaTeX.
See the LaTeX writer documentation for details.
prevent LaTeX error "missing unit".
px is a valid unit in pdftex since version 1.3.0 released on 2005-02-04:
1px defaults to 1bp (or 72dpi), but can be changed with the \pdfpxdimen primitive.:
\pdfpxdimen=1in % 1 dpi \divide\pdfpxdimen by 96 % 96 dpi
Modern TeX distributions use pdftex also for dvi generation (i.e. latex actually calls pdftex with some options).
In Docutils (as well as CSS) the unit symbol "pt" denotes the Postscript point or DTP point while 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
Images with width specification in px come out slightly (0.3 %) larger:
1 px = 1 bp = 1/72 in > 1 pt = 1/72.25 in
This can be reset with
\pdfpxdimen=1pt
Caution!
It is impossible to revert the change of lengths specified with "pt" or without unit in a style sheet, however the 0.3 % change will be imperceptible in most cases.
Error illegal unit px
The unit px is not defined in "pure" LaTeX, but introduced by the pdfTeX converter on 2005-02-04. pdfTeX is used in all modern LaTeX distributions (since ca. 2006) also for conversion into DVI.
If you convert the LaTeX source with a legacy program, you might get the error illegal unit px.
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.
Do not mix font-encoding and font settings: do not load the obsolete ae and aeguill packages unless explicitely required via the --stylesheet option.
font-encoding = "": | |
---|---|
do not load ae and aeguill, i.e.
|
|
font-encoding = "OT1": | |
load fontenc with \usepackage[OT1]{fontenc} |
Tip
Using ae is not recommended. A similar look (but better implementation) can be achieved with the packages lmodern, cmsuper, or cmlgr all providing Computer Modern look-alikes in vector format and T1 encoding, e.g. --font-encoding=T1 --stylesheet=lmodern.
Set sub- and superscript role argument in text mode not as math.
Pass the role content to \textsubscript or \textsuperscript.
The old implementation set the role content in Math mode, where
Although it is possible to redefine \textsubscript and \textsuperscript to typeset the content in math-mode, this can lead to errors with certain input and is therefore not done in this style sheet.
Tip
To get italic subscripts, define and use in your document custom roles like .. role:: sub(subscript) and .. role:: super(superscript) and define the "role commands":
\newcommand{\DUrolesub}{\itshape} \newcommand{\DUrolesuper}{\itshape}
Alternatively, if you want all sub- and superscripts in italic, redefine the macros:
%% \let\DUsup\textsubscript %% \let\DUsuper\textsuperscript %% \renewcommand*{\textsubscript}{\DUsub\itshape} %% \renewcommand*{\textsuperscript}{\DUsuper\itshape}
This is not fully backwards compatible, as it will also set numbers in italic shape and not ignore whitespace.
Up to version 0.5, use of typearea and a DIV setting of 12 were hard-coded into the latex2e writer
\usepackage{typearea} \typearea{12}
and the vertical alignment of lower boundary of the text area in book classes disabled via
\raggedbottom
Better conformance to Docutils specifications.
Backwards compatibility:
The previous behaviour was to always number sections if 'use-latex-toc' is true, using the document class defaults. It cannot be restored universally, the following code sets the default values of the "article" document class:
\setcounter{secnumdepth}{3} \setcounter{tocdepth}{3}
Use \floatplacement from the float package instead of "hard-coded" optional argument for the global setting.
Default to \floatplacement{figure}{H} (here definitely). This corresponds most closely to the source and HTML placement (principle of least surprise).
Set the global default back to the previous used value:
\usepackage{float} \floatplacement{figure}{htbp} % here, top, bottom, extra-page
New features:
Fix behaviour of 'align' argument to a figure (do not align figure contents).
As the 'figwidth' argument is still ignored and the "natural width" of a figure in LaTeX is 100% textwidth, setting the 'align' argument of a figure has currently no effect on the LaTeX output.
Set default align of image in a figure to 'center'.
Also center images that are wider than textwidth.
Align images with class "align-[right|center|left]" (allows setting the alignment of an image in a figure).
The alignment of the image can be set with the "align-left", "align-center" and "align-right" class arguments.
As previously, the caption of a figure is aligned according to the document class -- configurable with a style sheet using the "caption" package.
See a)
Set the alignment of "oversized" images to "left" to get back the old placement.
The following packages where required in pre-0.5 versions and still loaded with version 0.5:
\usepackage{shortvrb} \usepackage{amsmath}
Additional to the typearea for page layout, the following packages are only loaded if actually required by doctree elements:
Standard package for tables across several pages:
\usepackage{longtable}
Extra space between text in tables and the line above them ('array' is implicitely loaded by 'tabularx', see below):
\usepackage{array} \setlength{\extrarowheight}{2pt}
Table cells spanning multiple rows:
\usepackage{multirow}
One-page tables with auto-width columns:
\usepackage{tabularx}
Include graphic files:
\usepackage{graphicx}
Set text and/or background colour, coloured boxes with \colorbox:
\usepackage{color}
Settings for the use of floats for footnotes are only included if
% begin: floats for footnotes tweaking. \setlength{\floatsep}{0.5em} \setlength{\textfloatsep}{\fill} \addtolength{\textfloatsep}{3em} \renewcommand{\textfraction}{0.5} \renewcommand{\topfraction}{0.5} \renewcommand{\bottomfraction}{0.5} \setcounter{totalnumber}{50} \setcounter{topnumber}{50} \setcounter{bottomnumber}{50} % end floats for footnotes
The admonitionwith lenght is replaced by the more powerful \DUadmonition command (see admonitions).
The default value (90 % of the textwidth) is unchanged.
To configure the admonition width, you must redefine the DUadmonition command instead of changing the admonitionwith length value.
The names for special doctree elements are now prefixed with DU.
Up to version 0.5, all definitions were included in the preamble (before the style sheet) of every document -- even if not used in the body. Since version 0.6, fallback definitions are included after the style sheet and only if required.
Customization is done by an alternative definition in a style sheet with \newcommand instead of the former \renewcommand.
The following code provides the old definitions and maps them (or their custom variants) to the new interface.
\newlength{\docinfowidth} \setlength{\docinfowidth}{0.9\textwidth} \newlength{\DUdocinfowidth} \AtBeginDocument{\setlength{\DUdocinfowidth}{\docinfowidth}}
\newlength{\lineblockindentation} \setlength{\lineblockindentation}{2.5em} \newenvironment{lineblock}[1] {\begin{list}{} {\setlength{\partopsep}{\parskip} \addtolength{\partopsep}{\baselineskip} \topsep0pt\itemsep0.15\baselineskip\parsep0pt \leftmargin#1} \raggedright} {\end{list}} \newlength{\DUlineblockindent} \AtBeginDocument{\setlength{\DUlineblockindent}{\lineblockindentation}} \newenvironment{DUlineblock}[1] {\begin{lineblock}{#1}} {\end{lineblock}}
The \locallinewidth length for internal use in tables is replaced by \DUtablewidth. It was never intended for customization:
\newlength{\locallinewidth}
\newcommand{\optionlistlabel}[1]{\bf #1 \hfill} \newenvironment{optionlist}[1] {\begin{list}{} {\setlength{\labelwidth}{#1} \setlength{\rightmargin}{1cm} \setlength{\leftmargin}{\rightmargin} \addtolength{\leftmargin}{\labelwidth} \addtolength{\leftmargin}{\labelsep} \renewcommand{\makelabel}{\optionlistlabel}} }{\end{list}} \newcommand{\DUoptionlistlabel}{\optionlistlabel} \newenvironment{DUoptionlist} {\begin{optionlist}{3cm}} {\end{optionlist}}
Now less prominent (not bold, normal size) restore with:
\newcommand{\rubric}[1]{\subsection*{~\hfill {\it #1} \hfill ~}} \newcommand{\DUrubric}[2][class-arg]{\rubric{#2}}
\newcommand{\titlereference}[1]{\textsl{#1}} \newcommand{\DUroletitlereference}[1]{\titlereference{#1}}
Enable customization of some more Docutils elements with special commands
admonition: | DUadmonition command (replacing \admonitionwidth), |
---|---|
field list: | DUfieldlist environment, |
legend: | DUlegend environment, |
sidebar: | \DUsidebar, \DUtitle, and DUsubtitle commands, |
topic: | \DUtopic and \DUtitle commands, |
transition: | \DUtransition command. |
footnotes: | \DUfootnotemark and \DUfootnotetext commands with hyperlink support using the Docutils-provided footnote label. |
Use sans-serif fonts:
\newcommand{\DUadmonition}[2][class-arg]{% \begin{center} \fbox{\parbox{0.9\textwidth}{\sffamily #2}} \end{center} }
Do not center:
\newcommand{\DUtopicdedication}[1]{#1}
But center the title:
\newcommand*{\DUtitlededication}[1]{\centerline{\textbf{#1}}}
Use sans-serif fonts, a frame, and a darker shade of grey:
\providecommand{\DUsidebar}[2][class-arg]{% \begin{center} \sffamily \fbox{\colorbox[gray]{0.80}{\parbox{0.9\textwidth}{#2}}} \end{center} }
Bold instead of emphasized:
\providecommand*{\DUsubtitlesidebar}[1]{\hspace*{\fill}\\ \textbf{#1}\smallskip}
No quote but normal text:
\newcommand{\DUtopic}[2][class-arg]{% \ifcsname DUtopic#1\endcsname% \csname DUtopic#1\endcsname{#2}% \else #2 \fi }
Title for "topics" (admonitions, sidebar).
Larger font size:
\providecommand*{\DUtitletopic}[1]{\textbf{\large #1}\smallskip}
Do not add vertical space after the transition.
\providecommand*{\DUtransition}[1][class-arg]{% \hspace*{\fill}\hrulefill\hspace*{\fill}}