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 % backwards compatibility: try \docutilsrole#1{#2}
108 \ifcsname docutilsrole
#1\endcsname%
109 \csname docutilsrole
#1\endcsname{#2}%
111 \csname DUrole
#1\endcsname{#2}%
116 \ifthenelse{\isundefined{\DUlegend}}{
117 \newenvironment{DUlegend
}{\small}{}
120 % lineblock environment
121 \DUprovidelength{\DUlineblockindent}{2.5em
}
122 \ifthenelse{\isundefined{\DUlineblock}}{
123 \newenvironment{DUlineblock
}[1]{%
124 \list{}{\setlength{\partopsep}{\parskip}
125 \addtolength{\partopsep}{\baselineskip}
126 \setlength{\topsep}{0pt
}
127 \setlength{\itemsep}{0.15\baselineskip}
128 \setlength{\parsep}{0pt
}
129 \setlength{\leftmargin}{#1}}
135 % optionlist environment
136 \providecommand*
{\DUoptionlistlabel}[1]{\bf #1 \hfill}
137 \DUprovidelength{\DUoptionlistindent}{3cm
}
138 \ifthenelse{\isundefined{\DUoptionlist}}{
139 \newenvironment{DUoptionlist
}{%
140 \list{}{\setlength{\labelwidth}{\DUoptionlistindent}
141 \setlength{\rightmargin}{1cm
}
142 \setlength{\leftmargin}{\rightmargin}
143 \addtolength{\leftmargin}{\labelwidth}
144 \addtolength{\leftmargin}{\labelsep}
145 \renewcommand{\makelabel}{\DUoptionlistlabel}}
150 % rubric (informal heading)
151 \providecommand*
{\DUrubric}[1]{%
152 \subsubsection*
{\centering\textit{\textmd{#1}}}}
154 % sidebar (text outside the main text flow)
155 \providecommand{\DUsidebar}[1]{%
157 \colorbox[gray
]{0.80}{\parbox{0.9\linewidth}{#1}}
161 % subtitle (for topic/sidebar)
162 \providecommand*
{\DUsubtitle}[1]{\par\emph{#1}\smallskip}
164 % text mode subscript
165 \ifx\textsubscript\undefined
166 \usepackage{fixltx2e
} % since 2015 loaded by default
169 % title for topics, admonitions, unsupported section levels, and sidebar
170 \providecommand*
{\DUtitle}[2][class-arg
]{%
171 % call \DUtitle#1{#2} if it exists:
172 \ifcsname DUtitle
#1\endcsname%
173 \csname DUtitle
#1\endcsname{#2}%
175 \smallskip\noindent\textbf{#2}\smallskip%
179 % titlereference role
180 \providecommand*
{\DUroletitlereference}[1]{\textsl{#1}}
182 % transition (break, fancybreak, anonymous section)
183 \providecommand*
{\DUtransition}{%
184 \hspace*
{\fill}\hrulefill\hspace*
{\fill}
185 \vskip 0.5\baselineskip
189 \ifthenelse{\isundefined{\hypersetup}}{
190 \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue
]{hyperref
}
191 \usepackage{bookmark
}
192 \urlstyle{same
} % normal text font (alternatives: tt, rm, sf)
195 pdftitle=
{reStructuredText Test Document
},
196 pdfauthor=
{David Goodger;Me;Myself;I
}
201 \title{reStructuredText Test Document
%
202 \label{restructuredtext-test-
document}%
205 \DUdocumentsubtitle{Examples of Syntax Constructs
}%
206 \label{examples-of-syntax-constructs
}%
214 \begin{tabularx
}{\DUdocinfowidth}{lX
}
223 \href{mailto:goodger@python.org
}{goodger@python.org
} \\
230 \textbf{Organization
}: &
233 Now, or yesterday. Or maybe even
\emph{before
} yesterday. \\
235 This is a “work in progress” \\
237 is managed by a version control system. \\
240 \textbf{Copyright
}: &
241 This
document has been placed in the public domain. You
242 may do with it as you wish. You may copy, modify,
243 redistribute, reattribute, sell, buy, rent, lease,
244 destroy, or improve it, quote it at length, excerpt,
245 incorporate, collate, fold, staple, or mutilate it, or do
246 anything else to it that your or anyone else’s heart
248 \textbf{field name
}: &
249 This is a “generic bibliographic field”.
251 \textbf{field name “
2”
}: &
252 Generic bibliographic fields may contain multiple body elements.
259 \begin{DUclass
}{dedication
}
261 \DUtitle[dedication
]{Dedication
}
263 For Docutils users \& co-developers.
267 \begin{DUclass
}{abstract
}
269 \DUtitle[abstract
]{Abstract
}
271 This is a test
document, containing at least one example of each
272 reStructuredText construct.
276 % This is a comment. Note how any initial comments are moved by
277 % transforms to after the document title, subtitle, and docinfo.
279 % Above is the document title, and below is the subtitle.
280 % They are transformed from section titles after parsing.
282 % bibliographic fields (which also require a transform):
284 \pagebreak[4] % start ToC on new page
286 \phantomsection\label{table-of-contents
}
287 \pdfbookmark[1]{Table of Contents
}{table-of-contents
}
288 \renewcommand{\contentsname}{Table of Contents
}
292 \section{1 Structural Elements
%
293 \label{structural-elements
}%
297 \subsection{1.1 Section Title
%
298 \label{section-title
}%
300 \subsubsection*
{Section Subtitle
}
302 Lone subsections are converted to a section subtitle by a transform
303 activated with the
\texttt{-
{}-section-subtitles
} command line option or the
304 \texttt{sectsubtitle-xform
} configuration value.
307 \subsection{1.2 Empty Section
%
308 \label{empty-section
}%
312 \subsection{1.3 Transitions
%
318 %___________________________________________________________________________
321 It divides the section. Transitions may also occur between sections:
323 %___________________________________________________________________________
327 \section{2 Body Elements
%
328 \label{body-elements
}%
332 \subsection{2.1 Paragraphs
%
339 \subsubsection{2.1.1 Inline Markup
%
340 \label{inline-markup
}%
343 Paragraphs contain text and may contain inline markup:
\emph{emphasis
},
344 \textbf{strong emphasis
},
\texttt{inline literals
}, standalone hyperlinks
345 (
\url{http://www.python.org
}), external hyperlinks (
\href{http://www.python.org/
}{Python
}\DUfootnotemark{id30
}{id29
}{5}), internal
346 cross-references (
\hyperref[example
]{example
}), external hyperlinks with embedded URIs
347 (
\href{http://www.python.org
}{Python web site
}),
\href{http://www.python.org/
}{anonymous hyperlink
348 references
}\DUfootnotemark{id38
}{id29
}{5} (
\href{http://docutils.sourceforge.net/
}{a second reference
}\DUfootnotemark{id40
}{id39
}{8}), footnote references (manually
349 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
]}),
350 substitution references (
\includegraphics{../../../docs/user/rst/images/biohazard.png
}), and
%
351 \phantomsection\label{inline-hyperlink-targets
}inline hyperlink targets
352 (see
\hyperref[targets
]{Targets
} below for a reference back to here). Character-level
353 inline markup is also possible (although exceedingly ugly!) in
\emph{re
}\texttt{Structured
}\emph{Text
}. Problems are indicated by
%
354 \raisebox{1em
}{\hypertarget{id28
}{}}\hyperlink{id27
}{\textbf{\color{red
}|problematic|
}} text
355 (generated by processing errors; this one is intentional). Here is a
356 reference to the
\hyperref[doctitle
]{doctitle
} and the
\hyperref[subtitle
]{subtitle
}.
358 The default role for interpreted text is
\DUroletitlereference{Title Reference
}. Here are
359 some explicit interpreted text roles: a PEP reference (
\href{http://www.python.org/dev/peps/pep-
0287}{PEP
287}); an
360 RFC reference (
\href{http://tools.ietf.org/html/rfc2822.html
}{RFC
2822}); an abbreviation (
\DUrole{abbreviation
}{abb.
}), an acronym
361 (
\DUrole{acronym
}{reST
}), code (
\texttt{\DUrole{code
}{print
\textquotedbl{}hello world
\textquotedbl{}}}); a
\textsubscript{subscript
};
362 a
\textsuperscript{superscript
} and explicit roles for
\DUroletitlereference{Docutils
}’
363 \emph{standard
} \textbf{inline
} \texttt{markup
}.
365 % DO NOT RE-WRAP THE FOLLOWING PARAGRAPH!
367 Let’s test wrapping and whitespace significance in inline literals:
368 \texttt{This is an example of -
{}-inline-literal -
{}-text, -
{}-including some-
{}-
369 strangely-
{}-hyphenated-words. ~Adjust-the-width-of-your-browser-window
370 to see how the text is wrapped. ~-
{}- -
{}-
{}-
{}- -
{}-
{}-
{}-
{}-
{}-
{}-
{}- ~Now note ~ ~the
371 spacing ~ ~between the ~ ~words of ~ ~this sentence ~ ~(words
372 should ~ ~be grouped ~ ~in pairs).
}
374 If the
\texttt{-
{}-pep-references
} option was supplied, there should be a
375 live link to PEP
258 here.
378 \subsection{2.2 Bullet Lists
%
379 \label{bullet-lists
}%
386 \item Nested bullet list.
393 Paragraph
2 of item
2.
396 \item Nested bullet list.
408 \item This nested list should be compacted by the HTML writer.
410 \phantomsection\label{target
}
411 % Even if this item contains a target and a comment.
416 \subsection{2.3 Enumerated Lists
%
417 \label{enumerated-lists
}%
421 \item Arabic numerals.
424 \renewcommand{\labelenumii}{\alph{enumii
})
}
428 \renewcommand{\labelenumiii}{(
\roman{enumiii
})
}
434 \begin{list
}{\Roman{enumv
})
}{\usecounter{enumv
}}
441 \item Lists that don’t start at
1:
444 \renewcommand{\labelenumii}{\arabic{enumii
}.
}
445 \setcounter{enumii
}{2}
452 \renewcommand{\labelenumii}{\Alph{enumii
}.
}
453 \setcounter{enumii
}{2}
460 \renewcommand{\labelenumii}{\roman{enumii
}.
}
461 \setcounter{enumii
}{2}
469 \subsection{2.4 Definition Lists
%
470 \label{definition-lists
}%
474 \item[{Term
}] \leavevmode
477 \item[{Term
}] \leavevmode (
\textbf{classifier
})
478 Definition paragraph
1.
480 Definition paragraph
2.
482 \item[{Term
}] \leavevmode
485 \item[{Term
}] \leavevmode (
\textbf{classifier one
})(
\textbf{classifier two
})
491 \subsection{2.5 Field Lists
%
497 Field lists map field names to field bodies, like database
498 records. They are often part of an extension syntax. They are
499 an unambiguous variant of RFC
2822 fields.
501 \item[{how arg1 arg2:
}]
502 The field marker is a colon, the field name, and a colon.
504 The field body may contain one or more body elements, indented
505 relative to the field marker.
508 \DUrole{credits
}{This paragraph has the
\DUroletitlereference{credits
} class set. (This is actually not
509 about credits but just for ensuring that the class attribute
510 doesn’t get stripped away.)
}
514 \subsection{2.6 Option Lists
%
515 \label{option-lists
}%
518 For listing command-line options:
521 \item[-a
] command-line option “a”
523 \item[-b file
] options can have arguments
524 and long descriptions
526 \item[-
{}-long
] options can be long also
528 \item[-
{}-input=file
] long options can also have
531 \item[-
{}-very-long-option
] The description can also start on the next line.
533 The description may contain multiple body elements,
534 regardless of where it starts.
536 \item[-x, -y, -z
] Multiple options are an “option group”.
538 \item[-v, -
{}-verbose
] Commonly-seen: short \& long options.
540 \item[-
1 file, -
{}-one=file, -
{}-two file
] Multiple options with arguments.
542 \item[/V
] DOS/VMS-style options too
545 There must be at least two spaces between the option and the
549 \subsection{2.7 Literal Blocks
%
550 \label{literal-blocks
}%
553 Literal blocks are indicated with a double-colon (“::”) at the end of
554 the preceding paragraph (over there
\texttt{-
{}->
}). They can be indented:
559 text = 'is left as-is'
560 spaces_and_linebreaks = 'are preserved'
561 markup_processing = None
565 Or they can be quoted without indentation:
571 > Why didn't I think of that?
576 \subsection{2.8 Line Blocks
%
580 This section tests line blocks. Line blocks are body elements which
581 consist of lines and other line blocks. Nested line blocks cause
584 \begin{DUlineblock
}{0em
}
585 \item[] This is a line block. It ends with a blank line.
587 \begin{DUlineblock
}{\DUlineblockindent}
588 \item[] New lines begin with a vertical bar (“|”).
589 \item[] Line breaks and initial indent are significant, and preserved.
591 \begin{DUlineblock
}{\DUlineblockindent}
592 \item[] Continuation lines are also possible. A long line that is intended
593 to wrap should begin with a space in place of the vertical bar.
595 \item[] The left edge of a continuation line need not be aligned with
596 the left edge of the text above it.
600 \begin{DUlineblock
}{0em
}
601 \item[] This is a second line block.
603 \item[] Blank lines are permitted internally, but they must begin with a “|”.
606 Another line block, surrounded by paragraphs:
608 \begin{DUlineblock
}{0em
}
609 \item[] And it’s no good waiting by the window
610 \item[] It’s no good waiting for the sun
611 \item[] Please believe me, the things you dream of
612 \item[] They don’t fall in the lap of no-one
615 Take it away, Eric the Orchestra Leader!
618 \begin{DUlineblock
}{0em
}
619 \item[] A one, two, a one two three four
621 \item[] Half a bee, philosophically,
623 \begin{DUlineblock
}{\DUlineblockindent}
624 \item[] must,
\emph{ipso facto
}, half not be.
626 \item[] But half the bee has got to be,
628 \begin{DUlineblock
}{\DUlineblockindent}
629 \item[] \emph{vis a vis
} its entity. D’you see?
632 \item[] But can a bee be said to be
634 \begin{DUlineblock
}{\DUlineblockindent}
635 \item[] or not to be an entire bee,
637 \begin{DUlineblock
}{\DUlineblockindent}
638 \item[] when half the bee is not a bee,
640 \begin{DUlineblock
}{\DUlineblockindent}
641 \item[] due to some ancient injury?
650 A line block, like the following poem by Christian Morgenstern, can
651 also be centre-aligned:
653 \begin{selectlanguage
}{ngerman}
654 \begin{DUlineblock
}{0em
}
656 \item[] \textbf{Die Trichter
}
658 \item[] Zwei Trichter wandeln durch die Nacht.
659 \item[] Durch ihres Rumpfs verengten Schacht
660 \item[] fließt weißes Mondlicht
661 \item[] still und heiter
671 \subsection{2.9 Block Quotes
%
672 \label{block-quotes
}%
675 Block quotes consist of indented body elements:
678 My theory by A. Elk. Brackets Miss, brackets. This theory goes
679 as follows and begins now. All brontosauruses are thin at one
680 end, much much thicker in the middle and then thin again at the
681 far end. That is my theory, it is mine, and belongs to me and I
682 own it, and what it is too.
685 \raggedleft —Anne Elk (Miss)
688 The language of a quote (like any other object) can be specified by
693 \begin{selectlanguage
}{french
}
695 ReStructuredText est un langage de balisage léger utilisé
696 notamment dans la documentation du langage Python.
701 \subsection{2.10 Doctest Blocks
%
702 \label{doctest-blocks
}%
707 >>> print 'Python-specific usage examples; begun with ">>>"'
708 Python-specific usage examples; begun with ">>>"
709 >>> print '(cut and pasted from interactive Python sessions)'
710 (cut and pasted from interactive Python sessions)
715 \subsection{2.11 Footnotes
%
719 \DUfootnotetext{id8
}{id1
}{1}{%
720 A footnote contains body elements, consistently indented by at
723 This is the footnote’s second paragraph.
726 \DUfootnotetext{label
}{id3
}{2}{\phantomsection\label{label
}%
727 Footnotes may be numbered, either manually (as in
\DUfootnotemark{id9
}{id8
}{1}) or
728 automatically using a “\#”-prefixed label. This footnote has a
729 label so it can be referred to from multiple places, both as a
730 footnote reference (
\DUfootnotemark{id10
}{label
}{2}) and as a
\hyperref[label
]{hyperlink reference
}.
733 \DUfootnotetext{id12
}{id2
}{3}{%
734 This footnote is numbered automatically and anonymously using a
737 This is the second paragraph.
739 And this is the third paragraph.
742 \DUfootnotetext{id13
}{id4
}{*
}{%
743 Footnotes may also use symbols, specified with a “*” label.
744 Here’s a reference to the next footnote:
\DUfootnotemark{id14
}{id15
}{†
}.
747 \DUfootnotetext{id15
}{id14
}{†
}{%
748 This footnote shows the next symbol in the sequence.
751 \DUfootnotetext{id16
}{id16
}{4}{%
752 Here’s an unreferenced footnote, with a reference to a
753 nonexistent footnote:
%
754 \raisebox{1em
}{\hypertarget{id17
}{}}\hyperlink{id45
}{\textbf{\color{red
}{[}5{]}\_}}.
758 \subsection{2.12 Citations
%
761 \begin{figure
}[b
]\raisebox{1em
}{\hypertarget{cit2002
}{}}[CIT2002
]
762 Citations are text-labeled footnotes. They may be
763 rendered separately and differently from footnotes.
766 Here’s a reference to the above,
\hyperlink{cit2002
}{[CIT2002
]}, and a
%
767 \raisebox{1em
}{\hypertarget{id19
}{}}\hyperlink{id46
}{\textbf{\color{red
}{[}nonexistent
{]}\_}}
771 \subsection{2.13 Targets
%
773 \label{another-target
}%
776 \phantomsection\label{example
}
777 This paragraph is pointed to by the explicit “example” target. A
778 reference can be found under
\hyperref[inline-markup
]{Inline Markup
}, above.
\hyperref[inline-hyperlink-targets
]{Inline
779 hyperlink targets
} are also possible.
781 Section headers are implicit targets, referred to by name. See
782 \hyperref[targets
]{Targets
}, which is a subsection of
\hyperref[body-elements
]{Body Elements
}.
784 Explicit external targets are interpolated into references such as
785 “
\href{http://www.python.org/
}{Python
}\DUfootnotemark{id31
}{id29
}{5}”.
787 Targets may be indirect and anonymous. Thus
\hyperref[targets
]{this phrase
} may also
788 refer to the
\hyperref[targets
]{Targets
} section.
791 \raisebox{1em
}{\hypertarget{id48
}{}}\hyperlink{id47
}{\textbf{\color{red
}`hyperlink reference without a target`
\_}}, which generates an
795 \subsubsection{2.13.1 Duplicate Target Names
%
796 \label{duplicate-target-names
}%
799 Duplicate names in section headers or other implicit targets will
800 generate “info” (level-
1) system messages. Duplicate names in
801 explicit targets will generate “warning” (level-
2) system messages.
804 \subsubsection{2.13.2 Duplicate Target Names
%
808 Since there are two “Duplicate Target Names” section headers, we
809 cannot uniquely refer to either of them by name. If we try to (like
811 \raisebox{1em
}{\hypertarget{id50
}{}}\hyperlink{id49
}{\textbf{\color{red
}`Duplicate Target Names`
\_}}), an error is generated.
814 \subsection{2.14 Directives
%
818 \phantomsection\label{contents
}
819 These are just a sample of the many reStructuredText Directives. For
821 \url{http://docutils.sourceforge.net/docs/ref/rst/directives.html
}.
824 \subsubsection{2.14.1 Document Parts
%
825 \label{document-parts
}%
828 An example of the “contents” directive can be seen above this section
829 (a local, untitled table of
\hyperref[contents
]{contents
}) and at the beginning of the
830 document (a
document-wide
\hyperref[table-of-contents
]{table of contents
}).
833 \subsubsection{2.14.2 Images and Figures
%
834 \label{images-and-figures
}%
837 An image directive (also clickable – a hyperlink reference):
839 \hyperref[directives
]{\includegraphics{../../../docs/user/rst/images/title.png
}}
841 Image with multiple IDs:
843 \includegraphics{../../../docs/user/rst/images/title.png
}
844 \phantomsection\label{image-target-
3}\label{image-target-
2}\label{image-target-
1}
848 \noindent\makebox[\linewidth][c
]{\includegraphics{../../../docs/user/rst/images/biohazard.png
}}
850 A left-aligned image:
852 \noindent{\includegraphics{../../../docs/user/rst/images/biohazard.png
}\hfill}
854 This paragraph might flow around the image.
855 The specific behavior depends upon the style sheet and
856 the browser or rendering software used.
858 A right-aligned image:
860 \noindent{\hfill\includegraphics{../../../docs/user/rst/images/biohazard.png
}}
862 This paragraph might flow around the image.
863 The specific behavior depends upon the style sheet and
864 the browser or rendering software used.
866 For inline images see
\hyperref[substitution-definitions
]{Substitution Definitions
}.
872 \includegraphics[width=
2em
]{../../../docs/user/rst/images/biohazard.png
}
874 An image
2 em wide and
15 pixel high:
876 \includegraphics[height=
15px,width=
2em
]{../../../docs/user/rst/images/biohazard.png
}
878 An image occupying
50\% of the line width:
880 \includegraphics[width=
0.500\linewidth]{../../../docs/user/rst/images/title.png
}
884 \includegraphics[height=
2cm
]{../../../docs/user/rst/images/biohazard.png
}
886 A
\emph{figure
} is an image with a caption and/or a legend. With page-based output
887 media, figures might float to a different position if this helps the page
890 \begin{DUclass
}{figclass1
}
891 \begin{DUclass
}{figclass2
}
893 \noindent\makebox[\linewidth][c
]{\includegraphics[width=
258bp
]{../../../docs/user/rst/images/title.png
}}
894 \caption{Plaintext markup syntax and parser system.
}
896 \setlength{\DUtablewidth}{\linewidth}
897 \begin{longtable*
}[c
]{|p
{0.156\DUtablewidth}|p
{0.563\DUtablewidth}|
}
902 Revised, revisited, based on ‘re’ module.
908 Structure-enhanced text, structuredtext.
914 Well it is, isn’t it?
919 This paragraph is also part of the legend.
925 A left-aligned figure:
927 \begin{DUclass
}{figclass1
}
928 \begin{DUclass
}{figclass2
}
929 \begin{figure
} % align = "left"
930 \noindent\makebox[\linewidth][c
]{\includegraphics[width=
40px
]{../../../docs/user/rst/images/biohazard.png
}}
931 \caption{This is the caption.
}
935 The legend may consist of several paragraphs.
941 This paragraph might flow around the figure.
943 The specific behavior depends upon the style sheet and the browser or
944 rendering software used.
949 \noindent\makebox[\linewidth][c
]{\includegraphics[width=
40px
]{../../../docs/user/rst/images/biohazard.png
}}
950 \caption{This is the caption.
}
954 The legend may consist of several paragraphs.
958 This paragraph might flow around the figure.
960 The specific behavior depends upon the style sheet and the browser or
961 rendering software used.
963 A right-aligned figure:
965 \begin{figure
} % align = "right"
966 \noindent\makebox[\linewidth][c
]{\includegraphics[width=
40px
]{../../../docs/user/rst/images/biohazard.png
}}
967 \caption{This is the caption.
}
971 The legend may consist of several paragraphs.
975 This paragraph might flow around the figure. The specific behavior depends
976 upon the style sheet and the browser or rendering software used.
978 Tables may be given titles and additional arguments with the
\emph{table
}
981 \setlength{\DUtablewidth}{\linewidth}
982 \begin{longtable
}[l
]{|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|
}
983 \caption{left-aligned table
}\\
992 \caption[]{left-aligned table (... continued)
}\\
1001 \multicolumn{2}{c
}{\hfill ... continued on next page
} \\
1018 \setlength{\DUtablewidth}{\linewidth}
1019 \begin{longtable
}[c
]{|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|
}
1020 \caption{center-aligned table
}\\
1029 \caption[]{center-aligned table (... continued)
}\\
1038 \multicolumn{2}{c
}{\hfill ... continued on next page
} \\
1055 \setlength{\DUtablewidth}{\linewidth}
1056 \begin{longtable
}[r
]{|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|
}
1057 \caption{right-aligned table
}\\
1066 \caption[]{right-aligned table (... continued)
}\\
1075 \multicolumn{2}{c
}{\hfill ... continued on next page
} \\
1092 With the “widths” argument “auto” (or “class” value “colwidths-auto”),
1093 column widths are determined by the backend (if supported by the
1096 \begin{longtable*
}[c
]{|l|l|l|
}
1098 \textbf{A
} &
\textbf{B
} &
\textbf{A or B
} \\
1102 \textbf{A
} &
\textbf{B
} &
\textbf{A or B
} \\
1105 \multicolumn{3}{c
}{\hfill ... continued on next page
} \\
1108 False & False & False \\
1110 True & False & True \\
1112 False & True & True \\
1114 True & True & True \\
1117 \label{target2
}\label{target1
}
1120 \subsubsection{2.14.3 Admonitions
%
1121 \label{admonitions
}%
1124 \DUadmonition[attention
]{
1125 \DUtitle[attention
]{Attention!
}
1127 Directives at large.
1130 \DUadmonition[caution
]{
1131 \DUtitle[caution
]{Caution!
}
1133 Don’t take any wooden nickels.
1136 \DUadmonition[danger
]{
1137 \DUtitle[danger
]{!DANGER!
}
1139 Mad scientist at work!
1142 \DUadmonition[error
]{
1143 \DUtitle[error
]{Error
}
1148 \DUadmonition[hint
]{
1149 \DUtitle[hint
]{Hint
}
1151 It’s bigger than a bread box.
1154 \DUadmonition[important
]{
1155 \DUtitle[important
]{Important
}
1158 \item Wash behind your ears.
1160 \item Clean up your room.
1162 \item Call your mother.
1164 \item Back up your data.
1168 \DUadmonition[note
]{
1169 \DUtitle[note
]{Note
}
1177 15\% if the service is good.
1180 \DUadmonition[warning
]{
1181 \DUtitle[warning
]{Warning
}
1183 Strong prose may provoke extreme mental exertion.
1184 Reader discretion is strongly advised.
1187 \DUadmonition[admonition-and-by-the-way
]{
1188 \DUtitle[admonition-and-by-the-way
]{And, by the way…
}
1190 You can make up your own admonition too.
1194 \subsubsection{2.14.4 Topics, Sidebars, and Rubrics
%
1195 \label{topics-sidebars-and-rubrics
}%
1198 \emph{Sidebars
} are like miniature, parallel documents.
1201 \DUtitle[title
]{Sidebar Title
}
1203 \DUsubtitle[sidebar
]{Optional Subtitle
}
1205 This is a sidebar. It is for text outside the flow of the main
1208 \DUrubric{This is a rubric inside a sidebar
}
1210 Sidebars often appear beside the main text with a border and a different
1211 background or font
color.
1214 A
\emph{topic
} is like a block quote with a title, or a self-contained section
1215 with no subsections.
1217 \begin{DUclass
}{topic
}
1219 \DUtitle[topic
]{Topic Title
}
1225 A
\emph{rubric
} is like an informal heading that doesn’t correspond to the
1226 document’s structure. It is typically highlighted in red (hence the name).
1228 \DUrubric{This is a rubric
}
1230 Topics and rubrics can be used at places where a
\hyperref[section-title
]{section title
} is not
1231 allowed (e.g. inside a directive).
1234 \subsubsection{2.14.5 Target Footnotes
%
1235 \label{target-footnotes
}%
1238 \DUfootnotetext{id29
}{id30
}{5}{%
1239 \url{http://www.python.org/
}
1242 \DUfootnotetext{id33
}{id34
}{6}{%
1243 \url{http://pygments.org/
}
1246 \DUfootnotetext{id35
}{id36
}{7}{%
1247 \url{ftp://ftp.ams.org/ams/doc/amsmath/short-math-guide.pdf
}
1250 \DUfootnotetext{id39
}{id40
}{8}{%
1251 \url{http://docutils.sourceforge.net/
}
1254 \DUfootnotetext{id41
}{id42
}{9}{%
1259 \subsubsection{2.14.6 Replacement Text
%
1260 \label{replacement-text
}%
1263 I recommend you try
\href{http://www.python.org/
}{Python,
\emph{the
} best language around
}\DUfootnotemark{id32
}{id29
}{5}.
1266 \subsubsection{2.14.7 Compound Paragraph
%
1267 \label{compound-paragraph
}%
1270 The
\emph{compound
} directive is used to create a “compound paragraph”, which
1271 is a single logical paragraph containing multiple physical body
1272 elements. For example:
1274 \begin{DUclass
}{compound
}
1275 The ‘rm’ command is very dangerous. If you are logged
1276 in as root and enter
1283 you will erase the entire contents of your file system.
1286 Test the handling and display of compound paragraphs:
1288 \begin{DUclass
}{compound
}
1289 \begin{DUclass
}{some-class
}
1290 Compound
2, paragraph
1,
1292 compound
2, paragraph
2,
1298 compound
2, paragraph
3.
1302 \begin{DUclass
}{compound
}
1303 Compound
3, only consisting of one paragraph.
1306 \begin{DUclass
}{compound
}
1310 This one starts with a literal block.
1313 Compound
4, paragraph following the literal block.
1316 Now something
\emph{really
} perverted – a nested compound block. This is
1317 just to test that it works at all; the results don’t have to be
1320 \begin{DUclass
}{compound
}
1321 Compound
5, block
1 (a paragraph).
1323 \begin{DUclass
}{compound
}
1324 Compound
6 is block
2 in compound
5.
1326 Compound
6, another paragraph.
1329 Compound
5, block
3 (a paragraph).
1332 \begin{DUclass
}{compound
}
1333 Compound
7, tests the inclusion of various block-level
1334 elements in one logical paragraph. First a table,
1336 \setlength{\DUtablewidth}{\linewidth}
1337 \begin{longtable*
}[c
]{|p
{0.249\DUtablewidth}|p
{0.249\DUtablewidth}|p
{0.249\DUtablewidth}|
}
1359 followed by a paragraph. This physical paragraph is
1360 actually a continuation of the paragraph before the table. It is followed
1366 \item an enumerated list,
1369 \begin{DUoptionlist
}
1370 \item[-
{}-an
] option list,
1379 \item[{a definition
}] \leavevmode
1383 a paragraph, an image:
1384 \includegraphics{../../../docs/user/rst/images/biohazard.png
}
1386 \begin{DUlineblock
}{0em
}
1390 a paragraph followed by a comment,
1394 \DUadmonition[note
]{
1395 \DUtitle[note
]{Note
}
1399 and the final paragraph of the compound
7.
1403 \subsubsection{2.14.8 Parsed Literal Blocks
%
1404 \label{parsed-literal-blocks
}%
1408 \ttfamily\raggedright
1409 This~is~a~parsed~literal~block.\\
1410 ~~~~This~line~is~indented.~~The~next~line~is~blank.\\
1412 Inline~markup~is~supported,~e.g.~
\emph{emphasis
},~
\textbf{strong
},~
\texttt{literal\\
1413 text
},~
\textsubscript{sub-
}~and~
\textsuperscript{super
}scripts,\\
1414 inline~formulas:~$A =
2 \pi r^
2$,\\
1415 footnotes
\DUfootnotemark{id22
}{id8
}{1},~
%
1416 \phantomsection\label{hyperlink-targets
}hyperlink~targets,~and~
\href{http://www.python.org/
}{references
}.
1420 \subsubsection{2.14.9 Code
%
1424 Blocks of source code can be set with the
\DUroletitlereference{code
} directive. If the code
1425 language is specified, the content is parsed and tagged by the
\href{http://pygments.org/
}{Pygments
}\DUfootnotemark{id34
}{id33
}{6}
1426 syntax highlighter and can be formatted with a style sheet. (Code parsing
1427 is turned off using the
\texttt{syntax-highlight
} config setting in the test
1428 conversions in order to get identical results with/without installed
1429 Pygments highlighter.)
1431 \begin{DUclass
}{code
}
1432 \begin{DUclass
}{python
}
1435 print 'This is Python code.'
1441 The
\texttt{:number-lines:
} option (with optional start value) generates line
1444 \begin{DUclass
}{code
}
1445 \begin{DUclass
}{python
}
1447 \ttfamily\raggedright
1448 \DUrole{ln
}{~
8~
}\#~print~integers~from~
0~to~
9:\\
1449 \DUrole{ln
}{~
9~
}for~i~in~range(
10):\\
1450 \DUrole{ln
}{10~
}~~~~print~i
1455 For inline code snippets, there is the
\DUroletitlereference{code
} role, which can be used
1456 directly (the code will not be parsed/tagged, as the language is not known)
1457 or as base for special code roles, e.g. the LaTeX code in the next
1460 Docutils uses LaTeX syntax for math directives and roles:
1461 \texttt{\DUrole{code
}{\DUrole{tex
}{\textbackslash{}alpha = f(x)
}}} prints $
\alpha = f(x)$.
1463 The
\texttt{:code:
} option of the
\DUroletitlereference{include
} directive sets the included content
1464 as a code block, here the rst file
\texttt{header
\_footer.txt
} with line numbers:
1466 \begin{DUclass
}{code
}
1467 \begin{DUclass
}{rst
}
1469 \ttfamily\raggedright
1470 \DUrole{ln
}{1~
}..~header::~Document~header\\
1471 \DUrole{ln
}{2~
}..~footer::~Document~footer
1477 \subsection{2.15 Substitution Definitions
%
1478 \label{substitution-definitions
}%
1481 An inline image (
\includegraphics{../../../docs/user/rst/images/biohazard.png
}) example:
1483 (Substitution definitions are not visible in the HTML source.)
1486 \subsection{2.16 Comments
%
1492 % Comments begin with two dots and a space. Anything may
1493 % follow, except for the syntax of footnotes, hyperlink
1494 % targets, directives, or substitution definitions.
1496 % Double-dashes -- "--" -- must be escaped somehow in HTML output.
1498 % Comments may contain non-ASCII characters: ä ö ü æ ø å
1500 (View the HTML source to see the comment.)
1503 \subsection{2.17 Raw text
%
1507 This does not necessarily look nice, because there may be missing white space.
1509 It’s just there to freeze the behavior.
1515 \DUrole{myclass
}{Another test with myclass set.
}
1517 This is the
\DUrole{myrawroleclass
}{fourth test
} with myrawroleclass set.
1519 Fifth test in LaTeX.\
\Line two.
1522 \subsection{2.18 Container
%
1526 \begin{DUclass
}{custom
}
1533 % currently not implemented in LaTeX:
1534 % .. include:: data/header_footer.txt
1537 \subsection{2.19 Colspanning tables
%
1538 \label{colspanning-tables
}%
1541 This table has a cell spanning two columns:
1543 \setlength{\DUtablewidth}{\linewidth}
1544 \begin{longtable*
}[c
]{|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|p
{0.086\DUtablewidth}|
}
1546 \multicolumn{2}{|p
{0.15\DUtablewidth}|
}{\textbf{%
1562 \multicolumn{2}{|p
{0.15\DUtablewidth}|
}{\textbf{%
1577 \multicolumn{3}{c
}{\hfill ... continued on next page
} \\
1615 \subsection{2.20 Rowspanning tables
%
1616 \label{rowspanning-tables
}%
1619 Here’s a table with cells spanning several rows:
1621 \setlength{\DUtablewidth}{\linewidth}
1622 \begin{longtable*
}[c
]{|p
{0.296\DUtablewidth}|p
{0.156\DUtablewidth}|p
{0.226\DUtablewidth}|
}
1625 Header row, column
1
1626 (header rows optional)
1636 Header row, column
1
1637 (header rows optional)
1645 \multicolumn{3}{c
}{\hfill ... continued on next page
} \\
1649 body row
1, column
1
1658 &
\multirow{2}{0.16\DUtablewidth}{%
1661 } &
\multirow{2}{0.23\DUtablewidth}{%
1674 \subsection{2.21 List Tables
%
1675 \label{list-tables
}%
1678 Here’s a list table exercising all features:
1680 \setlength{\DUtablewidth}{40em
}
1681 \begin{longtable
}[c
]{|p
{0.133\DUtablewidth}|p
{0.249\DUtablewidth}|p
{0.365\DUtablewidth}|
}
1682 \caption{list table with integral header
}\\
1693 \caption[]{list table with integral header (... continued)
}\\
1704 \multicolumn{3}{c
}{\hfill ... continued on next page
} \\
1720 If we took the bones out, it wouldn’t be
1721 crunchy, now would it?
1734 \begin{longtable
}[c
]{|l|l|
}
1735 \caption{center aligned list table
}\\
1739 Crunchy Frog &
1.49 \\
1741 Gannet Ripple &
1.99 \\
1746 \subsection{2.22 Custom Roles
%
1747 \label{custom-roles
}%
1751 \item A role based on an existing role.
1753 \texttt{\DUrole{custom
}{one
}} \texttt{\DUrole{custom
}{two
}} \texttt{\DUrole{custom
}{three
}}
1757 \DUrole{customnew
}{one two three
}
1759 \item A role with class attribute.
1761 \DUrole{special
}{interpreted text
}
1763 \item A language-switching role:
1765 Let’s count in German
\foreignlanguage{ngerman}{eins zwei drei
}.
1767 \item A role with multiple class attributes, styled with raw directives:
1769 \newcommand{\DUrolegreen}[1]{\textcolor{green
}{#1}}
1770 \newcommand{\DUrolesc}[1]{\textsc{#1}}
1772 The following works in most browsers but does not validate
1773 (
\texttt{<style>
} is only allowed in the
document head):
1779 <style type="text/css"><!-
{}-
1780 .green \
{color: green;\
}
1781 .sc \
{font-variant: small-caps;\
}
1786 \DUrole{green
}{\DUrole{sc
}{\foreignlanguage{british
}{British colourful text in small-caps
}}}.
1790 \subsection{2.23 Mathematics
%
1791 \label{mathematics
}%
1794 Docutils supports inline math with the prefix or postfix
\texttt{:math:
}
1795 role specificator, $n! +
\sin(x_n^
2)$ and $A_
\text{c
} =
1796 \frac{\pi}{4} d^
2$, as well as displayed math via the
1797 \DUroletitlereference{math
} directive:
1800 f(
\epsilon) =
\frac{1}{1 +
\exp\left(
\frac{\varepsilon}{k_
\text{B
}T
}\right)
}
1802 Content may start on the first line of the directive, e.g.
1805 N =
\frac{\text{number of apples
}}{7}
1807 Equations can be labeled with a reference name using the
\texttt{:name:
} option.
1808 See
\hyperref[eq-m
]{eq:M
} and
\hyperref[eq-schrodinger
]{eq:schrödinger
} below.
1810 The determinant of the matrix
1813 \mathbf{M
} =
\left(
\begin{matrix
}a&b\
\c&d
\end{matrix
}\right)
1817 is $|
\mathbf{M
}| = ad - bc$.
1819 More than one display math block can be put in one math directive.
1820 For example, the following sum and integral with limits:
1823 \int_0^
1 x^n dx =
\frac{1}{n +
1}
1826 \sum_{n=
1}^m n =
\frac{m(m+
1)
}{2}
1828 LaTeX-supported Unicode math symbols can be used in math roles and
1831 The Schrödinger equation
1834 i
\hbar \frac{\partial }{\partial t
}\Psi =
\hat{H
}\Psi ,
1836 \label{eq-schrodinger
}
1838 with the
\emph{wave function
} $
\Psi $, describes how the quantum state of a
1839 physical system changes in time.
1842 \item[{Math-Accents:
}] \leavevmode
1843 \setlength{\DUtablewidth}{\linewidth}
1844 \begin{longtable*
}[c
]{p
{0.315\DUtablewidth}p
{0.315\DUtablewidth}p
{0.315\DUtablewidth}}
1846 $
\acute{a
}$
\texttt{\textbackslash{}acute\
{a\
}}
1848 $
\dot{t
}$
\texttt{\textbackslash{}dot\
{t\
}}
1850 $
\hat{\gamma}$
\texttt{\textbackslash{}hat\
{\textbackslash{}gamma\
}}
1853 $
\grave{a
}$
\texttt{\textbackslash{}grave\
{a\
}}
1855 $
\ddot{t
}$
\texttt{\textbackslash{}ddot\
{t\
}}
1857 $
\tilde{\alpha}$
\texttt{\textbackslash{}tilde\
{\textbackslash{}alpha\
}}
1860 $
\breve{x
}$
\texttt{\textbackslash{}breve\
{x\
}}
1862 $
\dddot{t
}$
\texttt{\textbackslash{}dddot\
{t\
}}
1864 $
\vec{\imath}$
\texttt{\textbackslash{}vec\
{\textbackslash{}imath\
}}
1867 $
\check{a
}$
\texttt{\textbackslash{}check\
{a\
}}
1869 $
\bar{a
}$
\texttt{\textbackslash{}bar\
{a\
}}
1871 $
\vec{R
}$
\texttt{\textbackslash{}vec\
{R\
}}
1880 Modulation Transfer Function:
1883 \text{MTF
} =
\left|
\frac{\mathcal{F
}\
{s(x)\
}}
1884 {\mathcal{F
}\
{ s(x)\
} |_
{\omega _
{x
}=
0}}\right|
1885 =
\mathrm{abs
}\left(
\frac
1886 {\int _
{-
\infty }^
{\infty }s(x)
\mathrm{e
}^
{\mathrm{i
}\omega _
{x
}x
}\mathrm{d
}{x
}}
1887 {\int _
{-
\infty }^
{\infty }s(x)
\mathrm{d
}{x
}}
1890 Math split over two lines: If a double backslash is detected outside a
1891 \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}
1892 \texttt{align
} environment:
1895 s_
{\mathrm{out
}}(x) & = s_
{\mathrm{in
}}(x') * s_
\delta (x-x') \\
1896 & =
\int s_
{\mathrm{in
}}(x')s_
\delta (x-x')
\mathrm{d
}x'
1898 Cases (“manually”, with
\texttt{matrix
} environment):
1901 \mathrm{sgn
}(x) =
\left\
{\begin{matrix
}
1906 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
1907 HTML writers with
\texttt{-
{}-math-output=MathML
}):
1910 \mathrm{sgn
}(x) =
\begin{cases
}
1916 \section{3 Tests for the LaTeX writer
%
1917 \label{tests-for-the-latex-writer
}%
1920 Test syntax elements which may cause trouble for the LaTeX writer but might
1921 not need to be tested with other writers (e.g. the HTML writer).
1924 \subsection{3.1 Custom Roles in LaTeX
%
1925 \label{custom-roles-in-latex
}%
1929 \item Role names and class arguments are converted to conform to the
1930 regular expression
\texttt{{[}a-z
{]}{[}-a-z0-
9{]}*
} (letters are downcased,
1931 accents and similar decoration is stripped, non-conforming
1932 characters are replaced by a hyphen).
1934 Class arguments may contain numbers and hyphens, which need special
1935 treatment in LaTeX command names.
1937 \DUrole{large
}{\DUrole{custom4
}{\DUrole{small-caps
}{\DUrole{custom-role
}{\DUrole{custom-role
}{Text with role “custom4”
}}}}} (but without styling by
\texttt{DUrole*
}
1940 \item With LaTeX, roles can be styled within the
document using the
\DUroletitlereference{raw
}
1943 \newcommand{\DUrolelarge}[1]{{\large #1}}
1945 \@namedef
{DUrolesmall-caps
}{\textsc}
1946 \@namedef
{DUrolecustom4
}{\textbf}
1949 \DUrole{large
}{\DUrole{custom4
}{\DUrole{small-caps
}{\DUrole{custom-role
}{\DUrole{custom-role
}{inline text
}}}}} in large, bold, small-caps.
1951 \item Custom roles can be based on standard roles:
1953 This is a
\emph{\DUrole{custom-emphasis
}{customized emphasis text role
}}
1955 This is a
\texttt{\DUrole{custom-literal
}{customized literal text role
}}
1957 This is a
\textbf{\DUrole{custom-strong
}{customized strong text role
}}
1959 This is a
\textsubscript{\DUrole{custom-subscript
}{customized subscript text role
}}
1961 This is a
\textsuperscript{\DUrole{custom-superscript
}{customized superscript text role
}}
1963 This is a
\DUroletitlereference{\DUrole{custom-title-reference
}{customized title-reference text role
}}
1967 \subsection{3.2 class handling
%
1968 \label{class-handling
}%
1971 This section tests class handling for block level elements by the LaTeX
1972 writer. See the input file
\texttt{classes
\_latex.txt
} for the raw LaTeX code used
1973 to style the examples.
1975 An “epigraph” directive is exported as “quote” wrapped in a “DUclass”
1976 environment. Here, it is styled by a “DUCLASSepigraph” environment
1977 redefining the “quote” environment as “minipage”:
1979 \newcommand*
{\DUCLASSepigraph}{%
1980 \renewenvironment{quote
}{\vspace{1em
}
1981 \footnotesize\hfill{}%
1982 \begin{minipage
}{0.4\columnwidth}}%
1983 {\end{minipage
}\vskip\baselineskip}}
1985 \begin{DUclass
}{epigraph
}
1987 Do not play this piece fast. It is never right to play
\emph{Ragtime
} fast.
1990 \raggedleft —Scott Joplin
1994 Raw latex is also used to style the following lists: “DUCLASSenumerateitems”
1995 redefines “itemize” as “enumerate”, “DUCLASSrules” draws horizontal lines
1998 \newcommand*
{\DUCLASSenumerateitems}{%
1999 \renewenvironment{itemize
}{\begin{enumerate
}}%
2003 \newenvironment{DUCLASSrules
}%
2004 {\noindent\rule[0.5ex
]{1\columnwidth}{1pt
}}%
2005 {\noindent\rule[0.5ex
]{1\columnwidth}{1pt
}}
2007 An “enumerated” bullet list:
2009 \begin{DUclass
}{enumerateitems
}
2019 A list with lines above and below:
2021 \begin{DUclass
}{rules
}
2029 A normal bullet list is kept unchanged by the above redefinitions:
2039 A container wraps several elements in a common “class wrapper”. Here, we use
2040 it to set
2 paragraphs and a list in small caps:
2042 \newcommand*
{\DUCLASSscshape}{\scshape}
2044 \begin{DUclass
}{scshape
}
2053 \item still bullet list
2057 A right-aligned line-block. Alignment handling is built into the latex
2058 writer for image, table, and line block elements.
2060 \begin{DUlineblock
}{0em
}
2062 \item[] Max Mustermann
2064 \item[] D
01234 Testdorf
2065 \item[] Tel.:
0123/
456789
2069 \subsection{3.3 More Tables
%
2070 \label{more-tables
}%
2073 A table with multi-paragraph multicolumn cells:
2075 \setlength{\DUtablewidth}{\linewidth}
2076 \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}|
}
2082 &
\multicolumn{3}{p
{0.41\DUtablewidth}|
}{%
2085 With a second paragraph
2090 \multicolumn{2}{|p
{0.31\DUtablewidth}|
}{%
2093 With a second paragraph
2106 &
\multicolumn{2}{p
{0.36\DUtablewidth}|
}{%
2107 multicolumn
3 (one line,
2108 but very very very very
2124 &
\multicolumn{3}{p
{0.38\DUtablewidth}|
}{%
2130 Tables with multi-paragraph multirow cells currently fail due to a LaTeX
2131 limitation (see
\url{https://sourceforge.net/p/docutils/bugs/
225/
}).
2133 A table with multirow header and column-widths set by LaTeX:
2135 \begin{longtable*
}[c
]{|l|l|
}
2137 \multirow{2}{*
}{\textbf{XXX
}} &
\textbf{Variable Summary
} \\
2139 &
\textbf{Description
} \\
2143 \multirow{2}{*
}{\textbf{XXX
}} &
\textbf{Variable Summary
} \\
2145 &
\textbf{Description
} \\
2148 \multicolumn{2}{c
}{\hfill ... continued on next page
} \\
2151 \multicolumn{2}{|l|
}{multicollumn cell
} \\
2155 In a table with column-widths set by LaTeX, each cell has just one line.
2156 Paragraphs are merged (a warning is given).
2158 \begin{longtable*
}[c
]{|l|l|
}
2160 11 & first paragraph
2168 % This file is used by the standalone_rst_latex test.
2171 \subsection{3.4 Option lists
%
2175 The LaTeX-
2e description environment is used for definition lists.
2176 The definition is continued on the same line as the term, this should
2177 not happen if a option-list is at the top of the definition.
2179 If the option list is not at the first element in the definition, it
2180 is contained in a quote
2183 \begin{DUoptionlist
}
2184 \item[-
{}-help
] show help
2191 \item[{In a definition list:
}] \leavevmode
2192 \begin{DUoptionlist
}
2193 \item[-
{}-help
] show help
2201 \subsection{3.5 Monospaced non-alphanumeric characters
%
2202 \label{monospaced-non-alphanumeric-characters
}%
2205 These are all ASCII characters except a-zA-Z0-
9 and space:
2207 \texttt{!!!
\textquotedbl{}\textquotedbl{}\textquotedbl{}\#\#\#\$\$\$\%\%\%\&\&\&'
{}'
{}'((()))***+++,
{},
{},-
{}-
{}-...///:::
}
2209 \texttt{;;;<
{}<
{}<===>
{}>
{}>???@@@
{[}{[}{[}\textbackslash{}\textbackslash{}\textbackslash{}{]}{]}{]}\textasciicircum{}\textasciicircum{}\textasciicircum{}\_\_\_`
{}`
{}`\
{\
{\
{|||\
}\
}\
}\textasciitilde{}\textasciitilde{}\textasciitilde{}}
2211 \texttt{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
}
2213 The two lines of non-alphanumeric characters should both have the same
2214 width as the third line.
2217 \subsection{3.6 Non-ASCII characters
%
2218 \label{non-ascii-characters
}%
2221 Punctuation and footnote symbols
2223 \setlength{\DUtablewidth}{\linewidth}
2224 \begin{longtable*
}[c
]{|p
{0.028\DUtablewidth}|p
{0.424\DUtablewidth}|
}
2241 single turned comma quotation mark
2247 single comma quotation mark
2253 low single comma quotation mark
2259 double turned comma quotation mark
2265 double comma quotation mark
2271 low double comma quotation mark
2325 left-right double arrow
2330 The
\DUroletitlereference{Latin-
1 extended
} Unicode block
2332 \setlength{\DUtablewidth}{\linewidth}
2333 \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}|
}
2590 \item The following line should not be wrapped, because it uses
2591 no-break spaces (
\textbackslash{}u00a0):
2593 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
2595 \item Line wrapping with/without breakpoints marked by soft hyphens
2596 (
\textbackslash{}u00ad):
2598 pdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-sch
2600 pdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrisch
2604 \subsection{3.7 Encoding special chars
%
2605 \label{encoding-special-chars
}%
2608 The LaTeX Info pages lists under “
2.18 Special Characters”
2611 The following characters play a special role in LaTeX and are called
2612 “special printing characters”, or simply “special characters”.
2615 \# \$ \% \&
\textasciitilde{} \_ \textasciicircum{} \textbackslash{} \
{ \
}
2619 The special chars verbatim:
2623 # $
% & ~ _ ^ \textbackslash{} \{ \}
2627 However also
\emph{square brackets
} {[}{]} need special care.
2630 Commands with optional arguments (e.g.
\texttt{\textbackslash{}item
}) check
2631 if the token right after the macro name is an opening bracket.
2632 In that case the contents between that bracket and the following
2633 closing bracket on the same grouping level are taken as the
2634 optional argument. What makes this unintuitive is the fact that
2635 the square brackets aren’t grouping characters themselves, so in
2636 your last example item
{[}{[}…
{]}{]} the optional argument consists of
2637 {[}… (without the closing bracket).
2640 Compare the items in the following lists:
2645 \item {[}bracketed
{]} item
2649 \item[{simple
}] \leavevmode
2652 \item[{{[}bracketed
{]}}] \leavevmode
2657 The OT1 font-encoding has different characters for the less-than,
2658 greater-than and bar, < | >, except for typewriter font
\DUroletitlereference{cmtt
}:
2667 \subsection{3.8 Hyperlinks and -targets
%
2668 \label{hyperlinks-and-targets
}%
2671 In LaTeX, we must set an explicit anchor (
\texttt{\textbackslash{}phantomsection
}) for a
2673 \phantomsection\label{hypertarget-in-plain-text
}hypertarget in plain text or in a figure but not in a longtable or
2676 \setlength{\DUtablewidth}{\linewidth}
2677 \begin{longtable
}[c
]{|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|p
{0.075\DUtablewidth}|
}
2678 \caption{Table with
%
2679 \label{hypertarget-in-table-title
}hypertarget in table title.
}\\
2693 \phantomsection\label{figure-label
}
2694 \noindent\makebox[\linewidth][c
]{\includegraphics{../../../docs/user/rst/images/biohazard.png
}}
2695 \caption{Figure with
%
2696 \label{hypertarget-in-figure-caption
}hypertarget in figure caption.
}
2699 \phantomsection\label{hypertarget-in-figure-legend
}hypertarget in figure legend.
2703 \includegraphics{../../../docs/user/rst/images/biohazard.png
}
2704 \phantomsection\label{image-label
}
2706 See
\hyperref[hypertarget-in-plain-text
]{hypertarget in plain text
},
2707 \hyperref[table-label
]{table label
},
\hyperref[hypertarget-in-table-title
]{hypertarget in table title
},
2708 \hyperref[figure-label
]{figure label
},
\hyperref[hypertarget-in-figure-caption
]{hypertarget in figure caption
},
2709 \hyperref[hypertarget-in-figure-legend
]{hypertarget in figure legend
}, and
2710 \hyperref[image-label
]{image label
}.
2713 \subsection{3.9 External references
%
2714 \label{external-references
}%
2717 Long URLs should be wrapped in the PDF.
2718 This can be achieved with the url command which is used by the LaTeX writer
2719 whenever the content (name) of a reference node equals the link URL.
2722 \item[{Example:
}] \leavevmode
2723 a long URL that should wrap in the output
2724 \url{http://docutils.sourceforge.net/docs/user/latex.html\#id79
}
2728 If the argument contains any “\%”, “\#”, or “
\textasciicircum{}\textasciicircum{}”, or ends with
\texttt{\textbackslash{}}, it can’t
2729 be used in the argument to another command. The argument must not contain
2732 The characters
\textasciicircum{}, \
{, \
}, and
\texttt{\textbackslash{}} are invalid in a “http:” or “ftp:” URL
2733 and not recognized as part of it:
2735 \begin{DUlineblock
}{0em
}
2736 \item[] \url{http://www.example.org
}/strange
\textasciicircum{}\textasciicircum{}name
2737 \item[] \url{http://www.example.org
}\textbackslash{}using
\textbackslash{}DOS
\textbackslash{}paths
\textbackslash{}
2738 \item[] \url{http://www.example.org/XML
}/strange\
{n\
}ame
2741 They can, however be used in paths and/or filenames.
2743 Handling by the LaTeX writer:
2746 \item \texttt{\#
},
\texttt{\textbackslash{}} and
\texttt{\%
} are escaped:
2748 \begin{DUlineblock
}{0em
}
2749 \item[] \href{http://www.w3.org/XML/Schema\#dev
}{URL with \#
}
2750 \url{http://www.w3.org/XML/Schema\#dev
}
2751 \item[] \href{http://www.w3.org/XML/Schema\%dev
}{URL with \%
}
2752 \url{http://example.org/Schema\%dev
}
2753 \item[] \href{A:DOS\
\path\\
}{file with DOS path
}\DUfootnotemark{id42
}{id41
}{9} \url{A:DOS\
\path\\
}\DUfootnotemark{id43
}{id41
}{9}
2756 \DUadmonition[note
]{
2757 \DUtitle[note
]{Note
}
2759 These URLs are typeset inside a LaTeX command without error.
2761 \begin{DUlineblock
}{0em
}
2762 \item[] \url{http://www.w3.org/XML/Schema\#dev
}
2763 \item[] \url{http://example.org/Schema\%dev
}
2764 \item[] \url{A:DOS\
\path\\
}\DUfootnotemark{id44
}{id41
}{9}
2770 \item \textasciicircum{}\textasciicircum{} LaTeX’s special syntax for characters results in “strange” replacements
2771 (both with href and url). A warning is given.
2773 \href{../strange^^name
}{file with
\textasciicircum{}\textasciicircum{}}:
2774 \url{../strange^^name
}
2776 \item Unbalanced braces, \
{ or \
}, will fail (both with href and url):
2780 `file with \
{ <../strange\
{name>`__
2781 `<../strange\
{name>`__
2785 while balanced braces are suported:
2787 \begin{DUlineblock
}{0em
}
2788 \item[] \url{../strange
{n
}ame
}
2789 \item[] \url{../st
{r
}ange
{n
}ame
}
2790 \item[] \url{../
{st
{r
}ange
{n
}ame
}}
2795 \subsection{3.10 Section titles with
\hyperref[inline-markup
]{inline markup
}%
2796 \label{section-titles-with-inline-markup
}%
2800 \subsubsection{3.10.1 \emph{emphasized
}, H
\textsubscript{2}O and $x^
2$
%
2801 \label{emphasized-h2o-and-x-
2}%
2805 \subsubsection{3.10.2 Substitutions work
%
2806 \label{substitutions-fail
}%
2810 \subsection{3.11 Deeply nested sections
%
2811 \label{deeply-nested-sections
}%
2817 \subsubsection{3.11.1 Level
3%
2824 \paragraph{3.11.1.1 level
4%
2831 \subparagraph{3.11.1.1.1 level
5%
2835 (depending on the
document class)
2838 \DUtitle[sectionVI
]{3.11.1.1.1.1 level
6%
2842 an unsupported level.
2844 % unusual combinations (currently separately tested)
2845 % .. include:: data/latex_cornercases.txt
2847 % Preface for System Messages:
2850 \section{4 Error Handling
%
2851 \label{error-handling
}%
2854 Any errors caught during processing will generate system messages.
2856 There should be five messages in the following, auto-generated
2857 section, “Docutils System Messages”:
2859 % section should be added by Docutils automatically
2862 \section[Docutils System Messages
]{\color{red
}Docutils System Messages
%
2865 \DUadmonition[system-message
]{
2866 \DUtitle[system-message
]{system-message
}
2867 \raisebox{1em
}{\hypertarget{id27
}{}}
2869 {\color{red
}ERROR/
3} in
\texttt{functional/input/data/standard.txt
}, line~
104
2872 Undefined substitution referenced:
\textquotedbl{}problematic
\textquotedbl{}.
2875 \DUadmonition[system-message
]{
2876 \DUtitle[system-message
]{system-message
}
2877 \raisebox{1em
}{\hypertarget{id45
}{}}
2879 {\color{red
}ERROR/
3} in
\texttt{functional/input/data/standard.txt
}, line~
391
2882 Unknown target name:
\textquotedbl{}5\textquotedbl{}.
2885 \DUadmonition[system-message
]{
2886 \DUtitle[system-message
]{system-message
}
2887 \raisebox{1em
}{\hypertarget{id46
}{}}
2889 {\color{red
}ERROR/
3} in
\texttt{functional/input/data/standard.txt
}, line~
400
2892 Unknown target name:
\textquotedbl{}nonexistent
\textquotedbl{}.
2895 \DUadmonition[system-message
]{
2896 \DUtitle[system-message
]{system-message
}
2897 \raisebox{1em
}{\hypertarget{id47
}{}}
2899 {\color{red
}ERROR/
3} in
\texttt{functional/input/data/standard.txt
}, line~
427
2902 Unknown target name:
\textquotedbl{}hyperlink reference without a target
\textquotedbl{}.
2905 \DUadmonition[system-message
]{
2906 \DUtitle[system-message
]{system-message
}
2907 \raisebox{1em
}{\hypertarget{id49
}{}}
2909 {\color{red
}ERROR/
3} in
\texttt{functional/input/data/standard.txt
}, line~
440
2912 Duplicate target name, cannot be used as a unique reference:
\textquotedbl{}duplicate target names
\textquotedbl{}.