1 \documentclass[a4paper]{article
}
2 % generated by Docutils <http://docutils.sourceforge.net/>
3 \usepackage{cmap
} % fix search and cut-and-paste in Acrobat
5 \usepackage[T1]{fontenc}
6 \usepackage[utf8
]{inputenc}
7 \DeclareUnicodeCharacter{21D4
}{\ensuremath{\Leftrightarrow}}
8 \DeclareUnicodeCharacter{2660}{\ensuremath{\spadesuit}}
9 \DeclareUnicodeCharacter{2663}{\ensuremath{\clubsuit}}
12 \usepackage[british,french,
ngerman,english
]{babel
}
13 % Prevent side-effects if French hyphenation patterns are not loaded:
14 \frenchbsetup{StandardLayout
}
15 \AtBeginDocument{\selectlanguage{english
}\noextrasfrench}
17 \usepackage{float
} % float configuration
18 \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
27 \usepackage{textcomp
} % text symbol macros
29 %%% Custom LaTeX preamble
31 \usepackage{mathptmx
} % Times
32 \usepackage[scaled=
.90]{helvet
}
35 %%% User specified packages and stylesheets
37 %%% Fallback definitions for Docutils-specific commands
39 % class handling for environments (block-level elements)
40 % \begin{DUclass}{spam} tries \DUCLASSspam and
41 % \end{DUclass}{spam} tries \endDUCLASSspam
42 \ifx\DUclass\undefined % poor man's "provideenvironment"
43 \newenvironment{DUclass
}[1]%
44 {\def\DocutilsClassFunctionName{DUCLASS
#1}% arg cannot be used in end-part of environment.
45 \csname \DocutilsClassFunctionName \endcsname}%
46 {\csname end
\DocutilsClassFunctionName \endcsname}%
49 % providelength (provide a length variable and set default, if it is new)
50 \providecommand*
{\DUprovidelength}[2]{
51 \ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{}
55 \providecommand*
{\DUtitleabstract}[1]{\centerline{\textbf{#1}}}
57 % admonition (specially marked topic)
58 \providecommand{\DUadmonition}[2][class-arg
]{%
59 % try \DUadmonition#1{#2}:
60 \ifcsname DUadmonition
#1\endcsname%
61 \csname DUadmonition
#1\endcsname{#2}%
64 \fbox{\parbox{0.9\linewidth}{#2}}
70 \providecommand*
{\DUCLASSdedication}{%
71 \renewenvironment{quote
}{\begin{center
}}{\end{center
}}%
74 % docinfo (width of docinfo table)
75 \DUprovidelength{\DUdocinfowidth}{0.9\linewidth}
77 % subtitle (in document title)
78 \providecommand*
{\DUdocumentsubtitle}[1]{{\large #1}}
81 % error admonition title
82 \providecommand*
{\DUtitleerror}[1]{\DUtitle{\color{red
}#1}}
84 % fieldlist environment
85 \ifthenelse{\isundefined{\DUfieldlist}}{
86 \newenvironment{DUfieldlist
}%
88 {\enddescription\endquote}
90 % numeric or symbol footnotes with hyperlinks
91 \providecommand*
{\DUfootnotemark}[3]{%
92 \raisebox{1em
}{\hypertarget{#1}{}}%
93 \hyperlink{#2}{\textsuperscript{#3}}%
95 \providecommand{\DUfootnotetext}[4]{%
97 \renewcommand{\thefootnote}{%
98 \protect\raisebox{1em
}{\protect\hypertarget{#1}{}}%
99 \protect\hyperlink{#2}{#3}}%
104 % inline markup (custom roles)
105 % \DUrole{#1}{#2} tries \DUrole#1{#2}
106 \providecommand*
{\DUrole}[2]{%
107 \ifcsname DUrole
#1\endcsname%
108 \csname DUrole
#1\endcsname{#2}%
110 % backwards compatibility: try \docutilsrole#1{#2}
111 \ifcsname docutilsrole
#1\endcsname%
112 \csname docutilsrole
#1\endcsname{#2}%
120 \ifthenelse{\isundefined{\DUlegend}}{
121 \newenvironment{DUlegend
}{\small}{}
124 % lineblock environment
125 \DUprovidelength{\DUlineblockindent}{2.5em
}
126 \ifthenelse{\isundefined{\DUlineblock}}{
127 \newenvironment{DUlineblock
}[1]{%
128 \list{}{\setlength{\partopsep}{\parskip}
129 \addtolength{\partopsep}{\baselineskip}
130 \setlength{\topsep}{0pt
}
131 \setlength{\itemsep}{0.15\baselineskip}
132 \setlength{\parsep}{0pt
}
133 \setlength{\leftmargin}{#1}}
139 % optionlist environment
140 \providecommand*
{\DUoptionlistlabel}[1]{\bf #1 \hfill}
141 \DUprovidelength{\DUoptionlistindent}{3cm
}
142 \ifthenelse{\isundefined{\DUoptionlist}}{
143 \newenvironment{DUoptionlist
}{%
144 \list{}{\setlength{\labelwidth}{\DUoptionlistindent}
145 \setlength{\rightmargin}{1cm
}
146 \setlength{\leftmargin}{\rightmargin}
147 \addtolength{\leftmargin}{\labelwidth}
148 \addtolength{\leftmargin}{\labelsep}
149 \renewcommand{\makelabel}{\DUoptionlistlabel}}
154 % rubric (informal heading)
155 \providecommand*
{\DUrubric}[1]{%
156 \subsubsection*
{\centering\textit{\textmd{#1}}}}
158 % sidebar (text outside the main text flow)
159 \providecommand{\DUsidebar}[1]{%
161 \colorbox[gray
]{0.80}{\parbox{0.9\linewidth}{#1}}
165 % subtitle (for topic/sidebar)
166 \providecommand*
{\DUsubtitle}[1]{\par\emph{#1}\smallskip}
168 % text mode subscript
169 \ifx\textsubscript\undefined
170 \usepackage{fixltx2e
} % since 2015 loaded by default
173 % title for topics, admonitions, unsupported section levels, and sidebar
174 \providecommand*
{\DUtitle}[2][class-arg
]{%
175 % call \DUtitle#1{#2} if it exists:
176 \ifcsname DUtitle
#1\endcsname%
177 \csname DUtitle
#1\endcsname{#2}%
179 \smallskip\noindent\textbf{#2}\smallskip%
183 % titlereference role
184 \providecommand*
{\DUroletitlereference}[1]{\textsl{#1}}
186 % transition (break, fancybreak, anonymous section)
187 \providecommand*
{\DUtransition}{%
188 \hspace*
{\fill}\hrulefill\hspace*
{\fill}
189 \vskip 0.5\baselineskip
193 \ifthenelse{\isundefined{\hypersetup}}{
194 \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue
]{hyperref
}
195 \usepackage{bookmark
}
196 \urlstyle{same
} % normal text font (alternatives: tt, rm, sf)
199 pdftitle=
{reStructuredText Test Document
},
200 pdfauthor=
{David Goodger;Me;Myself;I
}
205 \title{reStructuredText Test Document
%
206 \label{restructuredtext-test-
document}%
209 \DUdocumentsubtitle{Examples of Syntax Constructs
}%
210 \label{examples-of-syntax-constructs
}%
218 \begin{tabularx
}{\DUdocinfowidth}{lX
}
227 \href{mailto:goodger@python.org
}{goodger@python.org
} \\
234 \textbf{Organization
}: &
237 Now, or yesterday. Or maybe even
\emph{before
} yesterday. \\
239 This is a “work in progress” \\
241 is managed by a version control system. \\
244 \textbf{Copyright
}: &
245 This
document has been placed in the public domain. You
246 may do with it as you wish. You may copy, modify,
247 redistribute, reattribute, sell, buy, rent, lease,
248 destroy, or improve it, quote it at length, excerpt,
249 incorporate, collate, fold, staple, or mutilate it, or do
250 anything else to it that your or anyone else’s heart
252 \textbf{field name
}: &
253 This is a “generic bibliographic field”.
255 \textbf{field name “
2”
}: &
256 Generic bibliographic fields may contain multiple body elements.
263 \begin{DUclass
}{dedication
}
265 \DUtitle[dedication
]{Dedication
}
267 For Docutils users \& co-developers.
271 \begin{DUclass
}{abstract
}
273 \DUtitle[abstract
]{Abstract
}
275 This is a test
document, containing at least one example of each
276 reStructuredText construct.
280 % This is a comment. Note how any initial comments are moved by
281 % transforms to after the document title, subtitle, and docinfo.
283 % Above is the document title, and below is the subtitle.
284 % They are transformed from section titles after parsing.
286 % bibliographic fields (which also require a transform):
288 \pagebreak[4] % start ToC on new page
290 \phantomsection\label{table-of-contents
}
291 \pdfbookmark[1]{Table of Contents
}{table-of-contents
}
292 \renewcommand{\contentsname}{Table of Contents
}
296 \section{1 Structural Elements
%
297 \label{structural-elements
}%
301 \subsection{1.1 Section Title
%
302 \label{section-title
}%
304 \subsubsection*
{Section Subtitle
}
306 Lone subsections are converted to a section subtitle by a transform
307 activated with the
\texttt{-
{}-section-subtitles
} command line option or the
308 \texttt{sectsubtitle-xform
} configuration value.
311 \subsection{1.2 Empty Section
%
312 \label{empty-section
}%
316 \subsection{1.3 Transitions
%
322 %___________________________________________________________________________
325 It divides the section. Transitions may also occur between sections:
327 %___________________________________________________________________________
331 \section{2 Body Elements
%
332 \label{body-elements
}%
336 \subsection{2.1 Paragraphs
%
343 \subsubsection{2.1.1 Inline Markup
%
344 \label{inline-markup
}%
347 Paragraphs contain text and may contain inline markup:
\emph{emphasis
},
348 \textbf{strong emphasis
},
\texttt{inline literals
}, standalone hyperlinks
349 (
\url{http://www.python.org
}), external hyperlinks (
\href{http://www.python.org/
}{Python
}\DUfootnotemark{id30
}{id29
}{5}), internal
350 cross-references (
\hyperref[example
]{example
}), external hyperlinks with embedded URIs
351 (
\href{http://www.python.org
}{Python web site
}),
\href{http://www.python.org/
}{anonymous hyperlink
352 references
}\DUfootnotemark{id38
}{id29
}{5} (
\href{http://docutils.sourceforge.net/
}{a second reference
}\DUfootnotemark{id40
}{id39
}{8}), footnote references (manually
353 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
]}),
354 substitution references (
\includegraphics{../../../docs/user/rst/images/biohazard.png
} \&
355 a
\emph{trimmed heart
} \texttt{(U+
2665):
}\ding{170}), and
%
356 \phantomsection\label{inline-hyperlink-targets
}inline hyperlink targets
357 (see
\hyperref[targets
]{Targets
} below for a reference back to here). Character-level
358 inline markup is also possible (although exceedingly ugly!) in
\emph{re
}\texttt{Structured
}\emph{Text
}. Problems are indicated by
%
359 \raisebox{1em
}{\hypertarget{id28
}{}}\hyperlink{id27
}{\textbf{\color{red
}|problematic|
}} text
360 (generated by processing errors; this one is intentional). Here is a
361 reference to the
\hyperref[doctitle
]{doctitle
} and the
\hyperref[subtitle
]{subtitle
}.
363 The default role for interpreted text is
\DUroletitlereference{Title Reference
}. Here are
364 some explicit interpreted text roles: a PEP reference (
\href{http://www.python.org/dev/peps/pep-
0287}{PEP
287}); an
365 RFC reference (
\href{http://tools.ietf.org/html/rfc2822.html
}{RFC
2822}); an abbreviation (
\DUrole{abbreviation
}{abb.
}), an acronym
366 (
\DUrole{acronym
}{reST
}), code (
\texttt{\DUrole{code
}{print
\textquotedbl{}hello world
\textquotedbl{}}}); a
\textsubscript{subscript
};
367 a
\textsuperscript{superscript
} and explicit roles for
\DUroletitlereference{Docutils
}’
368 \emph{standard
} \textbf{inline
} \texttt{markup
}.
370 % DO NOT RE-WRAP THE FOLLOWING PARAGRAPH!
372 Let’s test wrapping and whitespace significance in inline literals:
373 \texttt{This is an example of -
{}-inline-literal -
{}-text, -
{}-including some-
{}-
374 strangely-
{}-hyphenated-words. ~Adjust-the-width-of-your-browser-window
375 to see how the text is wrapped. ~-
{}- -
{}-
{}-
{}- -
{}-
{}-
{}-
{}-
{}-
{}-
{}- ~Now note ~ ~the
376 spacing ~ ~between the ~ ~words of ~ ~this sentence ~ ~(words
377 should ~ ~be grouped ~ ~in pairs).
}
379 If the
\texttt{-
{}-pep-references
} option was supplied, there should be a
380 live link to PEP
258 here.
383 \subsection{2.2 Bullet Lists
%
384 \label{bullet-lists
}%
391 \item Nested bullet list.
398 Paragraph
2 of item
2.
401 \item Nested bullet list.
413 \item This nested list should be compacted by the HTML writer.
415 \phantomsection\label{target
}
416 % Even if this item contains a target and a comment.
421 \subsection{2.3 Enumerated Lists
%
422 \label{enumerated-lists
}%
426 \item Arabic numerals.
429 \renewcommand{\labelenumii}{\alph{enumii
})
}
433 \renewcommand{\labelenumiii}{(
\roman{enumiii
})
}
439 \begin{list
}{\Roman{enumv
})
}{\usecounter{enumv
}}
446 \item Lists that don’t start at
1:
449 \renewcommand{\labelenumii}{\arabic{enumii
}.
}
450 \setcounter{enumii
}{2}
457 \renewcommand{\labelenumii}{\Alph{enumii
}.
}
458 \setcounter{enumii
}{2}
465 \renewcommand{\labelenumii}{\roman{enumii
}.
}
466 \setcounter{enumii
}{2}
474 \subsection{2.4 Definition Lists
%
475 \label{definition-lists
}%
479 \item[{Term
}] \leavevmode
482 \item[{Term
}] \leavevmode (
\textbf{classifier
})
483 Definition paragraph
1.
485 Definition paragraph
2.
487 \item[{Term
}] \leavevmode
490 \item[{Term
}] \leavevmode (
\textbf{classifier one
})(
\textbf{classifier two
})
496 \subsection{2.5 Field Lists
%
502 Field lists map field names to field bodies, like database
503 records. They are often part of an extension syntax. They are
504 an unambiguous variant of RFC
2822 fields.
506 \item[{how arg1 arg2:
}]
507 The field marker is a colon, the field name, and a colon.
509 The field body may contain one or more body elements, indented
510 relative to the field marker.
513 \DUrole{credits
}{This paragraph has the
\DUroletitlereference{credits
} class set. (This is actually not
514 about credits but just for ensuring that the class attribute
515 doesn’t get stripped away.)
}
519 \subsection{2.6 Option Lists
%
520 \label{option-lists
}%
523 For listing command-line options:
526 \item[-a
] command-line option “a”
528 \item[-b file
] options can have arguments
529 and long descriptions
531 \item[-
{}-long
] options can be long also
533 \item[-
{}-input=file
] long options can also have
536 \item[-
{}-very-long-option
] The description can also start on the next line.
538 The description may contain multiple body elements,
539 regardless of where it starts.
541 \item[-x, -y, -z
] Multiple options are an “option group”.
543 \item[-v, -
{}-verbose
] Commonly-seen: short \& long options.
545 \item[-
1 file, -
{}-one=file, -
{}-two file
] Multiple options with arguments.
547 \item[/V
] DOS/VMS-style options too
550 There must be at least two spaces between the option and the
554 \subsection{2.7 Literal Blocks
%
555 \label{literal-blocks
}%
558 Literal blocks are indicated with a double-colon (“::”) at the end of
559 the preceding paragraph (over there
\texttt{-
{}->
}). They can be indented:
564 text = 'is left as-is'
565 spaces_and_linebreaks = 'are preserved'
566 markup_processing = None
570 Or they can be quoted without indentation:
576 > Why didn't I think of that?
581 \subsection{2.8 Line Blocks
%
585 This section tests line blocks. Line blocks are body elements which
586 consist of lines and other line blocks. Nested line blocks cause
589 \begin{DUlineblock
}{0em
}
590 \item[] This is a line block. It ends with a blank line.
592 \begin{DUlineblock
}{\DUlineblockindent}
593 \item[] New lines begin with a vertical bar (“|”).
594 \item[] Line breaks and initial indent are significant, and preserved.
596 \begin{DUlineblock
}{\DUlineblockindent}
597 \item[] Continuation lines are also possible. A long line that is intended
598 to wrap should begin with a space in place of the vertical bar.
600 \item[] The left edge of a continuation line need not be aligned with
601 the left edge of the text above it.
605 \begin{DUlineblock
}{0em
}
606 \item[] This is a second line block.
608 \item[] Blank lines are permitted internally, but they must begin with a “|”.
611 Another line block, surrounded by paragraphs:
613 \begin{DUlineblock
}{0em
}
614 \item[] And it’s no good waiting by the window
615 \item[] It’s no good waiting for the sun
616 \item[] Please believe me, the things you dream of
617 \item[] They don’t fall in the lap of no-one
620 Take it away, Eric the Orchestra Leader!
623 \begin{DUlineblock
}{0em
}
624 \item[] A one, two, a one two three four
626 \item[] Half a bee, philosophically,
628 \begin{DUlineblock
}{\DUlineblockindent}
629 \item[] must,
\emph{ipso facto
}, half not be.
631 \item[] But half the bee has got to be,
633 \begin{DUlineblock
}{\DUlineblockindent}
634 \item[] \emph{vis a vis
} its entity. D’you see?
637 \item[] But can a bee be said to be
639 \begin{DUlineblock
}{\DUlineblockindent}
640 \item[] or not to be an entire bee,
642 \begin{DUlineblock
}{\DUlineblockindent}
643 \item[] when half the bee is not a bee,
645 \begin{DUlineblock
}{\DUlineblockindent}
646 \item[] due to some ancient injury?
655 A line block, like the following poem by Christian Morgenstern, can
656 also be centre-aligned:
658 \begin{selectlanguage
}{ngerman}
659 \begin{DUlineblock
}{0em
}
661 \item[] \textbf{Die Trichter
}
663 \item[] Zwei Trichter wandeln durch die Nacht.
664 \item[] Durch ihres Rumpfs verengten Schacht
665 \item[] fließt weißes Mondlicht
666 \item[] still und heiter
676 \subsection{2.9 Block Quotes
%
677 \label{block-quotes
}%
680 Block quotes consist of indented body elements:
683 My theory by A. Elk. Brackets Miss, brackets. This theory goes
684 as follows and begins now. All brontosauruses are thin at one
685 end, much much thicker in the middle and then thin again at the
686 far end. That is my theory, it is mine, and belongs to me and I
687 own it, and what it is too.
690 \raggedleft —Anne Elk (Miss)
693 The language of a quote (like any other object) can be specified by
698 \begin{selectlanguage
}{french
}
700 ReStructuredText est un langage de balisage léger utilisé
701 notamment dans la documentation du langage Python.
706 \subsection{2.10 Doctest Blocks
%
707 \label{doctest-blocks
}%
712 >>> print 'Python-specific usage examples; begun with ">>>"'
713 Python-specific usage examples; begun with ">>>"
714 >>> print '(cut and pasted from interactive Python sessions)'
715 (cut and pasted from interactive Python sessions)
720 \subsection{2.11 Footnotes
%
724 \DUfootnotetext{id8
}{id1
}{1}{%
725 A footnote contains body elements, consistently indented by at
728 This is the footnote’s second paragraph.
731 \DUfootnotetext{label
}{id3
}{2}{\phantomsection\label{label
}%
732 Footnotes may be numbered, either manually (as in
\DUfootnotemark{id9
}{id8
}{1}) or
733 automatically using a “\#”-prefixed label. This footnote has a
734 label so it can be referred to from multiple places, both as a
735 footnote reference (
\DUfootnotemark{id10
}{label
}{2}) and as a
\hyperref[label
]{hyperlink reference
}.
738 \DUfootnotetext{id12
}{id2
}{3}{%
739 This footnote is numbered automatically and anonymously using a
742 This is the second paragraph.
744 And this is the third paragraph.
747 \DUfootnotetext{id13
}{id4
}{*
}{%
748 Footnotes may also use symbols, specified with a “*” label.
749 Here’s a reference to the next footnote:
\DUfootnotemark{id14
}{id15
}{†
}.
752 \DUfootnotetext{id15
}{id14
}{†
}{%
753 This footnote shows the next symbol in the sequence.
756 \DUfootnotetext{id16
}{id16
}{4}{%
757 Here’s an unreferenced footnote, with a reference to a
758 nonexistent footnote:
%
759 \raisebox{1em
}{\hypertarget{id17
}{}}\hyperlink{id45
}{\textbf{\color{red
}{[}5{]}\_}}.
763 \subsection{2.12 Citations
%
766 \begin{figure
}[b
]\raisebox{1em
}{\hypertarget{cit2002
}{}}[CIT2002
]
767 Citations are text-labeled footnotes. They may be
768 rendered separately and differently from footnotes.
771 Here’s a reference to the above,
\hyperlink{cit2002
}{[CIT2002
]}, and a
%
772 \raisebox{1em
}{\hypertarget{id19
}{}}\hyperlink{id46
}{\textbf{\color{red
}{[}nonexistent
{]}\_}}
776 \subsection{2.13 Targets
%
778 \label{another-target
}%
781 \phantomsection\label{example
}
782 This paragraph is pointed to by the explicit “example” target. A
783 reference can be found under
\hyperref[inline-markup
]{Inline Markup
}, above.
\hyperref[inline-hyperlink-targets
]{Inline
784 hyperlink targets
} are also possible.
786 Section headers are implicit targets, referred to by name. See
787 \hyperref[targets
]{Targets
}, which is a subsection of
\hyperref[body-elements
]{Body Elements
}.
789 Explicit external targets are interpolated into references such as
790 “
\href{http://www.python.org/
}{Python
}\DUfootnotemark{id31
}{id29
}{5}”.
792 Targets may be indirect and anonymous. Thus
\hyperref[targets
]{this phrase
} may also
793 refer to the
\hyperref[targets
]{Targets
} section.
796 \raisebox{1em
}{\hypertarget{id48
}{}}\hyperlink{id47
}{\textbf{\color{red
}`hyperlink reference without a target`
\_}}, which generates an
800 \subsubsection{2.13.1 Duplicate Target Names
%
801 \label{duplicate-target-names
}%
804 Duplicate names in section headers or other implicit targets will
805 generate “info” (level-
1) system messages. Duplicate names in
806 explicit targets will generate “warning” (level-
2) system messages.
809 \subsubsection{2.13.2 Duplicate Target Names
%
813 Since there are two “Duplicate Target Names” section headers, we
814 cannot uniquely refer to either of them by name. If we try to (like
816 \raisebox{1em
}{\hypertarget{id50
}{}}\hyperlink{id49
}{\textbf{\color{red
}`Duplicate Target Names`
\_}}), an error is generated.
819 \subsection{2.14 Directives
%
823 \phantomsection\label{contents
}
824 These are just a sample of the many reStructuredText Directives. For
826 \url{http://docutils.sourceforge.net/docs/ref/rst/directives.html
}.
829 \subsubsection{2.14.1 Document Parts
%
830 \label{document-parts
}%
833 An example of the “contents” directive can be seen above this section
834 (a local, untitled table of
\hyperref[contents
]{contents
}) and at the beginning of the
835 document (a
document-wide
\hyperref[table-of-contents
]{table of contents
}).
838 \subsubsection{2.14.2 Images and Figures
%
839 \label{images-and-figures
}%
842 An image directive (also clickable – a hyperlink reference):
844 \hyperref[directives
]{\includegraphics{../../../docs/user/rst/images/title.png
}}
846 Image with multiple IDs:
848 \includegraphics{../../../docs/user/rst/images/title.png
}
849 \phantomsection\label{image-target-
3}\label{image-target-
2}\label{image-target-
1}
853 \noindent\makebox[\linewidth][c
]{\includegraphics{../../../docs/user/rst/images/biohazard.png
}}
855 A left-aligned image:
857 \noindent{\includegraphics{../../../docs/user/rst/images/biohazard.png
}\hfill}
859 This paragraph might flow around the image.
860 The specific behavior depends upon the style sheet and
861 the browser or rendering software used.
863 A right-aligned image:
865 \noindent{\hfill\includegraphics{../../../docs/user/rst/images/biohazard.png
}}
867 This paragraph might flow around the image.
868 The specific behavior depends upon the style sheet and
869 the browser or rendering software used.
871 For inline images see
\hyperref[substitution-definitions
]{Substitution Definitions
}.
877 \includegraphics[width=
2em
]{../../../docs/user/rst/images/biohazard.png
}
879 An image
2 em wide and
15 pixel high:
881 \includegraphics[height=
15px,width=
2em
]{../../../docs/user/rst/images/biohazard.png
}
883 An image occupying
50\% of the line width:
885 \includegraphics[width=
0.500\linewidth]{../../../docs/user/rst/images/title.png
}
889 \includegraphics[height=
2cm
]{../../../docs/user/rst/images/biohazard.png
}
891 A
\emph{figure
} is an image with a caption and/or a legend. With page-based output
892 media, figures might float to a different position if this helps the page
895 \begin{DUclass
}{figclass1
}
896 \begin{DUclass
}{figclass2
}
898 \noindent\makebox[\linewidth][c
]{\includegraphics[width=
258bp
]{../../../docs/user/rst/images/title.png
}}
899 \caption{Plaintext markup syntax and parser system.
}
901 \setlength{\DUtablewidth}{\linewidth}
902 \begin{longtable*
}[c
]{|p
{0.156\DUtablewidth}|p
{0.563\DUtablewidth}|
}
907 Revised, revisited, based on ‘re’ module.
913 Structure-enhanced text, structuredtext.
919 Well it is, isn’t it?
924 This paragraph is also part of the legend.
930 A left-aligned figure:
932 \begin{DUclass
}{figclass1
}
933 \begin{DUclass
}{figclass2
}
934 \begin{figure
} % align = "left"
935 \noindent\makebox[\linewidth][c
]{\includegraphics[width=
40px
]{../../../docs/user/rst/images/biohazard.png
}}
936 \caption{This is the caption.
}
940 The legend may consist of several paragraphs.
946 This paragraph might flow around the figure.
948 The specific behavior depends upon the style sheet and the browser or
949 rendering software used.
954 \noindent\makebox[\linewidth][c
]{\includegraphics[width=
40px
]{../../../docs/user/rst/images/biohazard.png
}}
955 \caption{This is the caption.
}
959 The legend may consist of several paragraphs.
963 This paragraph might flow around the figure.
965 The specific behavior depends upon the style sheet and the browser or
966 rendering software used.
968 A right-aligned figure:
970 \begin{figure
} % align = "right"
971 \noindent\makebox[\linewidth][c
]{\includegraphics[width=
40px
]{../../../docs/user/rst/images/biohazard.png
}}
972 \caption{This is the caption.
}
976 The legend may consist of several paragraphs.
980 This paragraph might flow around the figure. The specific behavior depends
981 upon the style sheet and the browser or rendering software used.
983 Tables may be given titles and additional arguments with the
\emph{table
}
986 \setlength{\DUtablewidth}{\linewidth}
987 \begin{longtable
}[l
]{|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|
}
988 \caption{left-aligned table
}\\
997 \caption[]{left-aligned table (... continued)
}\\
1006 \multicolumn{2}{c
}{\hfill ... continued on next page
} \\
1023 \setlength{\DUtablewidth}{\linewidth}
1024 \begin{longtable
}[c
]{|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|
}
1025 \caption{center-aligned table
}\\
1034 \caption[]{center-aligned table (... continued)
}\\
1043 \multicolumn{2}{c
}{\hfill ... continued on next page
} \\
1060 \setlength{\DUtablewidth}{\linewidth}
1061 \begin{longtable
}[r
]{|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|
}
1062 \caption{right-aligned table
}\\
1071 \caption[]{right-aligned table (... continued)
}\\
1080 \multicolumn{2}{c
}{\hfill ... continued on next page
} \\
1097 With the “widths” argument “auto” (or “class” value “colwidths-auto”),
1098 column widths are determined by the backend (if supported by the
1101 \begin{longtable*
}[c
]{|l|l|l|
}
1103 \textbf{A
} &
\textbf{B
} &
\textbf{A or B
} \\
1107 \textbf{A
} &
\textbf{B
} &
\textbf{A or B
} \\
1110 \multicolumn{3}{c
}{\hfill ... continued on next page
} \\
1113 False & False & False \\
1115 True & False & True \\
1117 False & True & True \\
1119 True & True & True \\
1122 \label{target2
}\label{target1
}
1125 \subsubsection{2.14.3 Admonitions
%
1126 \label{admonitions
}%
1129 \DUadmonition[attention
]{
1130 \DUtitle[attention
]{Attention!
}
1132 Directives at large.
1135 \DUadmonition[caution
]{
1136 \DUtitle[caution
]{Caution!
}
1138 Don’t take any wooden nickels.
1141 \DUadmonition[danger
]{
1142 \DUtitle[danger
]{!DANGER!
}
1144 Mad scientist at work!
1147 \DUadmonition[error
]{
1148 \DUtitle[error
]{Error
}
1153 \DUadmonition[hint
]{
1154 \DUtitle[hint
]{Hint
}
1156 It’s bigger than a bread box.
1159 \DUadmonition[important
]{
1160 \DUtitle[important
]{Important
}
1163 \item Wash behind your ears.
1165 \item Clean up your room.
1167 \item Call your mother.
1169 \item Back up your data.
1173 \DUadmonition[note
]{
1174 \DUtitle[note
]{Note
}
1182 15\% if the service is good.
1185 \DUadmonition[warning
]{
1186 \DUtitle[warning
]{Warning
}
1188 Strong prose may provoke extreme mental exertion.
1189 Reader discretion is strongly advised.
1192 \DUadmonition[admonition-and-by-the-way
]{
1193 \DUtitle[admonition-and-by-the-way
]{And, by the way…
}
1195 You can make up your own admonition too.
1199 \subsubsection{2.14.4 Topics, Sidebars, and Rubrics
%
1200 \label{topics-sidebars-and-rubrics
}%
1203 \emph{Sidebars
} are like miniature, parallel documents.
1206 \DUtitle[title
]{Sidebar Title
}
1208 \DUsubtitle[sidebar
]{Optional Subtitle
}
1210 This is a sidebar. It is for text outside the flow of the main
1213 \DUrubric{This is a rubric inside a sidebar
}
1215 Sidebars often appear beside the main text with a border and a different
1216 background or font
color.
1219 A
\emph{topic
} is like a block quote with a title, or a self-contained section
1220 with no subsections.
1222 \begin{DUclass
}{topic
}
1224 \DUtitle[topic
]{Topic Title
}
1230 A
\emph{rubric
} is like an informal heading that doesn’t correspond to the
1231 document’s structure. It is typically highlighted in red (hence the name).
1233 \DUrubric{This is a rubric
}
1235 Topics and rubrics can be used at places where a
\hyperref[section-title
]{section title
} is not
1236 allowed (e.g. inside a directive).
1239 \subsubsection{2.14.5 Target Footnotes
%
1240 \label{target-footnotes
}%
1243 \DUfootnotetext{id29
}{id30
}{5}{%
1244 \url{http://www.python.org/
}
1247 \DUfootnotetext{id33
}{id34
}{6}{%
1248 \url{http://pygments.org/
}
1251 \DUfootnotetext{id35
}{id36
}{7}{%
1252 \url{ftp://ftp.ams.org/ams/doc/amsmath/short-math-guide.pdf
}
1255 \DUfootnotetext{id39
}{id40
}{8}{%
1256 \url{http://docutils.sourceforge.net/
}
1259 \DUfootnotetext{id41
}{id42
}{9}{%
1264 \subsubsection{2.14.6 Replacement Text
%
1265 \label{replacement-text
}%
1268 I recommend you try
\href{http://www.python.org/
}{Python,
\emph{the
} best language around
}\DUfootnotemark{id32
}{id29
}{5}.
1271 \subsubsection{2.14.7 Compound Paragraph
%
1272 \label{compound-paragraph
}%
1275 The
\emph{compound
} directive is used to create a “compound paragraph”, which
1276 is a single logical paragraph containing multiple physical body
1277 elements. For example:
1279 \begin{DUclass
}{compound
}
1280 The ‘rm’ command is very dangerous. If you are logged
1281 in as root and enter
1288 you will erase the entire contents of your file system.
1291 Test the handling and display of compound paragraphs:
1293 \begin{DUclass
}{compound
}
1294 \begin{DUclass
}{some-class
}
1295 Compound
2, paragraph
1,
1297 compound
2, paragraph
2,
1303 compound
2, paragraph
3.
1307 \begin{DUclass
}{compound
}
1308 Compound
3, only consisting of one paragraph.
1311 \begin{DUclass
}{compound
}
1315 This one starts with a literal block.
1318 Compound
4, paragraph following the literal block.
1321 Now something
\emph{really
} perverted – a nested compound block. This is
1322 just to test that it works at all; the results don’t have to be
1325 \begin{DUclass
}{compound
}
1326 Compound
5, block
1 (a paragraph).
1328 \begin{DUclass
}{compound
}
1329 Compound
6 is block
2 in compound
5.
1331 Compound
6, another paragraph.
1334 Compound
5, block
3 (a paragraph).
1337 \begin{DUclass
}{compound
}
1338 Compound
7, tests the inclusion of various block-level
1339 elements in one logical paragraph. First a table,
1341 \setlength{\DUtablewidth}{\linewidth}
1342 \begin{longtable*
}[c
]{|p
{0.249\DUtablewidth}|p
{0.249\DUtablewidth}|p
{0.249\DUtablewidth}|
}
1364 followed by a paragraph. This physical paragraph is
1365 actually a continuation of the paragraph before the table. It is followed
1371 \item an enumerated list,
1374 \begin{DUoptionlist
}
1375 \item[-
{}-an
] option list,
1384 \item[{a definition
}] \leavevmode
1388 a paragraph, an image:
1389 \includegraphics{../../../docs/user/rst/images/biohazard.png
}
1391 \begin{DUlineblock
}{0em
}
1395 a paragraph followed by a comment,
1399 \DUadmonition[note
]{
1400 \DUtitle[note
]{Note
}
1404 and the final paragraph of the compound
7.
1408 \subsubsection{2.14.8 Parsed Literal Blocks
%
1409 \label{parsed-literal-blocks
}%
1413 \ttfamily\raggedright
1414 This~is~a~parsed~literal~block.\\
1415 ~~~~This~line~is~indented.~~The~next~line~is~blank.\\
1417 Inline~markup~is~supported,~e.g.~
\emph{emphasis
},~
\textbf{strong
},~
\texttt{literal\\
1418 text
},~
\textsubscript{sub-
}~and~
\textsuperscript{super
}scripts,\\
1419 inline~formulas:~$A =
2 \pi r^
2$,\\
1420 footnotes
\DUfootnotemark{id22
}{id8
}{1},~
%
1421 \phantomsection\label{hyperlink-targets
}hyperlink~targets,~and~
\href{http://www.python.org/
}{references
}.
1425 \subsubsection{2.14.9 Code
%
1429 Blocks of source code can be set with the
\DUroletitlereference{code
} directive. If the code
1430 language is specified, the content is parsed and tagged by the
\href{http://pygments.org/
}{Pygments
}\DUfootnotemark{id34
}{id33
}{6}
1431 syntax highlighter and can be formatted with a style sheet. (Code parsing
1432 is turned off using the
\texttt{syntax-highlight
} config setting in the test
1433 conversions in order to get identical results with/without installed
1434 Pygments highlighter.)
1436 \begin{DUclass
}{code
}
1437 \begin{DUclass
}{python
}
1440 print 'This is Python code.'
1446 The
\texttt{:number-lines:
} option (with optional start value) generates line
1449 \begin{DUclass
}{code
}
1450 \begin{DUclass
}{python
}
1452 \ttfamily\raggedright
1453 \DUrole{ln
}{~
8~
}\#~print~integers~from~
0~to~
9:\\
1454 \DUrole{ln
}{~
9~
}for~i~in~range(
10):\\
1455 \DUrole{ln
}{10~
}~~~~print~i
1460 For inline code snippets, there is the
\DUroletitlereference{code
} role, which can be used
1461 directly (the code will not be parsed/tagged, as the language is not known)
1462 or as base for special code roles, e.g. the LaTeX code in the next
1465 Docutils uses LaTeX syntax for math directives and roles:
1466 \texttt{\DUrole{code
}{\DUrole{tex
}{\textbackslash{}alpha = f(x)
}}} prints $
\alpha = f(x)$.
1468 The
\texttt{:code:
} option of the
\DUroletitlereference{include
} directive sets the included content
1469 as a code block, here the rst file
\texttt{header
\_footer.txt
} with line numbers:
1471 \begin{DUclass
}{code
}
1472 \begin{DUclass
}{rst
}
1474 \ttfamily\raggedright
1475 \DUrole{ln
}{1~
}..~header::~Document~header\\
1476 \DUrole{ln
}{2~
}..~footer::~Document~footer
1482 \subsection{2.15 Substitution Definitions
%
1483 \label{substitution-definitions
}%
1486 An inline image (
\includegraphics{../../../docs/user/rst/images/biohazard.png
}) example:
1490 (Substitution definitions are not visible in the HTML source.)
1493 \subsection{2.16 Comments
%
1499 % Comments begin with two dots and a space. Anything may
1500 % follow, except for the syntax of footnotes, hyperlink
1501 % targets, directives, or substitution definitions.
1503 % Double-dashes -- "--" -- must be escaped somehow in HTML output.
1505 % Comments may contain non-ASCII characters: ä ö ü æ ø å
1507 (View the HTML source to see the comment.)
1510 \subsection{2.17 Raw text
%
1514 This does not necessarily look nice, because there may be missing white space.
1516 It’s just there to freeze the behavior.
1522 \DUrole{myclass
}{Another test with myclass set.
}
1524 This is the
\DUrole{myrawroleclass
}{fourth test
} with myrawroleclass set.
1526 Fifth test in LaTeX.\
\Line two.
1529 \subsection{2.18 Container
%
1533 \begin{DUclass
}{custom
}
1540 % currently not implemented in LaTeX:
1541 % .. include:: data/header_footer.txt
1544 \subsection{2.19 Colspanning tables
%
1545 \label{colspanning-tables
}%
1548 This table has a cell spanning two columns:
1550 \setlength{\DUtablewidth}{\linewidth}
1551 \begin{longtable*
}[c
]{|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|p
{0.086\DUtablewidth}|
}
1553 \multicolumn{2}{|p
{0.15\DUtablewidth}|
}{\textbf{%
1569 \multicolumn{2}{|p
{0.15\DUtablewidth}|
}{\textbf{%
1584 \multicolumn{3}{c
}{\hfill ... continued on next page
} \\
1622 \subsection{2.20 Rowspanning tables
%
1623 \label{rowspanning-tables
}%
1626 Here’s a table with cells spanning several rows:
1628 \setlength{\DUtablewidth}{\linewidth}
1629 \begin{longtable*
}[c
]{|p
{0.296\DUtablewidth}|p
{0.156\DUtablewidth}|p
{0.226\DUtablewidth}|
}
1632 Header row, column
1
1633 (header rows optional)
1643 Header row, column
1
1644 (header rows optional)
1652 \multicolumn{3}{c
}{\hfill ... continued on next page
} \\
1656 body row
1, column
1
1665 &
\multirow{2}{0.16\DUtablewidth}{%
1668 } &
\multirow{2}{0.23\DUtablewidth}{%
1681 \subsection{2.21 List Tables
%
1682 \label{list-tables
}%
1685 Here’s a list table exercising all features:
1687 \setlength{\DUtablewidth}{40em
}
1688 \begin{longtable
}[c
]{|p
{0.133\DUtablewidth}|p
{0.249\DUtablewidth}|p
{0.365\DUtablewidth}|
}
1689 \caption{list table with integral header
}\\
1700 \caption[]{list table with integral header (... continued)
}\\
1711 \multicolumn{3}{c
}{\hfill ... continued on next page
} \\
1727 If we took the bones out, it wouldn’t be
1728 crunchy, now would it?
1741 \begin{longtable
}[c
]{|l|l|
}
1742 \caption{center aligned list table
}\\
1746 Crunchy Frog &
1.49 \\
1748 Gannet Ripple &
1.99 \\
1753 \subsection{2.22 Custom Roles
%
1754 \label{custom-roles
}%
1758 \item A role based on an existing role.
1760 \texttt{\DUrole{custom
}{one
}} \texttt{\DUrole{custom
}{two
}} \texttt{\DUrole{custom
}{three
}}
1764 \DUrole{customnew
}{one two three
}
1766 \item A role with class attribute.
1768 \DUrole{special
}{interpreted text
}
1770 \item A language-switching role:
1772 Let’s count in German
\foreignlanguage{ngerman}{eins zwei drei
}.
1774 \item A role with multiple class attributes, styled with raw directives:
1776 \newcommand{\DUrolegreen}[1]{\textcolor{green
}{#1}}
1777 \newcommand{\DUrolesc}[1]{\textsc{#1}}
1779 The following works in most browsers but does not validate
1780 (
\texttt{<style>
} is only allowed in the
document head):
1786 <style type="text/css"><!-
{}-
1787 .green \
{color: green;\
}
1788 .sc \
{font-variant: small-caps;\
}
1793 \DUrole{green
}{\DUrole{sc
}{\foreignlanguage{british
}{British colourful text in small-caps
}}}.
1797 \subsection{2.23 Mathematics
%
1798 \label{mathematics
}%
1801 Docutils supports inline math with the prefix or postfix
\texttt{:math:
}
1802 role specificator, $n! +
\sin(x_n^
2)$ and $A_
\text{c
} =
1803 \frac{\pi}{4} d^
2$, as well as displayed math via the
1804 \DUroletitlereference{math
} directive:
1807 f(
\epsilon) =
\frac{1}{1 +
\exp\left(
\frac{\varepsilon}{k_
\text{B
}T
}\right)
}
1809 Content may start on the first line of the directive, e.g.
1812 N =
\frac{\text{number of apples
}}{7}
1814 Equations can be labeled with a reference name using the
\texttt{:name:
} option.
1815 See
\hyperref[eq-m
]{eq:M
} and
\hyperref[eq-schrodinger
]{eq:schrödinger
} below.
1817 The determinant of the matrix
1820 \mathbf{M
} =
\left(
\begin{matrix
}a&b\
\c&d
\end{matrix
}\right)
1824 is $|
\mathbf{M
}| = ad - bc$.
1826 More than one display math block can be put in one math directive.
1827 For example, the following sum and integral with limits:
1830 \int_0^
1 x^n dx =
\frac{1}{n +
1}
1833 \sum_{n=
1}^m n =
\frac{m(m+
1)
}{2}
1835 LaTeX-supported Unicode math symbols can be used in math roles and
1838 The Schrödinger equation
1841 i
\hbar \frac{\partial }{\partial t
}\Psi =
\hat{H
}\Psi ,
1843 \label{eq-schrodinger
}
1845 with the
\emph{wave function
} $
\Psi $, describes how the quantum state of a
1846 physical system changes in time.
1849 \item[{Math-Accents:
}] \leavevmode
1850 \setlength{\DUtablewidth}{\linewidth}
1851 \begin{longtable*
}[c
]{p
{0.315\DUtablewidth}p
{0.315\DUtablewidth}p
{0.315\DUtablewidth}}
1853 $
\acute{a
}$
\texttt{\textbackslash{}acute\
{a\
}}
1855 $
\dot{t
}$
\texttt{\textbackslash{}dot\
{t\
}}
1857 $
\hat{\gamma}$
\texttt{\textbackslash{}hat\
{\textbackslash{}gamma\
}}
1860 $
\grave{a
}$
\texttt{\textbackslash{}grave\
{a\
}}
1862 $
\ddot{t
}$
\texttt{\textbackslash{}ddot\
{t\
}}
1864 $
\tilde{\alpha}$
\texttt{\textbackslash{}tilde\
{\textbackslash{}alpha\
}}
1867 $
\breve{x
}$
\texttt{\textbackslash{}breve\
{x\
}}
1869 $
\dddot{t
}$
\texttt{\textbackslash{}dddot\
{t\
}}
1871 $
\vec{\imath}$
\texttt{\textbackslash{}vec\
{\textbackslash{}imath\
}}
1874 $
\check{a
}$
\texttt{\textbackslash{}check\
{a\
}}
1876 $
\bar{a
}$
\texttt{\textbackslash{}bar\
{a\
}}
1878 $
\vec{R
}$
\texttt{\textbackslash{}vec\
{R\
}}
1887 Modulation Transfer Function:
1890 \text{MTF
} =
\left|
\frac{\mathcal{F
}\
{s(x)\
}}
1891 {\mathcal{F
}\
{ s(x)\
} |_
{\omega _
{x
}=
0}}\right|
1892 =
\mathrm{abs
}\left(
\frac
1893 {\int _
{-
\infty }^
{\infty }s(x)
\mathrm{e
}^
{\mathrm{i
}\omega _
{x
}x
}\mathrm{d
}{x
}}
1894 {\int _
{-
\infty }^
{\infty }s(x)
\mathrm{d
}{x
}}
1897 Math split over two lines: If a double backslash is detected outside a
1898 \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}
1899 \texttt{align
} environment:
1902 s_
{\mathrm{out
}}(x) & = s_
{\mathrm{in
}}(x') * s_
\delta (x-x') \\
1903 & =
\int s_
{\mathrm{in
}}(x')s_
\delta (x-x')
\mathrm{d
}x'
1905 Cases (“manually”, with
\texttt{matrix
} environment):
1908 \mathrm{sgn
}(x) =
\left\
{\begin{matrix
}
1913 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
1914 HTML writers with
\texttt{-
{}-math-output=MathML
}):
1917 \mathrm{sgn
}(x) =
\begin{cases
}
1923 \section{3 Tests for the LaTeX writer
%
1924 \label{tests-for-the-latex-writer
}%
1927 Test syntax elements which may cause trouble for the LaTeX writer but might
1928 not need to be tested with other writers (e.g. the HTML writer).
1931 \subsection{3.1 Custom Roles in LaTeX
%
1932 \label{custom-roles-in-latex
}%
1936 \item Role names and class arguments are converted to conform to the
1937 regular expression
\texttt{{[}a-z
{]}{[}-a-z0-
9{]}*
} (letters are downcased,
1938 accents and similar decoration is stripped, non-conforming
1939 characters are replaced by a hyphen).
1941 Class arguments may contain numbers and hyphens, which need special
1942 treatment in LaTeX command names.
1944 \DUrole{large
}{\DUrole{custom4
}{\DUrole{small-caps
}{\DUrole{custom-role
}{\DUrole{custom-role
}{Text with role “custom4”
}}}}} (but without styling by
\texttt{DUrole*
}
1947 \item With LaTeX, roles can be styled within the
document using the
\DUroletitlereference{raw
}
1950 \newcommand{\DUrolelarge}[1]{{\large #1}}
1952 \@namedef
{DUrolesmall-caps
}{\textsc}
1953 \@namedef
{DUrolecustom4
}{\textbf}
1956 \DUrole{large
}{\DUrole{custom4
}{\DUrole{small-caps
}{\DUrole{custom-role
}{\DUrole{custom-role
}{inline text
}}}}} in large, bold, small-caps.
1958 \item Custom roles can be based on standard roles:
1960 This is a
\emph{\DUrole{custom-emphasis
}{customized emphasis text role
}}
1962 This is a
\texttt{\DUrole{custom-literal
}{customized literal text role
}}
1964 This is a
\textbf{\DUrole{custom-strong
}{customized strong text role
}}
1966 This is a
\textsubscript{\DUrole{custom-subscript
}{customized subscript text role
}}
1968 This is a
\textsuperscript{\DUrole{custom-superscript
}{customized superscript text role
}}
1970 This is a
\DUroletitlereference{\DUrole{custom-title-reference
}{customized title-reference text role
}}
1974 \subsection{3.2 class handling
%
1975 \label{class-handling
}%
1978 This section tests class handling for block level elements by the LaTeX
1979 writer. See the input file
\texttt{classes
\_latex.txt
} for the raw LaTeX code used
1980 to style the examples.
1982 An “epigraph” directive is exported as “quote” wrapped in a “DUclass”
1983 environment. Here, it is styled by a “DUCLASSepigraph” environment
1984 redefining the “quote” environment as “minipage”:
1986 \newcommand*
{\DUCLASSepigraph}{%
1987 \renewenvironment{quote
}{\vspace{1em
}
1988 \footnotesize\hfill{}%
1989 \begin{minipage
}{0.4\columnwidth}}%
1990 {\end{minipage
}\vskip\baselineskip}}
1992 \begin{DUclass
}{epigraph
}
1994 Do not play this piece fast. It is never right to play
\emph{Ragtime
} fast.
1997 \raggedleft —Scott Joplin
2001 Raw latex is also used to style the following lists: “DUCLASSenumerateitems”
2002 redefines “itemize” as “enumerate”, “DUCLASSrules” draws horizontal lines
2005 \newcommand*
{\DUCLASSenumerateitems}{%
2006 \renewenvironment{itemize
}{\begin{enumerate
}}%
2010 \newenvironment{DUCLASSrules
}%
2011 {\noindent\rule[0.5ex
]{1\columnwidth}{1pt
}}%
2012 {\noindent\rule[0.5ex
]{1\columnwidth}{1pt
}}
2014 An “enumerated” bullet list:
2016 \begin{DUclass
}{enumerateitems
}
2026 A list with lines above and below:
2028 \begin{DUclass
}{rules
}
2036 A normal bullet list is kept unchanged by the above redefinitions:
2046 A container wraps several elements in a common “class wrapper”. Here, we use
2047 it to set
2 paragraphs and a list in small caps:
2049 \newcommand*
{\DUCLASSscshape}{\scshape}
2051 \begin{DUclass
}{scshape
}
2060 \item still bullet list
2064 A right-aligned line-block. Alignment handling is built into the latex
2065 writer for image, table, and line block elements.
2067 \begin{DUlineblock
}{0em
}
2069 \item[] Max Mustermann
2071 \item[] D
01234 Testdorf
2072 \item[] Tel.:
0123/
456789
2076 \subsection{3.3 More Tables
%
2077 \label{more-tables
}%
2080 A table with multi-paragraph multicolumn cells:
2082 \setlength{\DUtablewidth}{\linewidth}
2083 \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}|
}
2089 &
\multicolumn{3}{p
{0.41\DUtablewidth}|
}{%
2092 With a second paragraph
2097 \multicolumn{2}{|p
{0.31\DUtablewidth}|
}{%
2100 With a second paragraph
2113 &
\multicolumn{2}{p
{0.36\DUtablewidth}|
}{%
2114 multicolumn
3 (one line,
2115 but very very very very
2131 &
\multicolumn{3}{p
{0.38\DUtablewidth}|
}{%
2137 Tables with multi-paragraph multirow cells currently fail due to a LaTeX
2138 limitation (see
\url{https://sourceforge.net/p/docutils/bugs/
225/
}).
2140 A table with multirow header and column-widths set by LaTeX:
2142 \begin{longtable*
}[c
]{|l|l|
}
2144 \multirow{2}{*
}{\textbf{XXX
}} &
\textbf{Variable Summary
} \\
2146 &
\textbf{Description
} \\
2150 \multirow{2}{*
}{\textbf{XXX
}} &
\textbf{Variable Summary
} \\
2152 &
\textbf{Description
} \\
2155 \multicolumn{2}{c
}{\hfill ... continued on next page
} \\
2158 \multicolumn{2}{|l|
}{multicollumn cell
} \\
2162 In a table with column-widths set by LaTeX, each cell has just one line.
2163 Paragraphs are merged (a warning is given).
2165 \begin{longtable*
}[c
]{|l|l|
}
2167 11 & first paragraph
2175 % This file is used by the standalone_rst_latex test.
2178 \subsection{3.4 Option lists
%
2182 The LaTeX-
2e description environment is used for definition lists.
2183 The definition is continued on the same line as the term, this should
2184 not happen if a option-list is at the top of the definition.
2186 If the option list is not at the first element in the definition, it
2187 is contained in a quote
2190 \begin{DUoptionlist
}
2191 \item[-
{}-help
] show help
2198 \item[{In a definition list:
}] \leavevmode
2199 \begin{DUoptionlist
}
2200 \item[-
{}-help
] show help
2208 \subsection{3.5 Monospaced non-alphanumeric characters
%
2209 \label{monospaced-non-alphanumeric-characters
}%
2212 These are all ASCII characters except a-zA-Z0-
9 and space:
2214 \texttt{!!!
\textquotedbl{}\textquotedbl{}\textquotedbl{}\#\#\#\$\$\$\%\%\%\&\&\&'
{}'
{}'((()))***+++,
{},
{},-
{}-
{}-...///:::
}
2216 \texttt{;;;<
{}<
{}<===>
{}>
{}>???@@@
{[}{[}{[}\textbackslash{}\textbackslash{}\textbackslash{}{]}{]}{]}\textasciicircum{}\textasciicircum{}\textasciicircum{}\_\_\_`
{}`
{}`\
{\
{\
{|||\
}\
}\
}\textasciitilde{}\textasciitilde{}\textasciitilde{}}
2218 \texttt{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
}
2220 The two lines of non-alphanumeric characters should both have the same
2221 width as the third line.
2224 \subsection{3.6 Non-ASCII characters
%
2225 \label{non-ascii-characters
}%
2228 Punctuation and footnote symbols
2230 \setlength{\DUtablewidth}{\linewidth}
2231 \begin{longtable*
}[c
]{|p
{0.028\DUtablewidth}|p
{0.424\DUtablewidth}|
}
2248 single turned comma quotation mark
2254 single comma quotation mark
2260 low single comma quotation mark
2266 double turned comma quotation mark
2272 double comma quotation mark
2278 low double comma quotation mark
2332 left-right double arrow
2337 The
\DUroletitlereference{Latin-
1 extended
} Unicode block
2339 \setlength{\DUtablewidth}{\linewidth}
2340 \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}|
}
2597 \item The following line should not be wrapped, because it uses
2598 no-break spaces (
\textbackslash{}u00a0):
2600 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
2602 \item Line wrapping with/without breakpoints marked by soft hyphens
2603 (
\textbackslash{}u00ad):
2605 pdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-sch
2607 pdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrisch
2611 \subsection{3.7 Encoding special chars
%
2612 \label{encoding-special-chars
}%
2615 The LaTeX Info pages lists under “
2.18 Special Characters”
2618 The following characters play a special role in LaTeX and are called
2619 “special printing characters”, or simply “special characters”.
2622 \# \$ \% \&
\textasciitilde{} \_ \textasciicircum{} \textbackslash{} \
{ \
}
2626 The special chars verbatim:
2630 # $
% & ~ _ ^ \textbackslash{} \{ \}
2634 However also
\emph{square brackets
} {[}{]} need special care.
2637 Commands with optional arguments (e.g.
\texttt{\textbackslash{}item
}) check
2638 if the token right after the macro name is an opening bracket.
2639 In that case the contents between that bracket and the following
2640 closing bracket on the same grouping level are taken as the
2641 optional argument. What makes this unintuitive is the fact that
2642 the square brackets aren’t grouping characters themselves, so in
2643 your last example
\texttt{\textbackslash{}item
{[}{[}...
{]}{]}} the optional argument consists of
2644 {[}… (without the closing bracket).
2647 Compare the items in the following lists:
2652 \item {[}bracketed
{]} item
2656 \item[{simple
}] \leavevmode
2659 \item[{{[}bracketed
{]}}] \leavevmode
2664 The OT1 font-encoding has different characters for the less-than,
2665 greater-than and bar, < | >, except for typewriter font
\DUroletitlereference{cmtt
}:
2674 \subsection{3.8 Hyperlinks and -targets
%
2675 \label{hyperlinks-and-targets
}%
2678 In LaTeX, we must set an explicit anchor (
\texttt{\textbackslash{}phantomsection
}) for a
2680 \phantomsection\label{hypertarget-in-plain-text
}hypertarget in plain text or in a figure but not in a longtable or
2683 \setlength{\DUtablewidth}{\linewidth}
2684 \begin{longtable
}[c
]{|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|
}
2685 \caption{Table with
%
2686 \label{hypertarget-in-table-title
}hypertarget in table title.
}\\
2700 \phantomsection\label{figure-label
}
2701 \noindent\makebox[\linewidth][c
]{\includegraphics{../../../docs/user/rst/images/biohazard.png
}}
2702 \caption{Figure with
%
2703 \label{hypertarget-in-figure-caption
}hypertarget in figure caption.
}
2706 \phantomsection\label{hypertarget-in-figure-legend
}hypertarget in figure legend.
2710 \includegraphics{../../../docs/user/rst/images/biohazard.png
}
2711 \phantomsection\label{image-label
}
2713 See
\hyperref[hypertarget-in-plain-text
]{hypertarget in plain text
},
2714 \hyperref[table-label
]{table label
},
\hyperref[hypertarget-in-table-title
]{hypertarget in table title
},
2715 \hyperref[figure-label
]{figure label
},
\hyperref[hypertarget-in-figure-caption
]{hypertarget in figure caption
},
2716 \hyperref[hypertarget-in-figure-legend
]{hypertarget in figure legend
}, and
2717 \hyperref[image-label
]{image label
}.
2720 \subsection{3.9 External references
%
2721 \label{external-references
}%
2724 Long URLs should be wrapped in the PDF. This can be achieved with the
2725 \texttt{\textbackslash{}url
} command which is used by the LaTeX writer whenever the content
2726 (name) of a reference node equals the link URL.
2729 \item[{Example:
}] \leavevmode
2730 a long URL that should wrap in the output
2731 \url{http://docutils.sourceforge.net/docs/user/latex.html\#id79
}
2735 If the argument contains any “\%”, “\#”, or “
\textasciicircum{}\textasciicircum{}”, or ends with
\texttt{\textbackslash{}}, it can’t
2736 be used in the argument to another command. The argument must not contain
2739 The characters
\textasciicircum{}, \
{, \
}, and
\texttt{\textbackslash{}} are invalid in a “http:” or “ftp:” URL
2740 and not recognized as part of it:
2742 \begin{DUlineblock
}{0em
}
2743 \item[] \url{http://www.example.org
}/strange
\textasciicircum{}\textasciicircum{}name
2744 \item[] \url{http://www.example.org
}\textbackslash{}using
\textbackslash{}DOS
\textbackslash{}paths
\textbackslash{}
2745 \item[] \url{http://www.example.org/XML
}/strange\
{n\
}ame
2748 They can, however be used in paths and/or filenames.
2750 Handling by the LaTeX writer:
2753 \item \texttt{\#
},
\texttt{\textbackslash{}} and
\texttt{\%
} are escaped:
2755 \begin{DUlineblock
}{0em
}
2756 \item[] \href{http://www.w3.org/XML/Schema\#dev
}{URL with \#
}
2757 \url{http://www.w3.org/XML/Schema\#dev
}
2758 \item[] \href{http://www.w3.org/XML/Schema\%dev
}{URL with \%
}
2759 \url{http://example.org/Schema\%dev
}
2760 \item[] \href{A:DOS\
\path\\
}{file with DOS path
}\DUfootnotemark{id42
}{id41
}{9} \url{A:DOS\
\path\\
}\DUfootnotemark{id43
}{id41
}{9}
2763 \DUadmonition[note
]{
2764 \DUtitle[note
]{Note
}
2766 These URLs are typeset inside a LaTeX command without error.
2768 \begin{DUlineblock
}{0em
}
2769 \item[] \url{http://www.w3.org/XML/Schema\#dev
}
2770 \item[] \url{http://example.org/Schema\%dev
}
2771 \item[] \url{A:DOS\
\path\\
}\DUfootnotemark{id44
}{id41
}{9}
2777 \item \texttt{\textasciicircum{}\textasciicircum{}} LaTeX’s special syntax for characters results in “strange” replacements
2778 (both with
\texttt{\textbackslash{}href
} and
\texttt{\textbackslash{}url
}). A warning is given.
2780 \href{../strange^^name
}{file with
\textasciicircum{}\textasciicircum{}}:
2781 \url{../strange^^name
}
2783 \item Unbalanced braces, \
{ or \
}, will fail (both with
\texttt{\textbackslash{}href
} and
\texttt{\textbackslash{}url
}):
2787 `file with \
{ <../strange\
{name>`__
2788 `<../strange\
{name>`__
2792 while balanced braces are suported:
2794 \begin{DUlineblock
}{0em
}
2795 \item[] \url{../strange
{n
}ame
}
2796 \item[] \url{../st
{r
}ange
{n
}ame
}
2797 \item[] \url{../
{st
{r
}ange
{n
}ame
}}
2802 \subsection{3.10 Section titles with
\hyperref[inline-markup
]{inline markup
}%
2803 \label{section-titles-with-inline-markup
}%
2807 \subsubsection{3.10.1 \emph{emphasized
}, H
\textsubscript{2}O and $x^
2$
%
2808 \label{emphasized-h2o-and-x-
2}%
2812 \subsubsection{3.10.2 Substitutions work
%
2813 \label{substitutions-fail
}%
2817 \subsection{3.11 Deeply nested sections
%
2818 \label{deeply-nested-sections
}%
2824 \subsubsection{3.11.1 Level
3%
2831 \paragraph{3.11.1.1 level
4%
2838 \subparagraph{3.11.1.1.1 level
5%
2842 (depending on the
document class)
2845 \DUtitle[sectionVI
]{3.11.1.1.1.1 level
6%
2849 an unsupported level.
2851 % unusual combinations (currently separately tested)
2852 % .. include:: data/latex_cornercases.txt
2854 % Preface for System Messages:
2857 \section{4 Error Handling
%
2858 \label{error-handling
}%
2861 Any errors caught during processing will generate system messages.
2863 There should be five messages in the following, auto-generated
2864 section, “Docutils System Messages”:
2866 % section should be added by Docutils automatically
2869 \section[Docutils System Messages
]{\color{red
}Docutils System Messages
%
2872 \DUadmonition[system-message
]{
2873 \DUtitle[system-message
]{system-message
}
2874 \raisebox{1em
}{\hypertarget{id27
}{}}
2876 {\color{red
}ERROR/
3} in
\texttt{functional/input/data/standard.txt
}, line~
104
2879 Undefined substitution referenced:
\textquotedbl{}problematic
\textquotedbl{}.
2882 \DUadmonition[system-message
]{
2883 \DUtitle[system-message
]{system-message
}
2884 \raisebox{1em
}{\hypertarget{id45
}{}}
2886 {\color{red
}ERROR/
3} in
\texttt{functional/input/data/standard.txt
}, line~
392
2889 Unknown target name:
\textquotedbl{}5\textquotedbl{}.
2892 \DUadmonition[system-message
]{
2893 \DUtitle[system-message
]{system-message
}
2894 \raisebox{1em
}{\hypertarget{id46
}{}}
2896 {\color{red
}ERROR/
3} in
\texttt{functional/input/data/standard.txt
}, line~
401
2899 Unknown target name:
\textquotedbl{}nonexistent
\textquotedbl{}.
2902 \DUadmonition[system-message
]{
2903 \DUtitle[system-message
]{system-message
}
2904 \raisebox{1em
}{\hypertarget{id47
}{}}
2906 {\color{red
}ERROR/
3} in
\texttt{functional/input/data/standard.txt
}, line~
428
2909 Unknown target name:
\textquotedbl{}hyperlink reference without a target
\textquotedbl{}.
2912 \DUadmonition[system-message
]{
2913 \DUtitle[system-message
]{system-message
}
2914 \raisebox{1em
}{\hypertarget{id49
}{}}
2916 {\color{red
}ERROR/
3} in
\texttt{functional/input/data/standard.txt
}, line~
441
2919 Duplicate target name, cannot be used as a unique reference:
\textquotedbl{}duplicate target names
\textquotedbl{}.