1 \documentclass[a4paper]{article
}
2 % generated by Docutils <http://docutils.sourceforge.net/>
3 % rubber: set program xelatex
5 % \defaultfontfeatures{Scale=MatchLowercase}
6 % straight double quotes (defined T1 but missing in TU):
7 \ifdefined \UnicodeEncodingName
8 \DeclareTextCommand{\textquotedbl}{\UnicodeEncodingName}{%
9 {\addfontfeatures{RawFeature=-tlig,Mapping=
}\char34}}%
14 \usepackage{polyglossia
}
15 \setdefaultlanguage{english
}
16 \setotherlanguages{english,french,german
}
18 \usepackage{float
} % float configuration
19 \floatplacement{figure
}{H
} % place figures here definitely
22 \setcounter{secnumdepth
}{0}
23 \usepackage{longtable,ltcaption,array
}
24 \setlength{\extrarowheight}{2pt
}
25 \newlength{\DUtablewidth} % internal use in tables
28 %%% Custom LaTeX preamble
29 % Linux Libertine (free, wide coverage, not only for Linux)
30 \setmainfont{Linux Libertine O
}
31 \setsansfont{Linux Biolinum O
}
32 \setmonofont[HyphenChar=None,Scale=MatchLowercase
]{DejaVu Sans Mono
}
34 %%% User specified packages and stylesheets
36 %%% Fallback definitions for Docutils-specific commands
38 % class handling for environments (block-level elements)
39 % \begin{DUclass}{spam} tries \DUCLASSspam and
40 % \end{DUclass}{spam} tries \endDUCLASSspam
41 \ifx\DUclass\undefined % poor man's "provideenvironment"
42 \newenvironment{DUclass
}[1]%
43 {\def\DocutilsClassFunctionName{DUCLASS
#1}% arg cannot be used in end-part of environment.
44 \csname \DocutilsClassFunctionName \endcsname}%
45 {\csname end
\DocutilsClassFunctionName \endcsname}%
48 % providelength (provide a length variable and set default, if it is new)
49 \providecommand*
{\DUprovidelength}[2]{
50 \ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{}
54 \providecommand*
{\DUtitleabstract}[1]{\centerline{\textbf{#1}}}
56 % admonition (specially marked topic)
57 \providecommand{\DUadmonition}[2][class-arg
]{%
58 % try \DUadmonition#1{#2}:
59 \ifcsname DUadmonition
#1\endcsname%
60 \csname DUadmonition
#1\endcsname{#2}%
63 \fbox{\parbox{0.9\linewidth}{#2}}
69 \providecommand*
{\DUCLASSdedication}{%
70 \renewenvironment{quote
}{\begin{center
}}{\end{center
}}%
73 % docinfo (width of docinfo table)
74 \DUprovidelength{\DUdocinfowidth}{0.9\linewidth}
76 % subtitle (in document title)
77 \providecommand*
{\DUdocumentsubtitle}[1]{{\large #1}}
80 % error admonition title
81 \providecommand*
{\DUtitleerror}[1]{\DUtitle{\color{red
}#1}}
83 % fieldlist environment
84 \ifthenelse{\isundefined{\DUfieldlist}}{
85 \newenvironment{DUfieldlist
}%
87 {\enddescription\endquote}
89 % numeric or symbol footnotes with hyperlinks
90 \providecommand*
{\DUfootnotemark}[3]{%
91 \raisebox{1em
}{\hypertarget{#1}{}}%
92 \hyperlink{#2}{\textsuperscript{#3}}%
94 \providecommand{\DUfootnotetext}[4]{%
96 \renewcommand{\thefootnote}{%
97 \protect\raisebox{1em
}{\protect\hypertarget{#1}{}}%
98 \protect\hyperlink{#2}{#3}}%
103 % inline markup (custom roles)
104 % \DUrole{#1}{#2} tries \DUrole#1{#2}
105 \providecommand*
{\DUrole}[2]{%
106 \ifcsname DUrole
#1\endcsname%
107 \csname DUrole
#1\endcsname{#2}%
109 % backwards compatibility: try \docutilsrole#1{#2}
110 \ifcsname docutilsrole
#1\endcsname%
111 \csname docutilsrole
#1\endcsname{#2}%
119 \ifthenelse{\isundefined{\DUlegend}}{
120 \newenvironment{DUlegend
}{\small}{}
123 % lineblock environment
124 \DUprovidelength{\DUlineblockindent}{2.5em
}
125 \ifthenelse{\isundefined{\DUlineblock}}{
126 \newenvironment{DUlineblock
}[1]{%
127 \list{}{\setlength{\partopsep}{\parskip}
128 \addtolength{\partopsep}{\baselineskip}
129 \setlength{\topsep}{0pt
}
130 \setlength{\itemsep}{0.15\baselineskip}
131 \setlength{\parsep}{0pt
}
132 \setlength{\leftmargin}{#1}}
138 % optionlist environment
139 \providecommand*
{\DUoptionlistlabel}[1]{\bf #1 \hfill}
140 \DUprovidelength{\DUoptionlistindent}{3cm
}
141 \ifthenelse{\isundefined{\DUoptionlist}}{
142 \newenvironment{DUoptionlist
}{%
143 \list{}{\setlength{\labelwidth}{\DUoptionlistindent}
144 \setlength{\rightmargin}{1cm
}
145 \setlength{\leftmargin}{\rightmargin}
146 \addtolength{\leftmargin}{\labelwidth}
147 \addtolength{\leftmargin}{\labelsep}
148 \renewcommand{\makelabel}{\DUoptionlistlabel}}
153 \DUprovidelength{\pdfpxdimen}{1bp
}
156 % rubric (informal heading)
157 \providecommand*
{\DUrubric}[1]{%
158 \subsubsection*
{\centering\textit{\textmd{#1}}}}
160 % sidebar (text outside the main text flow)
161 \providecommand{\DUsidebar}[1]{%
163 \colorbox[gray
]{0.80}{\parbox{0.9\linewidth}{#1}}
167 % subtitle (for topic/sidebar)
168 \providecommand*
{\DUsubtitle}[1]{\par\emph{#1}\smallskip}
170 % text mode subscript
171 \ifx\textsubscript\undefined
172 \usepackage{fixltx2e
} % since 2015 loaded by default
175 % title for topics, admonitions, unsupported section levels, and sidebar
176 \providecommand*
{\DUtitle}[2][class-arg
]{%
177 % call \DUtitle#1{#2} if it exists:
178 \ifcsname DUtitle
#1\endcsname%
179 \csname DUtitle
#1\endcsname{#2}%
181 \smallskip\noindent\textbf{#2}\smallskip%
185 % titlereference role
186 \providecommand*
{\DUroletitlereference}[1]{\textsl{#1}}
188 % transition (break, fancybreak, anonymous section)
189 \providecommand*
{\DUtransition}{%
190 \hspace*
{\fill}\hrulefill\hspace*
{\fill}
191 \vskip 0.5\baselineskip
194 \ifthenelse{\isundefined{\hypersetup}}{
195 \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue
]{hyperref
}
196 \usepackage{bookmark
}
197 \urlstyle{same
} % normal text font (alternatives: tt, rm, sf)
200 pdftitle=
{reStructuredText Test Document
},
201 pdfauthor=
{David Goodger;Me;Myself;I
}
204 \title{reStructuredText Test Document
%
205 \label{restructuredtext-test-
document}%
208 \DUdocumentsubtitle{Examples of Syntax Constructs
}%
209 \label{examples-of-syntax-constructs
}%
220 \begin{tabularx
}{\DUdocinfowidth}{lX
}
229 \href{mailto:goodger@python.org
}{goodger@python.org
} \\
236 \textbf{Organization
}: &
239 Now, or yesterday. Or maybe even
\emph{before
} yesterday. \\
241 This is a “work in progress” \\
243 is managed by a version control system. \\
246 \textbf{Copyright
}: &
247 This
document has been placed in the public domain. You
248 may do with it as you wish. You may copy, modify,
249 redistribute, reattribute, sell, buy, rent, lease,
250 destroy, or improve it, quote it at length, excerpt,
251 incorporate, collate, fold, staple, or mutilate it, or do
252 anything else to it that your or anyone else’s heart
254 \textbf{field name
}: &
255 This is a “generic bibliographic field”.
257 \textbf{field name “
2”
}: &
258 Generic bibliographic fields may contain multiple body elements.
265 \begin{DUclass
}{dedication
}
267 \DUtitle[dedication
]{Dedication
}
269 For Docutils users \& co-developers.
273 \begin{DUclass
}{abstract
}
275 \DUtitle[abstract
]{Abstract
}
277 This is a test
document, containing at least one example of each
278 reStructuredText construct.
282 % This is a comment. Note how any initial comments are moved by
283 % transforms to after the document title, subtitle, and docinfo.
285 % Above is the document title, and below is the subtitle.
286 % They are transformed from section titles after parsing.
288 % bibliographic fields (which also require a transform):
290 \pagebreak[4] % start ToC on new page
292 \phantomsection\label{table-of-contents
}
293 \pdfbookmark[1]{Table of Contents
}{table-of-contents
}
294 \renewcommand{\contentsname}{Table of Contents
}
298 \section{1 Structural Elements
%
299 \label{structural-elements
}%
303 \subsection{1.1 Section Title
%
304 \label{section-title
}%
306 \subsubsection*
{Section Subtitle
}
308 Lone subsections are converted to a section subtitle by a transform
309 activated with the
\texttt{--section-subtitles
} command line option or the
310 \texttt{sectsubtitle-xform
} configuration value.
313 \subsection{1.2 Empty Section
%
314 \label{empty-section
}%
318 \subsection{1.3 Transitions
%
324 %___________________________________________________________________________
327 It divides the section. Transitions may also occur between sections:
329 %___________________________________________________________________________
333 \section{2 Body Elements
%
334 \label{body-elements
}%
338 \subsection{2.1 Paragraphs
%
345 \subsubsection{2.1.1 Inline Markup
%
346 \label{inline-markup
}%
349 Paragraphs contain text and may contain inline markup:
\emph{emphasis
},
350 \textbf{strong emphasis
},
\texttt{inline literals
}, standalone hyperlinks
351 (
\url{http://www.python.org
}), external hyperlinks (
\href{http://www.python.org/
}{Python
}\DUfootnotemark{id30
}{id29
}{5}), internal
352 cross-references (
\hyperref[example
]{example
}), external hyperlinks with embedded URIs
353 (
\href{http://www.python.org
}{Python web site
}),
\href{http://www.python.org/
}{anonymous hyperlink
354 references
}\DUfootnotemark{id40
}{id29
}{5} (
\href{http://docutils.sourceforge.net/
}{a second reference
}\DUfootnotemark{id42
}{id41
}{9}), footnote references (manually
355 numbered
\DUfootnotemark{id1
}{id8
}{1}, anonymous auto-numbered
\DUfootnotemark{id2
}{id12
}{3}, labeled auto-numbered
\DUfootnotemark{id3
}{label
}{2}, or symbolic
\DUfootnotemark{id4
}{id13
}{*
}), citation references (
\hyperlink{cit2002
}{[CIT2002
]}),
356 substitution references (
\includegraphics{../../../docs/user/rst/images/biohazard.png
} \&
357 a
\emph{trimmed heart
} \texttt{(U+
2665):
}♥), and
%
358 \phantomsection\label{inline-hyperlink-targets
}inline hyperlink targets
359 (see
\hyperref[targets
]{Targets
} below for a reference back to here). Character-level
360 inline markup is also possible (although exceedingly ugly!) in
\emph{re
}\texttt{Structured
}\emph{Text
}. Problems are indicated by
%
361 \raisebox{1em
}{\hypertarget{id28
}{}}\hyperlink{id27
}{\textbf{\color{red
}|problematic|
}} text
362 (generated by processing errors; this one is intentional). Here is a
363 reference to the
\hyperref[doctitle
]{doctitle
} and the
\hyperref[subtitle
]{subtitle
}.
365 The default role for interpreted text is
\DUroletitlereference{Title Reference
}. Here are
366 some explicit interpreted text roles: a PEP reference (
\href{http://www.python.org/dev/peps/pep-
0287}{PEP
287}); an
367 RFC reference (
\href{http://tools.ietf.org/html/rfc2822.html
}{RFC
2822}); an abbreviation (
\DUrole{abbreviation
}{abb.
}), an acronym
368 (
\DUrole{acronym
}{reST
}), code (
\texttt{\DUrole{code
}{print
\textquotedbl{}hello world
\textquotedbl{}}}); a
\textsubscript{subscript
};
369 a
\textsuperscript{superscript
} and explicit roles for
\DUroletitlereference{Docutils
}’
370 \emph{standard
} \textbf{inline
} \texttt{markup
}.
372 % DO NOT RE-WRAP THE FOLLOWING PARAGRAPH!
374 Let’s test wrapping and whitespace significance in inline literals:
375 \texttt{This is an example of --inline-literal --text, --including some--
376 strangely--hyphenated-words. ~Adjust-the-width-of-your-browser-window
377 to see how the text is wrapped. ~-- ---- -------- ~Now note ~ ~the
378 spacing ~ ~between the ~ ~words of ~ ~this sentence ~ ~(words
379 should ~ ~be grouped ~ ~in pairs).
}
381 If the
\texttt{--pep-references
} option was supplied, there should be a
382 live link to PEP
258 here.
385 \subsection{2.2 Bullet Lists
%
386 \label{bullet-lists
}%
393 \item Nested bullet list.
400 Paragraph
2 of item
2.
403 \item Nested bullet list.
415 \item This nested list should be compacted by the HTML writer.
417 \phantomsection\label{target
}
418 % Even if this item contains a target and a comment.
423 \subsection{2.3 Enumerated Lists
%
424 \label{enumerated-lists
}%
428 \item Arabic numerals.
431 \renewcommand{\labelenumii}{\alph{enumii
})
}
435 \renewcommand{\labelenumiii}{(
\roman{enumiii
})
}
441 \begin{list
}{\Roman{enumv
})
}{\usecounter{enumv
}}
448 \item Lists that don’t start at
1:
451 \renewcommand{\labelenumii}{\arabic{enumii
}.
}
452 \setcounter{enumii
}{2}
459 \renewcommand{\labelenumii}{\Alph{enumii
}.
}
460 \setcounter{enumii
}{2}
467 \renewcommand{\labelenumii}{\roman{enumii
}.
}
468 \setcounter{enumii
}{2}
476 \subsection{2.4 Definition Lists
%
477 \label{definition-lists
}%
481 \item[{Term
}] \leavevmode
484 \item[{Term
}] \leavevmode (
\textbf{classifier
})
485 Definition paragraph
1.
487 Definition paragraph
2.
489 \item[{Term
}] \leavevmode
492 \item[{Term
}] \leavevmode (
\textbf{classifier one
})(
\textbf{classifier two
})
498 \subsection{2.5 Field Lists
%
504 Field lists map field names to field bodies, like database
505 records. They are often part of an extension syntax. They are
506 an unambiguous variant of RFC
2822 fields.
508 \item[{how arg1 arg2:
}]
509 The field marker is a colon, the field name, and a colon.
511 The field body may contain one or more body elements, indented
512 relative to the field marker.
515 \DUrole{credits
}{This paragraph has the
\DUroletitlereference{credits
} class set. (This is actually not
516 about credits but just for ensuring that the class attribute
517 doesn’t get stripped away.)
}
521 \subsection{2.6 Option Lists
%
522 \label{option-lists
}%
525 For listing command-line options:
528 \item[-a
] command-line option “a”
530 \item[-b file
] options can have arguments
531 and long descriptions
533 \item[--long
] options can be long also
535 \item[--input=file
] long options can also have
538 \item[--very-long-option
] The description can also start on the next line.
540 The description may contain multiple body elements,
541 regardless of where it starts.
543 \item[-x, -y, -z
] Multiple options are an “option group”.
545 \item[-v, --verbose
] Commonly-seen: short \& long options.
547 \item[-
1 file, --one=file, --two file
] Multiple options with arguments.
549 \item[/V
] DOS/VMS-style options too
552 There must be at least two spaces between the option and the
556 \subsection{2.7 Literal Blocks
%
557 \label{literal-blocks
}%
560 Literal blocks are indicated with a double-colon (“::”) at the end of
561 the preceding paragraph (over there
\texttt{-->
}). They can be indented:
566 text = 'is left as-is'
567 spaces_and_linebreaks = 'are preserved'
568 markup_processing = None
572 Or they can be quoted without indentation:
578 > Why didn't I think of that?
583 \subsection{2.8 Line Blocks
%
587 This section tests line blocks. Line blocks are body elements which
588 consist of lines and other line blocks. Nested line blocks cause
591 \begin{DUlineblock
}{0em
}
592 \item[] This is a line block. It ends with a blank line.
594 \begin{DUlineblock
}{\DUlineblockindent}
595 \item[] New lines begin with a vertical bar (“|”).
596 \item[] Line breaks and initial indent are significant, and preserved.
598 \begin{DUlineblock
}{\DUlineblockindent}
599 \item[] Continuation lines are also possible. A long line that is intended
600 to wrap should begin with a space in place of the vertical bar.
602 \item[] The left edge of a continuation line need not be aligned with
603 the left edge of the text above it.
607 \begin{DUlineblock
}{0em
}
608 \item[] This is a second line block.
610 \item[] Blank lines are permitted internally, but they must begin with a “|”.
613 Another line block, surrounded by paragraphs:
615 \begin{DUlineblock
}{0em
}
616 \item[] And it’s no good waiting by the window
617 \item[] It’s no good waiting for the sun
618 \item[] Please believe me, the things you dream of
619 \item[] They don’t fall in the lap of no-one
622 Take it away, Eric the Orchestra Leader!
625 \begin{DUlineblock
}{0em
}
626 \item[] A one, two, a one two three four
628 \item[] Half a bee, philosophically,
630 \begin{DUlineblock
}{\DUlineblockindent}
631 \item[] must,
\emph{ipso facto
}, half not be.
633 \item[] But half the bee has got to be,
635 \begin{DUlineblock
}{\DUlineblockindent}
636 \item[] \emph{vis a vis
} its entity. D’you see?
639 \item[] But can a bee be said to be
641 \begin{DUlineblock
}{\DUlineblockindent}
642 \item[] or not to be an entire bee,
644 \begin{DUlineblock
}{\DUlineblockindent}
645 \item[] when half the bee is not a bee,
647 \begin{DUlineblock
}{\DUlineblockindent}
648 \item[] due to some ancient injury?
657 A line block, like the following poem by Christian Morgenstern, can
658 also be centre-aligned:
660 \begin{selectlanguage
}{german
}
661 \begin{DUlineblock
}{0em
}
663 \item[] \textbf{Die Trichter
}
665 \item[] Zwei Trichter wandeln durch die Nacht.
666 \item[] Durch ihres Rumpfs verengten Schacht
667 \item[] fließt weißes Mondlicht
668 \item[] still und heiter
678 \subsection{2.9 Block Quotes
%
679 \label{block-quotes
}%
682 Block quotes consist of indented body elements:
685 My theory by A. Elk. Brackets Miss, brackets. This theory goes
686 as follows and begins now. All brontosauruses are thin at one
687 end, much much thicker in the middle and then thin again at the
688 far end. That is my theory, it is mine, and belongs to me and I
689 own it, and what it is too.
692 \raggedleft —Anne Elk (Miss)
695 The language of a quote (like any other object) can be specified by
700 \begin{selectlanguage
}{french
}
702 ReStructuredText est un langage de balisage léger utilisé
703 notamment dans la documentation du langage Python.
708 \subsection{2.10 Doctest Blocks
%
709 \label{doctest-blocks
}%
714 >>> print 'Python-specific usage examples; begun with ">>>"'
715 Python-specific usage examples; begun with ">>>"
716 >>> print '(cut and pasted from interactive Python sessions)'
717 (cut and pasted from interactive Python sessions)
722 \subsection{2.11 Footnotes
%
726 \DUfootnotetext{id8
}{id1
}{1}{%
727 A footnote contains body elements, consistently indented by at
730 This is the footnote’s second paragraph.
733 \DUfootnotetext{label
}{id3
}{2}{\phantomsection\label{label
}%
734 Footnotes may be numbered, either manually (as in
\DUfootnotemark{id9
}{id8
}{1}) or
735 automatically using a “\#”-prefixed label. This footnote has a
736 label so it can be referred to from multiple places, both as a
737 footnote reference (
\DUfootnotemark{id10
}{label
}{2}) and as a
\hyperref[label
]{hyperlink reference
}.
740 \DUfootnotetext{id12
}{id2
}{3}{%
741 This footnote is numbered automatically and anonymously using a
744 This is the second paragraph.
746 And this is the third paragraph.
749 \DUfootnotetext{id13
}{id4
}{*
}{%
750 Footnotes may also use symbols, specified with a “*” label.
751 Here’s a reference to the next footnote:
\DUfootnotemark{id14
}{id15
}{†
}.
754 \DUfootnotetext{id15
}{id14
}{†
}{%
755 This footnote shows the next symbol in the sequence.
758 \DUfootnotetext{id16
}{id16
}{4}{%
759 Here’s an unreferenced footnote, with a reference to a
760 nonexistent footnote:
%
761 \raisebox{1em
}{\hypertarget{id17
}{}}\hyperlink{id47
}{\textbf{\color{red
}{[}5{]}\_}}.
765 \subsection{2.12 Citations
%
768 \begin{figure
}[b
]\raisebox{1em
}{\hypertarget{cit2002
}{}}[CIT2002
]
769 Citations are text-labeled footnotes. They may be
770 rendered separately and differently from footnotes.
773 Here’s a reference to the above,
\hyperlink{cit2002
}{[CIT2002
]}, and a
%
774 \raisebox{1em
}{\hypertarget{id19
}{}}\hyperlink{id48
}{\textbf{\color{red
}{[}nonexistent
{]}\_}}
778 \subsection{2.13 Targets
%
780 \label{another-target
}%
783 \phantomsection\label{example
}
784 This paragraph is pointed to by the explicit “example” target. A
785 reference can be found under
\hyperref[inline-markup
]{Inline Markup
}, above.
\hyperref[inline-hyperlink-targets
]{Inline
786 hyperlink targets
} are also possible.
788 Section headers are implicit targets, referred to by name. See
789 \hyperref[targets
]{Targets
}, which is a subsection of
\hyperref[body-elements
]{Body Elements
}.
791 Explicit external targets are interpolated into references such as
792 “
\href{http://www.python.org/
}{Python
}\DUfootnotemark{id31
}{id29
}{5}”.
794 Targets may be indirect and anonymous. Thus
\hyperref[targets
]{this phrase
} may also
795 refer to the
\hyperref[targets
]{Targets
} section.
798 \raisebox{1em
}{\hypertarget{id50
}{}}\hyperlink{id49
}{\textbf{\color{red
}`hyperlink reference without a target`
\_}}, which generates an
802 \subsubsection{2.13.1 Duplicate Target Names
%
803 \label{duplicate-target-names
}%
806 Duplicate names in section headers or other implicit targets will
807 generate “info” (level-
1) system messages. Duplicate names in
808 explicit targets will generate “warning” (level-
2) system messages.
811 \subsubsection{2.13.2 Duplicate Target Names
%
815 Since there are two “Duplicate Target Names” section headers, we
816 cannot uniquely refer to either of them by name. If we try to (like
818 \raisebox{1em
}{\hypertarget{id52
}{}}\hyperlink{id51
}{\textbf{\color{red
}`Duplicate Target Names`
\_}}), an error is generated.
821 \subsection{2.14 Directives
%
825 \phantomsection\label{contents
}
826 These are just a sample of the many reStructuredText Directives. For
828 \url{http://docutils.sourceforge.net/docs/ref/rst/directives.html
}.
831 \subsubsection{2.14.1 Document Parts
%
832 \label{document-parts
}%
835 An example of the “contents” directive can be seen above this section
836 (a local, untitled table of
\hyperref[contents
]{contents
}) and at the beginning of the
837 document (a
document-wide
\hyperref[table-of-contents
]{table of contents
}).
840 \subsubsection{2.14.2 Images and Figures
%
841 \label{images-and-figures
}%
844 An image directive (also clickable – a hyperlink reference):
846 \hyperref[directives
]{\includegraphics{../../../docs/user/rst/images/title.png
}}
848 Image with multiple IDs:
850 \includegraphics{../../../docs/user/rst/images/title.png
}
851 \phantomsection\label{image-target-
3}\label{image-target-
2}\label{image-target-
1}
855 \noindent\makebox[\linewidth][c
]{\includegraphics{../../../docs/user/rst/images/biohazard.png
}}
857 A left-aligned image:
859 \noindent{\includegraphics{../../../docs/user/rst/images/biohazard.png
}\hfill}
861 This paragraph might flow around the image.
862 The specific behavior depends upon the style sheet and
863 the browser or rendering software used.
865 A right-aligned image:
867 \noindent{\hfill\includegraphics{../../../docs/user/rst/images/biohazard.png
}}
869 This paragraph might flow around the image.
870 The specific behavior depends upon the style sheet and
871 the browser or rendering software used.
873 For inline images see
\hyperref[substitution-definitions
]{Substitution Definitions
}.
879 \includegraphics[width=
2em
]{../../../docs/user/rst/images/biohazard.png
}
881 An image
2 em wide and
15 pixel high:
883 \includegraphics[height=
15\pdfpxdimen,width=
2em
]{../../../docs/user/rst/images/biohazard.png
}
885 An image occupying
50\% of the line width:
887 \includegraphics[width=
0.500\linewidth]{../../../docs/user/rst/images/title.png
}
891 \includegraphics[height=
2cm
]{../../../docs/user/rst/images/biohazard.png
}
893 A
\emph{figure
} is an image with a caption and/or a legend. With page-based output
894 media, figures might float to a different position if this helps the page
897 \begin{DUclass
}{figclass1
}
898 \begin{DUclass
}{figclass2
}
900 \noindent\makebox[\linewidth][c
]{\includegraphics[width=
258bp
]{../../../docs/user/rst/images/title.png
}}
901 \caption{Plaintext markup syntax and parser system.
}
903 \setlength{\DUtablewidth}{\linewidth}
904 \begin{longtable*
}[c
]{|p
{0.156\DUtablewidth}|p
{0.563\DUtablewidth}|
}
909 Revised, revisited, based on ‘re’ module.
915 Structure-enhanced text, structuredtext.
921 Well it is, isn’t it?
926 This paragraph is also part of the legend.
932 A left-aligned figure:
934 \begin{DUclass
}{figclass1
}
935 \begin{DUclass
}{figclass2
}
936 \begin{figure
} % align = "left"
937 \noindent\makebox[\linewidth][c
]{\includegraphics[width=
40\pdfpxdimen]{../../../docs/user/rst/images/biohazard.png
}}
938 \caption{This is the caption.
}
942 The legend may consist of several paragraphs.
948 This paragraph might flow around the figure.
950 The specific behavior depends upon the style sheet and the browser or
951 rendering software used.
956 \noindent\makebox[\linewidth][c
]{\includegraphics[width=
40\pdfpxdimen]{../../../docs/user/rst/images/biohazard.png
}}
957 \caption{This is the caption.
}
961 The legend may consist of several paragraphs.
965 This paragraph might flow around the figure.
967 The specific behavior depends upon the style sheet and the browser or
968 rendering software used.
970 A right-aligned figure:
972 \begin{figure
} % align = "right"
973 \noindent\makebox[\linewidth][c
]{\includegraphics[width=
40\pdfpxdimen]{../../../docs/user/rst/images/biohazard.png
}}
974 \caption{This is the caption.
}
978 The legend may consist of several paragraphs.
982 This paragraph might flow around the figure. The specific behavior depends
983 upon the style sheet and the browser or rendering software used.
985 Tables may be given titles and additional arguments with the
\emph{table
}
988 \setlength{\DUtablewidth}{\linewidth}
989 \begin{longtable
}[l
]{|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|
}
990 \caption{left-aligned table
}\\
999 \caption[]{left-aligned table (... continued)
}\\
1008 \multicolumn{2}{c
}{\hfill ... continued on next page
} \\
1025 \setlength{\DUtablewidth}{\linewidth}
1026 \begin{longtable
}[c
]{|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|
}
1027 \caption{center-aligned table
}\\
1036 \caption[]{center-aligned table (... continued)
}\\
1045 \multicolumn{2}{c
}{\hfill ... continued on next page
} \\
1062 \setlength{\DUtablewidth}{\linewidth}
1063 \begin{longtable
}[r
]{|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|
}
1064 \caption{right-aligned table
}\\
1073 \caption[]{right-aligned table (... continued)
}\\
1082 \multicolumn{2}{c
}{\hfill ... continued on next page
} \\
1099 With the “widths” argument “auto” (or “class” value “colwidths-auto”),
1100 column widths are determined by the backend (if supported by the
1103 \begin{longtable*
}[c
]{|l|l|l|
}
1105 \textbf{A
} &
\textbf{B
} &
\textbf{A or B
} \\
1109 \textbf{A
} &
\textbf{B
} &
\textbf{A or B
} \\
1112 \multicolumn{3}{c
}{\hfill ... continued on next page
} \\
1115 False & False & False \\
1117 True & False & True \\
1119 False & True & True \\
1121 True & True & True \\
1124 \label{target2
}\label{target1
}
1127 \subsubsection{2.14.3 Admonitions
%
1128 \label{admonitions
}%
1131 \DUadmonition[attention
]{
1132 \DUtitle[attention
]{Attention!
}
1134 Directives at large.
1137 \DUadmonition[caution
]{
1138 \DUtitle[caution
]{Caution!
}
1140 Don’t take any wooden nickels.
1143 \DUadmonition[danger
]{
1144 \DUtitle[danger
]{!DANGER!
}
1146 Mad scientist at work!
1149 \DUadmonition[error
]{
1150 \DUtitle[error
]{Error
}
1155 \DUadmonition[hint
]{
1156 \DUtitle[hint
]{Hint
}
1158 It’s bigger than a bread box.
1161 \DUadmonition[important
]{
1162 \DUtitle[important
]{Important
}
1165 \item Wash behind your ears.
1167 \item Clean up your room.
1169 \item Call your mother.
1171 \item Back up your data.
1175 \DUadmonition[note
]{
1176 \DUtitle[note
]{Note
}
1184 15\% if the service is good.
1187 \DUadmonition[warning
]{
1188 \DUtitle[warning
]{Warning
}
1190 Strong prose may provoke extreme mental exertion.
1191 Reader discretion is strongly advised.
1194 \DUadmonition[admonition-and-by-the-way
]{
1195 \DUtitle[admonition-and-by-the-way
]{And, by the way…
}
1197 You can make up your own admonition too.
1201 \subsubsection{2.14.4 Topics, Sidebars, and Rubrics
%
1202 \label{topics-sidebars-and-rubrics
}%
1205 \emph{Sidebars
} are like miniature, parallel documents.
1208 \DUtitle[title
]{Sidebar Title
}
1210 \DUsubtitle[sidebar
]{Optional Subtitle
}
1212 This is a sidebar. It is for text outside the flow of the main
1215 \DUrubric{This is a rubric inside a sidebar
}
1217 Sidebars often appear beside the main text with a border and a different
1218 background or font
color.
1221 A
\emph{topic
} is like a block quote with a title, or a self-contained section
1222 with no subsections.
1224 \begin{DUclass
}{topic
}
1226 \DUtitle[topic
]{Topic Title
}
1232 A
\emph{rubric
} is like an informal heading that doesn’t correspond to the
1233 document’s structure. It is typically highlighted in red (hence the name).
1235 \DUrubric{This is a rubric
}
1237 Topics and rubrics can be used at places where a
\hyperref[section-title
]{section title
} is not
1238 allowed (e.g. inside a directive).
1241 \subsubsection{2.14.5 Target Footnotes
%
1242 \label{target-footnotes
}%
1245 \DUfootnotetext{id29
}{id30
}{5}{%
1246 \url{http://www.python.org/
}
1249 \DUfootnotetext{id33
}{id34
}{6}{%
1250 \url{http://pygments.org/
}
1253 \DUfootnotetext{id35
}{id36
}{7}{%
1254 \url{ftp://ftp.ams.org/ams/doc/amsmath/short-math-guide.pdf
}
1257 \DUfootnotetext{id38
}{id39
}{8}{%
1258 \url{http://ctan.org/pkg/polyglossia
}
1261 \DUfootnotetext{id41
}{id42
}{9}{%
1262 \url{http://docutils.sourceforge.net/
}
1265 \DUfootnotetext{id43
}{id44
}{10}{%
1270 \subsubsection{2.14.6 Replacement Text
%
1271 \label{replacement-text
}%
1274 I recommend you try
\href{http://www.python.org/
}{Python,
\emph{the
} best language around
}\DUfootnotemark{id32
}{id29
}{5}.
1277 \subsubsection{2.14.7 Compound Paragraph
%
1278 \label{compound-paragraph
}%
1281 The
\emph{compound
} directive is used to create a “compound paragraph”, which
1282 is a single logical paragraph containing multiple physical body
1283 elements. For example:
1285 \begin{DUclass
}{compound
}
1286 The ‘rm’ command is very dangerous. If you are logged
1287 in as root and enter
1294 you will erase the entire contents of your file system.
1297 Test the handling and display of compound paragraphs:
1299 \begin{DUclass
}{compound
}
1300 \begin{DUclass
}{some-class
}
1301 Compound
2, paragraph
1,
1303 compound
2, paragraph
2,
1309 compound
2, paragraph
3.
1313 \begin{DUclass
}{compound
}
1314 Compound
3, only consisting of one paragraph.
1317 \begin{DUclass
}{compound
}
1321 This one starts with a literal block.
1324 Compound
4, paragraph following the literal block.
1327 Now something
\emph{really
} perverted – a nested compound block. This is
1328 just to test that it works at all; the results don’t have to be
1331 \begin{DUclass
}{compound
}
1332 Compound
5, block
1 (a paragraph).
1334 \begin{DUclass
}{compound
}
1335 Compound
6 is block
2 in compound
5.
1337 Compound
6, another paragraph.
1340 Compound
5, block
3 (a paragraph).
1343 \begin{DUclass
}{compound
}
1344 Compound
7, tests the inclusion of various block-level
1345 elements in one logical paragraph. First a table,
1347 \setlength{\DUtablewidth}{\linewidth}
1348 \begin{longtable*
}[c
]{|p
{0.249\DUtablewidth}|p
{0.249\DUtablewidth}|p
{0.249\DUtablewidth}|
}
1370 followed by a paragraph. This physical paragraph is
1371 actually a continuation of the paragraph before the table. It is followed
1377 \item an enumerated list,
1380 \begin{DUoptionlist
}
1381 \item[--an
] option list,
1390 \item[{a definition
}] \leavevmode
1394 a paragraph, an image:
1395 \includegraphics{../../../docs/user/rst/images/biohazard.png
}
1397 \begin{DUlineblock
}{0em
}
1401 a paragraph followed by a comment,
1405 \DUadmonition[note
]{
1406 \DUtitle[note
]{Note
}
1410 and the final paragraph of the compound
7.
1414 \subsubsection{2.14.8 Parsed Literal Blocks
%
1415 \label{parsed-literal-blocks
}%
1419 \ttfamily\raggedright
1420 This~is~a~parsed~literal~block.\\
1421 ~~~~This~line~is~indented.~~The~next~line~is~blank.\\
1423 Inline~markup~is~supported,~e.g.~
\emph{emphasis
},~
\textbf{strong
},~
\texttt{literal\\
1424 text
},~
\textsubscript{sub-
}~and~
\textsuperscript{super
}scripts,\\
1425 inline~formulas:~$A =
2 \pi r^
2$,\\
1426 footnotes
\DUfootnotemark{id22
}{id8
}{1},~
%
1427 \phantomsection\label{hyperlink-targets
}hyperlink~targets,~and~
\href{http://www.python.org/
}{references
}.
1431 \subsubsection{2.14.9 Code
%
1435 Blocks of source code can be set with the
\DUroletitlereference{code
} directive. If the code
1436 language is specified, the content is parsed and tagged by the
\href{http://pygments.org/
}{Pygments
}\DUfootnotemark{id34
}{id33
}{6}
1437 syntax highlighter and can be formatted with a style sheet. (Code parsing
1438 is turned off using the
\texttt{syntax-highlight
} config setting in the test
1439 conversions in order to get identical results with/without installed
1440 Pygments highlighter.)
1442 \begin{DUclass
}{code
}
1443 \begin{DUclass
}{python
}
1446 print 'This is Python code.'
1452 The
\texttt{:number-lines:
} option (with optional start value) generates line
1455 \begin{DUclass
}{code
}
1456 \begin{DUclass
}{python
}
1458 \ttfamily\raggedright
1459 \DUrole{ln
}{~
8~
}\#~print~integers~from~
0~to~
9:\\
1460 \DUrole{ln
}{~
9~
}for~i~in~range(
10):\\
1461 \DUrole{ln
}{10~
}~~~~print~i
1466 For inline code snippets, there is the
\DUroletitlereference{code
} role, which can be used
1467 directly (the code will not be parsed/tagged, as the language is not known)
1468 or as base for special code roles, e.g. the LaTeX code in the next
1471 Docutils uses LaTeX syntax for math directives and roles:
1472 \texttt{\DUrole{code
}{\DUrole{tex
}{\textbackslash{}alpha = f(x)
}}} prints $
\alpha = f(x)$.
1474 The
\texttt{:code:
} option of the
\DUroletitlereference{include
} directive sets the included content
1475 as a code block, here the rst file
\texttt{header
\_footer.txt
} with line numbers:
1477 \begin{DUclass
}{code
}
1478 \begin{DUclass
}{rst
}
1480 \ttfamily\raggedright
1481 \DUrole{ln
}{1~
}..~header::~Document~header\\
1482 \DUrole{ln
}{2~
}..~footer::~Document~footer
1488 \subsection{2.15 Substitution Definitions
%
1489 \label{substitution-definitions
}%
1492 An inline image (
\includegraphics{../../../docs/user/rst/images/biohazard.png
}) example:
1496 (Substitution definitions are not visible in the HTML source.)
1499 \subsection{2.16 Comments
%
1505 % Comments begin with two dots and a space. Anything may
1506 % follow, except for the syntax of footnotes, hyperlink
1507 % targets, directives, or substitution definitions.
1509 % Double-dashes -- "--" -- must be escaped somehow in HTML output.
1511 % Comments may contain non-ASCII characters: ä ö ü æ ø å
1513 (View the HTML source to see the comment.)
1516 \subsection{2.17 Raw text
%
1520 This does not necessarily look nice, because there may be missing white space.
1522 It’s just there to freeze the behavior.
1528 \DUrole{myclass
}{Another test with myclass set.
}
1530 This is the
\DUrole{myrawroleclass
}{fourth test
} with myrawroleclass set.
1532 Fifth test in LaTeX.\
\Line two.
1535 \subsection{2.18 Container
%
1539 \begin{DUclass
}{custom
}
1546 % currently not implemented in LaTeX:
1547 % .. include:: data/header_footer.txt
1550 \subsection{2.19 Colspanning tables
%
1551 \label{colspanning-tables
}%
1554 This table has a cell spanning two columns:
1556 \setlength{\DUtablewidth}{\linewidth}
1557 \begin{longtable*
}[c
]{|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|p
{0.086\DUtablewidth}|
}
1559 \multicolumn{2}{|p
{0.15\DUtablewidth}|
}{\textbf{%
1575 \multicolumn{2}{|p
{0.15\DUtablewidth}|
}{\textbf{%
1590 \multicolumn{3}{c
}{\hfill ... continued on next page
} \\
1628 \subsection{2.20 Rowspanning tables
%
1629 \label{rowspanning-tables
}%
1632 Here’s a table with cells spanning several rows:
1634 \setlength{\DUtablewidth}{\linewidth}
1635 \begin{longtable*
}[c
]{|p
{0.296\DUtablewidth}|p
{0.156\DUtablewidth}|p
{0.226\DUtablewidth}|
}
1638 Header row, column
1
1639 (header rows optional)
1649 Header row, column
1
1650 (header rows optional)
1658 \multicolumn{3}{c
}{\hfill ... continued on next page
} \\
1662 body row
1, column
1
1671 &
\multirow{2}{0.16\DUtablewidth}{%
1674 } &
\multirow{2}{0.23\DUtablewidth}{%
1687 \subsection{2.21 List Tables
%
1688 \label{list-tables
}%
1691 Here’s a list table exercising all features:
1693 \setlength{\DUtablewidth}{40em
}
1694 \begin{longtable
}[c
]{|p
{0.133\DUtablewidth}|p
{0.249\DUtablewidth}|p
{0.365\DUtablewidth}|
}
1695 \caption{list table with integral header
}\\
1706 \caption[]{list table with integral header (... continued)
}\\
1717 \multicolumn{3}{c
}{\hfill ... continued on next page
} \\
1733 If we took the bones out, it wouldn’t be
1734 crunchy, now would it?
1747 \begin{longtable
}[c
]{|l|l|
}
1748 \caption{center aligned list table
}\\
1752 Crunchy Frog &
1.49 \\
1754 Gannet Ripple &
1.99 \\
1759 \subsection{2.22 Custom Roles
%
1760 \label{custom-roles
}%
1764 \item A role based on an existing role.
1766 \texttt{\DUrole{custom
}{one
}} \texttt{\DUrole{custom
}{two
}} \texttt{\DUrole{custom
}{three
}}
1770 \DUrole{customnew
}{one two three
}
1772 \item A role with class attribute.
1774 \DUrole{special
}{interpreted text
}
1776 \item A language-switching role:
1778 Let’s count in German
\foreignlanguage{german
}{eins zwei drei
}.
1780 \item A role with multiple class attributes, styled with raw directives:
1782 \newcommand{\DUrolegreen}[1]{\textcolor{green
}{#1}}
1783 \newcommand{\DUrolesc}[1]{\textsc{#1}}
1785 The following works in most browsers but does not validate
1786 (
\texttt{<style>
} is only allowed in the
document head):
1792 <style type="text/css"><!--
1793 .green \
{color: green;\
}
1794 .sc \
{font-variant: small-caps;\
}
1799 \DUrole{green
}{\DUrole{sc
}{\foreignlanguage{english
}{British colourful text in small-caps
}}}.
1803 \subsection{2.23 Mathematics
%
1804 \label{mathematics
}%
1807 Docutils supports inline math with the prefix or postfix
\texttt{:math:
}
1808 role specificator, $n! +
\sin(x_n^
2)$ and $A_
\text{c
} =
1809 \frac{\pi}{4} d^
2$, as well as displayed math via the
1810 \DUroletitlereference{math
} directive:
1813 f(
\epsilon) =
\frac{1}{1 +
\exp\left(
\frac{\varepsilon}{k_
\text{B
}T
}\right)
}
1815 Content may start on the first line of the directive, e.g.
1818 N =
\frac{\text{number of apples
}}{7}
1820 Equations can be labeled with a reference name using the
\texttt{:name:
} option.
1821 See
\hyperref[eq-m
]{eq:M
} and
\hyperref[eq-schrodinger
]{eq:schrödinger
} below.
1823 The determinant of the matrix
1826 \mathbf{M
} =
\left(
\begin{matrix
}a&b\
\c&d
\end{matrix
}\right)
1830 is $|
\mathbf{M
}| = ad - bc$.
1832 More than one display math block can be put in one math directive.
1833 For example, the following sum and integral with limits:
1836 \int_0^
1 x^n dx =
\frac{1}{n +
1}
1839 \sum_{n=
1}^m n =
\frac{m(m+
1)
}{2}
1841 LaTeX-supported Unicode math symbols can be used in math roles and
1844 The Schrödinger equation
1847 i
\hbar \frac{\partial }{\partial t
}\Psi =
\hat{H
}\Psi ,
1849 \label{eq-schrodinger
}
1851 with the
\emph{wave function
} $
\Psi $, describes how the quantum state of a
1852 physical system changes in time.
1855 \item[{Math-Accents:
}] \leavevmode
1856 \setlength{\DUtablewidth}{\linewidth}
1857 \begin{longtable*
}[c
]{p
{0.315\DUtablewidth}p
{0.315\DUtablewidth}p
{0.315\DUtablewidth}}
1859 $
\acute{a
}$
\texttt{\textbackslash{}acute\
{a\
}}
1861 $
\dot{t
}$
\texttt{\textbackslash{}dot\
{t\
}}
1863 $
\hat{\gamma}$
\texttt{\textbackslash{}hat\
{\textbackslash{}gamma\
}}
1866 $
\grave{a
}$
\texttt{\textbackslash{}grave\
{a\
}}
1868 $
\ddot{t
}$
\texttt{\textbackslash{}ddot\
{t\
}}
1870 $
\tilde{\alpha}$
\texttt{\textbackslash{}tilde\
{\textbackslash{}alpha\
}}
1873 $
\breve{x
}$
\texttt{\textbackslash{}breve\
{x\
}}
1875 $
\dddot{t
}$
\texttt{\textbackslash{}dddot\
{t\
}}
1877 $
\vec{\imath}$
\texttt{\textbackslash{}vec\
{\textbackslash{}imath\
}}
1880 $
\check{a
}$
\texttt{\textbackslash{}check\
{a\
}}
1882 $
\bar{a
}$
\texttt{\textbackslash{}bar\
{a\
}}
1884 $
\vec{R
}$
\texttt{\textbackslash{}vec\
{R\
}}
1893 Modulation Transfer Function:
1896 \text{MTF
} =
\left|
\frac{\mathcal{F
}\
{s(x)\
}}
1897 {\mathcal{F
}\
{ s(x)\
} |_
{\omega _
{x
}=
0}}\right|
1898 =
\mathrm{abs
}\left(
\frac
1899 {\int _
{-
\infty }^
{\infty }s(x)
\mathrm{e
}^
{\mathrm{i
}\omega _
{x
}x
}\mathrm{d
}{x
}}
1900 {\int _
{-
\infty }^
{\infty }s(x)
\mathrm{d
}{x
}}
1903 Math split over two lines: If a double backslash is detected outside a
1904 \texttt{\textbackslash{}begin\
{...\
} \textbackslash{}end\
{...\
}} pair, the math code is wrapped in an
\href{ftp://ftp.ams.org/ams/doc/amsmath/short-math-guide.pdf
}{AMSmath
}\DUfootnotemark{id36
}{id35
}{7}
1905 \texttt{align
} environment:
1908 s_
{\mathrm{out
}}(x) & = s_
{\mathrm{in
}}(x') * s_
\delta (x-x') \\
1909 & =
\int s_
{\mathrm{in
}}(x')s_
\delta (x-x')
\mathrm{d
}x'
1911 Cases (“manually”, with
\texttt{matrix
} environment):
1914 \mathrm{sgn
}(x) =
\left\
{\begin{matrix
}
1919 Cases with the
\href{ftp://ftp.ams.org/ams/doc/amsmath/short-math-guide.pdf
}{AMSmath
}\DUfootnotemark{id37
}{id35
}{7} \texttt{cases
} environment (not (yet) supported by
1920 HTML writers with
\texttt{--math-output=MathML
}):
1923 \mathrm{sgn
}(x) =
\begin{cases
}
1929 \section{3 Tests for the LaTeX writer
%
1930 \label{tests-for-the-latex-writer
}%
1933 Test syntax elements which may cause trouble for the LaTeX writer but might
1934 not need to be tested with other writers (e.g. the HTML writer).
1937 \subsection{3.1 Custom Roles in LaTeX
%
1938 \label{custom-roles-in-latex
}%
1942 \item Role names and class arguments are converted to conform to the
1943 regular expression
\texttt{{[}a-z
{]}{[}-a-z0-
9{]}*
} (letters are downcased,
1944 accents and similar decoration is stripped, non-conforming
1945 characters are replaced by a hyphen).
1947 Class arguments may contain numbers and hyphens, which need special
1948 treatment in LaTeX command names.
1950 \DUrole{large
}{\DUrole{custom4
}{\DUrole{small-caps
}{\DUrole{custom-role
}{\DUrole{custom-role
}{Text with role “custom4”
}}}}} (but without styling by
\texttt{DUrole*
}
1953 \item With LaTeX, roles can be styled within the
document using the
\DUroletitlereference{raw
}
1956 \newcommand{\DUrolelarge}[1]{{\large #1}}
1958 \@namedef
{DUrolesmall-caps
}{\textsc}
1959 \@namedef
{DUrolecustom4
}{\textbf}
1962 \DUrole{large
}{\DUrole{custom4
}{\DUrole{small-caps
}{\DUrole{custom-role
}{\DUrole{custom-role
}{inline text
}}}}} in large, bold, small-caps.
1964 \item Custom roles can be based on standard roles:
1966 This is a
\emph{\DUrole{custom-emphasis
}{customized emphasis text role
}}
1968 This is a
\texttt{\DUrole{custom-literal
}{customized literal text role
}}
1970 This is a
\textbf{\DUrole{custom-strong
}{customized strong text role
}}
1972 This is a
\textsubscript{\DUrole{custom-subscript
}{customized subscript text role
}}
1974 This is a
\textsuperscript{\DUrole{custom-superscript
}{customized superscript text role
}}
1976 This is a
\DUroletitlereference{\DUrole{custom-title-reference
}{customized title-reference text role
}}
1980 \subsection{3.2 class handling
%
1981 \label{class-handling
}%
1984 This section tests class handling for block level elements by the LaTeX
1985 writer. See the input file
\texttt{classes
\_latex.txt
} for the raw LaTeX code used
1986 to style the examples.
1988 An “epigraph” directive is exported as “quote” wrapped in a “DUclass”
1989 environment. Here, it is styled by a “DUCLASSepigraph” environment
1990 redefining the “quote” environment as “minipage”:
1992 \newcommand*
{\DUCLASSepigraph}{%
1993 \renewenvironment{quote
}{\vspace{1em
}
1994 \footnotesize\hfill{}%
1995 \begin{minipage
}{0.4\columnwidth}}%
1996 {\end{minipage
}\vskip\baselineskip}}
1998 \begin{DUclass
}{epigraph
}
2000 Do not play this piece fast. It is never right to play
\emph{Ragtime
} fast.
2003 \raggedleft —Scott Joplin
2007 Raw latex is also used to style the following lists: “DUCLASSenumerateitems”
2008 redefines “itemize” as “enumerate”, “DUCLASSrules” draws horizontal lines
2011 \newcommand*
{\DUCLASSenumerateitems}{%
2012 \renewenvironment{itemize
}{\begin{enumerate
}}%
2016 \newenvironment{DUCLASSrules
}%
2017 {\noindent\rule[0.5ex
]{1\columnwidth}{1pt
}}%
2018 {\noindent\rule[0.5ex
]{1\columnwidth}{1pt
}}
2020 An “enumerated” bullet list:
2022 \begin{DUclass
}{enumerateitems
}
2032 A list with lines above and below:
2034 \begin{DUclass
}{rules
}
2042 A normal bullet list is kept unchanged by the above redefinitions:
2052 A container wraps several elements in a common “class wrapper”. Here, we use
2053 it to set
2 paragraphs and a list in small caps:
2055 \newcommand*
{\DUCLASSscshape}{\scshape}
2057 \begin{DUclass
}{scshape
}
2066 \item still bullet list
2070 A right-aligned line-block. Alignment handling is built into the latex
2071 writer for image, table, and line block elements.
2073 \begin{DUlineblock
}{0em
}
2075 \item[] Max Mustermann
2077 \item[] D
01234 Testdorf
2078 \item[] Tel.:
0123/
456789
2082 \subsection{3.3 More Tables
%
2083 \label{more-tables
}%
2086 A table with multi-paragraph multicolumn cells:
2088 \setlength{\DUtablewidth}{\linewidth}
2089 \begin{longtable*
}[c
]{|p
{0.133\DUtablewidth}|p
{0.179\DUtablewidth}|p
{0.179\DUtablewidth}|p
{0.110\DUtablewidth}|p
{0.121\DUtablewidth}|p
{0.145\DUtablewidth}|
}
2095 &
\multicolumn{3}{p
{0.41\DUtablewidth}|
}{%
2098 With a second paragraph
2103 \multicolumn{2}{|p
{0.31\DUtablewidth}|
}{%
2106 With a second paragraph
2119 &
\multicolumn{2}{p
{0.36\DUtablewidth}|
}{%
2120 multicolumn
3 (one line,
2121 but very very very very
2137 &
\multicolumn{3}{p
{0.38\DUtablewidth}|
}{%
2143 Tables with multi-paragraph multirow cells currently fail due to a LaTeX
2144 limitation (see
\url{https://sourceforge.net/p/docutils/bugs/
225/
}).
2146 A table with multirow header and column-widths set by LaTeX:
2148 \begin{longtable*
}[c
]{|l|l|
}
2150 \multirow{2}{*
}{\textbf{XXX
}} &
\textbf{Variable Summary
} \\
2152 &
\textbf{Description
} \\
2156 \multirow{2}{*
}{\textbf{XXX
}} &
\textbf{Variable Summary
} \\
2158 &
\textbf{Description
} \\
2161 \multicolumn{2}{c
}{\hfill ... continued on next page
} \\
2164 \multicolumn{2}{|l|
}{multicollumn cell
} \\
2168 In a table with column-widths set by LaTeX, each cell has just one line.
2169 Paragraphs are merged (a warning is given).
2171 \begin{longtable*
}[c
]{|l|l|
}
2173 11 & first paragraph
2181 % This file is used by the standalone_rst_latex test.
2184 \subsection{3.4 Option lists
%
2188 The LaTeX-
2e description environment is used for definition lists.
2189 The definition is continued on the same line as the term, this should
2190 not happen if a option-list is at the top of the definition.
2192 If the option list is not at the first element in the definition, it
2193 is contained in a quote
2196 \begin{DUoptionlist
}
2197 \item[--help
] show help
2204 \item[{In a definition list:
}] \leavevmode
2205 \begin{DUoptionlist
}
2206 \item[--help
] show help
2214 \subsection{3.5 Monospaced non-alphanumeric characters
%
2215 \label{monospaced-non-alphanumeric-characters
}%
2218 These are all ASCII characters except a-zA-Z0-
9 and space:
2220 \texttt{!!!
\textquotedbl{}\textquotedbl{}\textquotedbl{}\#\#\#\$\$\$\%\%\%\&\&\&'''((()))***+++,,,---...///:::
}
2222 \texttt{;;;<<<===>>>???@@@
{[}{[}{[}\textbackslash{}\textbackslash{}\textbackslash{}{]}{]}{]}\textasciicircum{}\textasciicircum{}\textasciicircum{}\_\_\_```\
{\
{\
{|||\
}\
}\
}\textasciitilde{}\textasciitilde{}\textasciitilde{}}
2224 \texttt{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
}
2226 The two lines of non-alphanumeric characters should both have the same
2227 width as the third line.
2230 \subsection{3.6 Non-ASCII characters
%
2231 \label{non-ascii-characters
}%
2234 Punctuation and footnote symbols
2236 \setlength{\DUtablewidth}{\linewidth}
2237 \begin{longtable*
}[c
]{|p
{0.028\DUtablewidth}|p
{0.424\DUtablewidth}|
}
2254 single turned comma quotation mark
2260 single comma quotation mark
2266 low single comma quotation mark
2272 double turned comma quotation mark
2278 double comma quotation mark
2284 low double comma quotation mark
2338 left-right double arrow
2343 The
\DUroletitlereference{Latin-
1 extended
} Unicode block
2345 \setlength{\DUtablewidth}{\linewidth}
2346 \begin{longtable*
}[c
]{|p
{0.051\DUtablewidth}|p
{0.028\DUtablewidth}|p
{0.028\DUtablewidth}|p
{0.028\DUtablewidth}|p
{0.028\DUtablewidth}|p
{0.028\DUtablewidth}|p
{0.028\DUtablewidth}|p
{0.028\DUtablewidth}|p
{0.028\DUtablewidth}|p
{0.028\DUtablewidth}|p
{0.028\DUtablewidth}|
}
2603 \item The following line should not be wrapped, because it uses
2604 no-break spaces (
\textbackslash{}u00a0):
2606 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
2608 \item Line wrapping with/without breakpoints marked by soft hyphens
2609 (
\textbackslash{}u00ad):
2611 pdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-sch
2613 pdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrisch
2617 \subsection{3.7 Encoding special chars
%
2618 \label{encoding-special-chars
}%
2621 The LaTeX Info pages lists under “
2.18 Special Characters”
2624 The following characters play a special role in LaTeX and are called
2625 “special printing characters”, or simply “special characters”.
2628 \# \$ \% \&
\textasciitilde{} \_ \textasciicircum{} \textbackslash{} \
{ \
}
2632 The special chars verbatim:
2636 # $
% & ~ _ ^ \textbackslash{} \{ \}
2640 However also
\emph{square brackets
} {[}{]} need special care.
2643 Commands with optional arguments (e.g.
\texttt{\textbackslash{}item
}) check
2644 if the token right after the macro name is an opening bracket.
2645 In that case the contents between that bracket and the following
2646 closing bracket on the same grouping level are taken as the
2647 optional argument. What makes this unintuitive is the fact that
2648 the square brackets aren’t grouping characters themselves, so in
2649 your last example
\texttt{\textbackslash{}item
{[}{[}...
{]}{]}} the optional argument consists of
2650 {[}… (without the closing bracket).
2653 Compare the items in the following lists:
2658 \item {[}bracketed
{]} item
2662 \item[{simple
}] \leavevmode
2665 \item[{{[}bracketed
{]}}] \leavevmode
2670 The OT1 font-encoding has different characters for the less-than,
2671 greater-than and bar, < | >, except for typewriter font
\DUroletitlereference{cmtt
}:
2680 \subsection{3.8 Hyperlinks and -targets
%
2681 \label{hyperlinks-and-targets
}%
2684 In LaTeX, we must set an explicit anchor (
\texttt{\textbackslash{}phantomsection
}) for a
2686 \phantomsection\label{hypertarget-in-plain-text
}hypertarget in plain text or in a figure but not in a longtable or
2689 \setlength{\DUtablewidth}{\linewidth}
2690 \begin{longtable
}[c
]{|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|
}
2691 \caption{Table with
%
2692 \label{hypertarget-in-table-title
}hypertarget in table title.
}\\
2706 \phantomsection\label{figure-label
}
2707 \noindent\makebox[\linewidth][c
]{\includegraphics{../../../docs/user/rst/images/biohazard.png
}}
2708 \caption{Figure with
%
2709 \label{hypertarget-in-figure-caption
}hypertarget in figure caption.
}
2712 \phantomsection\label{hypertarget-in-figure-legend
}hypertarget in figure legend.
2716 \includegraphics{../../../docs/user/rst/images/biohazard.png
}
2717 \phantomsection\label{image-label
}
2719 See
\hyperref[hypertarget-in-plain-text
]{hypertarget in plain text
},
2720 \hyperref[table-label
]{table label
},
\hyperref[hypertarget-in-table-title
]{hypertarget in table title
},
2721 \hyperref[figure-label
]{figure label
},
\hyperref[hypertarget-in-figure-caption
]{hypertarget in figure caption
},
2722 \hyperref[hypertarget-in-figure-legend
]{hypertarget in figure legend
}, and
2723 \hyperref[image-label
]{image label
}.
2726 \subsection{3.9 External references
%
2727 \label{external-references
}%
2730 Long URLs should be wrapped in the PDF. This can be achieved with the
2731 \texttt{\textbackslash{}url
} command which is used by the LaTeX writer whenever the content
2732 (name) of a reference node equals the link URL.
2735 \item[{Example:
}] \leavevmode
2736 a long URL that should wrap in the output
2737 \url{http://docutils.sourceforge.net/docs/user/latex.html\#id79
}
2741 If the argument contains any “\%”, “\#”, or “
\textasciicircum{}\textasciicircum{}”, or ends with
\texttt{\textbackslash{}}, it can’t
2742 be used in the argument to another command. The argument must not contain
2745 The characters
\textasciicircum{}, \
{, \
}, and
\texttt{\textbackslash{}} are invalid in a “http:” or “ftp:” URL
2746 and not recognized as part of it:
2748 \begin{DUlineblock
}{0em
}
2749 \item[] \url{http://www.example.org
}/strange
\textasciicircum{}\textasciicircum{}name
2750 \item[] \url{http://www.example.org
}\textbackslash{}using
\textbackslash{}DOS
\textbackslash{}paths
\textbackslash{}
2751 \item[] \url{http://www.example.org/XML
}/strange\
{n\
}ame
2754 They can, however be used in paths and/or filenames.
2756 Handling by the LaTeX writer:
2759 \item \texttt{\#
},
\texttt{\textbackslash{}} and
\texttt{\%
} are escaped:
2761 \begin{DUlineblock
}{0em
}
2762 \item[] \href{http://www.w3.org/XML/Schema\#dev
}{URL with \#
}
2763 \url{http://www.w3.org/XML/Schema\#dev
}
2764 \item[] \href{http://www.w3.org/XML/Schema\%dev
}{URL with \%
}
2765 \url{http://example.org/Schema\%dev
}
2766 \item[] \href{A:DOS\
\path\\
}{file with DOS path
}\DUfootnotemark{id44
}{id43
}{10} \url{A:DOS\
\path\\
}\DUfootnotemark{id45
}{id43
}{10}
2769 \DUadmonition[note
]{
2770 \DUtitle[note
]{Note
}
2772 These URLs are typeset inside a LaTeX command without error.
2774 \begin{DUlineblock
}{0em
}
2775 \item[] \url{http://www.w3.org/XML/Schema\#dev
}
2776 \item[] \url{http://example.org/Schema\%dev
}
2777 \item[] \url{A:DOS\
\path\\
}\DUfootnotemark{id46
}{id43
}{10}
2783 \item \texttt{\textasciicircum{}\textasciicircum{}} LaTeX’s special syntax for characters results in “strange” replacements
2784 (both with
\texttt{\textbackslash{}href
} and
\texttt{\textbackslash{}url
}). A warning is given.
2786 \href{../strange^^name
}{file with
\textasciicircum{}\textasciicircum{}}:
2787 \url{../strange^^name
}
2789 \item Unbalanced braces, \
{ or \
}, will fail (both with
\texttt{\textbackslash{}href
} and
\texttt{\textbackslash{}url
}):
2793 `file with \
{ <../strange\
{name>`__
2794 `<../strange\
{name>`__
2798 while balanced braces are suported:
2800 \begin{DUlineblock
}{0em
}
2801 \item[] \url{../strange
{n
}ame
}
2802 \item[] \url{../st
{r
}ange
{n
}ame
}
2803 \item[] \url{../
{st
{r
}ange
{n
}ame
}}
2808 \subsection{3.10 Section titles with
\hyperref[inline-markup
]{inline markup
}%
2809 \label{section-titles-with-inline-markup
}%
2813 \subsubsection{3.10.1 \emph{emphasized
}, H
\textsubscript{2}O and $x^
2$
%
2814 \label{emphasized-h2o-and-x-
2}%
2818 \subsubsection{3.10.2 Substitutions work
%
2819 \label{substitutions-fail
}%
2823 \subsection{3.11 Deeply nested sections
%
2824 \label{deeply-nested-sections
}%
2830 \subsubsection{3.11.1 Level
3%
2837 \paragraph{3.11.1.1 level
4%
2844 \subparagraph{3.11.1.1.1 level
5%
2848 (depending on the
document class)
2851 \DUtitle[sectionVI
]{3.11.1.1.1.1 level
6%
2855 an unsupported level.
2858 \section{4 Tests for the XeTeX writer
%
2859 \label{tests-for-the-xetex-writer
}%
2862 With XeTeX, you can typeset text in any language/script supported by
2863 Unicode and the selected font, e.g. Azərbaycanca, Bân-lâm-gú, Башҡорт
2864 Беларуская, Български, Català, Чӑвашла, Česky, Ελληνικά, Español,
2865 Français, Føroyskt, Хальмг, Íslenska, עברית , Қазақша, Kurdî,
2866 Latviešu, Lietuvių, Македонски, Монгол, Nāhuatl, Português, Română,
2867 Русский, Slovenščina, Српски, Türkçe, Українська, Tiếng Việt, Volapük,
2868 Võro, ייִדיש , Žemaitėška.
2869 Currently, there is extended support for
28 languages in the
2870 \href{http://ctan.org/pkg/polyglossia
}{polyglossia
}\DUfootnotemark{id39
}{id38
}{8} package.
2875 \section{5 Error Handling
%
2876 \label{error-handling
}%
2879 Any errors caught during processing will generate system messages.
2881 There should be five messages in the following, auto-generated
2882 section, “Docutils System Messages”:
2884 % section should be added by Docutils automatically
2887 \section[Docutils System Messages
]{\color{red
}Docutils System Messages
%
2890 \DUadmonition[system-message
]{
2891 \DUtitle[system-message
]{system-message
}
2892 \raisebox{1em
}{\hypertarget{id27
}{}}
2894 {\color{red
}ERROR/
3} in
\texttt{functional/input/data/standard.txt
}, line~
104
2897 Undefined substitution referenced:
\textquotedbl{}problematic
\textquotedbl{}.
2900 \DUadmonition[system-message
]{
2901 \DUtitle[system-message
]{system-message
}
2902 \raisebox{1em
}{\hypertarget{id47
}{}}
2904 {\color{red
}ERROR/
3} in
\texttt{functional/input/data/standard.txt
}, line~
392
2907 Unknown target name:
\textquotedbl{}5\textquotedbl{}.
2910 \DUadmonition[system-message
]{
2911 \DUtitle[system-message
]{system-message
}
2912 \raisebox{1em
}{\hypertarget{id48
}{}}
2914 {\color{red
}ERROR/
3} in
\texttt{functional/input/data/standard.txt
}, line~
401
2917 Unknown target name:
\textquotedbl{}nonexistent
\textquotedbl{}.
2920 \DUadmonition[system-message
]{
2921 \DUtitle[system-message
]{system-message
}
2922 \raisebox{1em
}{\hypertarget{id49
}{}}
2924 {\color{red
}ERROR/
3} in
\texttt{functional/input/data/standard.txt
}, line~
428
2927 Unknown target name:
\textquotedbl{}hyperlink reference without a target
\textquotedbl{}.
2930 \DUadmonition[system-message
]{
2931 \DUtitle[system-message
]{system-message
}
2932 \raisebox{1em
}{\hypertarget{id51
}{}}
2934 {\color{red
}ERROR/
3} in
\texttt{functional/input/data/standard.txt
}, line~
441
2937 Duplicate target name, cannot be used as a unique reference:
\textquotedbl{}duplicate target names
\textquotedbl{}.