|
From: <mi...@us...> - 2017-03-11 12:09:39
|
Revision: 8046
http://sourceforge.net/p/docutils/code/8046
Author: milde
Date: 2017-03-11 12:09:36 +0000 (Sat, 11 Mar 2017)
Log Message:
-----------
Cleanup and documentation update for latex writer class handling.
Replace the special casing for topic elements with the generic block-level
element wrapper.
Rework latex writer documentation.
Minor fixes to latex writers.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/user/latex.txt
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/latex2e/xelatex.tex
trunk/docutils/docutils/writers/xetex/__init__.py
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
trunk/docutils/test/functional/expected/xetex-cyrillic.tex
trunk/docutils/test/functional/input/data/custom_roles_latex.txt
trunk/docutils/test/functional/input/data/unicode.txt
trunk/docutils/test/functional/input/standalone_rst_latex.txt
trunk/docutils/test/functional/input/standalone_rst_xetex.txt
Added Paths:
-----------
trunk/docutils/test/functional/input/data/classes_latex.txt
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-03-07 13:06:08 UTC (rev 8045)
+++ trunk/docutils/HISTORY.txt 2017-03-11 12:09:36 UTC (rev 8046)
@@ -71,7 +71,8 @@
* docutils/writers/latex2e/__init__.py
- Handle class arguments for block-level elements by wrapping them
- in a "DUclass" environment.
+ in a "DUclass" environment. This replaces the special handling for
+ "epigraph" and "topic" elements.
* tools/rst2html4.py: New front-end.
Modified: trunk/docutils/docs/user/latex.txt
===================================================================
--- trunk/docutils/docs/user/latex.txt 2017-03-07 13:06:08 UTC (rev 8045)
+++ trunk/docutils/docs/user/latex.txt 2017-03-11 12:09:36 UTC (rev 8046)
@@ -7,18 +7,21 @@
:Revision: $Revision$
:Date: $Date$
:Copyright: This document has been placed in the public domain.
+:Abstract: This document covers topics specific to Docutils' LaTeX_ export.
.. contents::
.. sectnum::
-Introduction
-============
-This document covers topics specific to Docutils' LaTeX__ export. For
-an introduction to LaTeX see, e.g., `LaTeX2e for authors`_. There exists
-a wide selecton of `LaTeX Documentation on the net`_ and
-`books on LaTeX and related topics`_.
+LaTeX
+=====
+LaTeX__, is a document preparation system for high-quality typesetting. It
+is most often used for medium-to-large technical or scientific documents but
+it can be used for almost any form of publishing. There exists a wide
+selecton of `LaTeX Documentation on the net`_ and `books on LaTeX and
+related topics`_. For an introduction to LaTeX see, e.g., `LaTeX2e for
+authors`_.
__ http://www.latex-project.org/
.. _LaTeX2e for authors:
@@ -28,28 +31,27 @@
.. _books on LaTeX and related topics:
http://www.latex-project.org/guides/books.html
-LaTeX
-=====
-Unlike HTML with CSS, LaTeX uses one common language for markup and
-style definitions. Separation of content and style is realized by
-collecting style definitions in the documentclass_, `LaTeX packages`_,
-or the document preamble.
+.. _LaTeX packages:
-LaTeX packages
---------------
+LaTeX classes and packages
+--------------------------
-LaTeX packages (similar to Python modules or C libraries) provide
-means to extend or modify the LaTeX language by redefining macros or
-providing new ones. There is a *huge* selection of packages (standard
-as well as user contributed) coming with your TeX distribution or
-available at CTAN_.
+Unlike HTML with CSS, LaTeX uses one common language for markup and style
+definitions. Separation of content and style is realized by collecting style
+definitions in LaTeX classes and packages, or the
+`document preamble <LaTeX preamble_>`_.
+LaTeX document classes and packages (similar to Python modules or C
+libraries) provide means to extend or modify the LaTeX language by
+redefining macros or providing new ones.
+
+Using the `document class`_ and `style sheet`_ configuration options, you
+can select from a *huge* selection of classes and packages (standard as well
+as user contributed) coming with your TeX distribution or available at
+CTAN_ as well as custom style sheets.
+
.. _CTAN: http://www.ctan.org
-.. _stylesheet:
- config.html#stylesheet-latex2e-writer
-.. _TeX input path:
- http://www.tex.ac.uk/cgi-bin/texfaq2html?label=what-TDS
Docutils specific LaTeX macros
@@ -74,9 +76,6 @@
See the test output standalone_rst_latex.tex_ for an example of the fallback
definitions and their use in the document.
-.. _standalone_rst_latex.tex:
- ../../test/functional/expected/standalone_rst_latex.tex
-
.. [#] DU for Documentation Utilities = Docutils
@@ -125,22 +124,13 @@
_`pdflatex`
Generates a PDF document directly from the LaTeX file.
-_`latex + dvipdfmx`
- Use ``latex`` to generate a DVI file and ``dvipdfmx`` to produce a PDF
- file. If you take this approach, add ``dvipdfmx`` to the
- _documentoptions.
-
-_`latex` + dvips + ps2pdf
- Produce a DVI file with ``latex``, postscript with ``dvips`` and PDF with
- ``ps2pdf``.
-
_`xelatex` or _`lualatex`
The `XeTeX`_ and LuaTeX_ engines work with input files in UTF-8 encoding
and system fonts. Export your document with the `xetex` writer
(``rst2xetex``), if you want to go this route.
-You need to call latex (or pdflatex/xelatex/lualatex) twice (or even three times) to
-get internal references correct.
+You may need to call latex two or three times to get internal references
+correct.
.. _documentoptions: config.html#documentoptions
.. _xetex: http://tug.org/xetex/
@@ -159,16 +149,8 @@
Configuration
=============
-The LaTeX code generation can be configured via
+.. contents:: :local:
-* configuration `options/settings`_ of the Docutils writer,
-* `LaTeX packages`_,
-* custom `LaTeX code`_ in
- + `style sheets`_,
- + the `LaTeX preamble`_,
- + the document body (`raw LaTeX`_), or
- + custom templates_.
-
.. _option:
Options/Settings
@@ -176,11 +158,13 @@
Options can be specified as
-* command-line options (run ``rst2latex.py --help`` to get a list of
- available options), or
+* command-line options, or
-* configuration settings (see `Docutils Configuration`_ for details).
+* configuration settings.
+Run ``rst2latex.py --help`` to get a list of available options;
+see `Docutils Configuration`_ for details.
+
.. _Docutils Configuration:
config.html
@@ -187,81 +171,65 @@
Classes
-------
-The `classes attribute`_ is one of the common attributes, shared by all
+The `"classes" attribute`_ is one of the common attributes, shared by all
Docutils elements.
-
- The purpose of the attribute is to indicate an “is-a” variant
- relationship, to allow an extensible way of defining sub-classes of
- existing elements. It can be used to carry context forward between a
- Docutils Reader and Writer, when a custom structure is reduced to a
- standardized document tree.
-
In HTML, the common use is to provide selection criteria for style rules in
CSS stylesheets. As there is no comparable framework for LaTeX, Docutils
mimics some of this behaviour via `Docutils specific LaTeX macros`_.
-* Role names and class arguments are converted to conform to the regular
- expression ``[a-z][-a-z0-9]*`` (lowercase letters, digits and hyphen, see
- `class directive`_).
+*Inline elements*
+ are handled via the ``\DUrole{}`` macro, that calls the optional styling
+ command ``\DUrole«classargument»`` with one argument (the role content).
+ See `custom interpreted text roles`_.
-* Class arguments may contain numbers and hyphens, which need special
- treatment in LaTeX command names. (The commands ``\begincsname`` and
- ``\endcsname`` or the special command ``\@namedef`` can
- help with the definition of corresponding macros or environments.)
+*Block level elements*
+ are wrapped in "class environments":
+ ``\begin{DUclass}`` calls the optional styling command
+ ``\DUCLASSe«classargument»{}``, ``\end{DUclass}`` tries
+ ``\endDUCLASS«classargument»``.
-* Elements can have multiple class arguments. In contrast to HTML/CSS, the
- order of the class arguments cannot be ignored in LaTeX
+Customization is done by defining matching macros or environments.
-For inline elements, classes are handled via the ``\DUrole{}`` macro,
-see `custom interpreted text roles`_.
+Example 1:
+ Use small caps font inside elements with class value "custom".
-Block level elements are wrapped in "class environments".
+ *Inline elements*
+ The LaTeX function ``\textsc`` sets the argument in small caps::
-* ``\begin{DUclass}{«classargument»}``
- calls the macro named ``\DUCLASSe«classargument»{}`` if it is defined and
- silently ignores this class argument if a corresponding macro is not
- defined.
+ \newcommand{\DUrolesmallcaps}[1]{\textsc{#1}}
-* ``\end{DUclass}{«classargument»}``
- tries ``\endDUCLASS«classargument»``
+ *Block-level elements*
+ The LaTeX directive (macro without argument) ``\scshape`` switches to
+ the small caps font. Its effect is confined to the wrapper ``DUclass``
+ environment::
-Customization is done by defining matching macros or environments.
+ \newcommand*{\DUCLASScustom}{\scshape}
-Examples:
-
-* Use small caps font inside elements with class value "custom"::
-
- \newcommand*{\DUCLASScustom}{\scshape}
-
- The LaTeX directive (macro without argument) ``\scshape`` switches to the
- small caps font. Its effect is confined to the wrapper ``DUclass``
- environment.
-
-* Turn bullet lists with class value "enumerateitems" into enumerated
+Example 2:
+ It is even possible to locally redefine other LaTeX macros, e.g. to
+ turn bullet lists with class value "enumerateitems" into enumerated
lists::
- \newcommand*{\DUCLASSenumerateitems}{%
- \renewenvironment{itemize}{\begin{enumerate}}%
- {\end{enumerate}}%
- }
+ \newcommand*{\DUCLASSenumerateitems}{%
+ \renewenvironment{itemize}{\begin{enumerate}}%
+ {\end{enumerate}}%
+ }
- The matching LaTeX macro can also locally redefine other LaTeX macros.
-* Draw a line below elements with class value "rulebelow"::
+Class arguments may contain numbers and hyphens, which need special
+treatment in LaTeX command names (see `class directive`_). The commands
+``\begincsname`` and ``\endcsname`` or the special command ``\@namedef`` can
+help with the definition of corresponding macros or environments.
- \newenvironment{DUCLASSrulebelow}%
- {} % nothing to do at start of element
- {\noindent\rule[0.5ex]{1\columnwidth}{1pt}}
+* Elements can have multiple class arguments. In contrast to HTML/CSS, the
+ order of the class arguments cannot be ignored in LaTeX
- The new LaTeX environment executes the rule-drawing macro when leaving the
- wrapper ``DUclass`` environment.
-
For "historical reasons", class handling differs for some elements and class
values:
* The special macros ``\DUadmonition``, ``\DUtitle``, and ``\DUtopic`` are
- handed a comma separated list of class values as optional argument. See
- the sections on admonitions_, titles_, and the `topic element`_ for
+ written with a comma separated list of class values as optional argument.
+ See the sections on admonitions_, titles_, and the `topic element`_ for
customization examples.
* Class argument values starting with ``align-`` are transformed to "align"
@@ -270,10 +238,9 @@
* The table element recognizes some special class values. See section table_.
+.. _"classes" attribute: ../ref/doctree.html#classes
-.. _classes attribute: ../ref/doctree.html#classes
-
LaTeX code
----------
@@ -280,6 +247,21 @@
Custom LaTeX code can be placed in `style sheets`_, the
`LaTeX preamble`_, the document body (`raw LaTeX`_), or custom templates_.
+The functional tests that come with Docutils, can serve as example.
+
+input:
+ standalone_rst_latex.txt_ (includes files from `tests/functional/input/data`_)
+expected output:
+ standalone_rst_latex.tex_
+
+.. _standalone_rst_latex.txt:
+ https://sf.net/p/docutils/code/HEAD/tree/trunk/docutils/test/functional/input/standalone_rst_latex.txt
+.. _tests/functional/input/data:
+ https://sf.net/p/docutils/code/HEAD/tree/trunk/docutils/test/functional/input/data
+.. _standalone_rst_latex.tex:
+ https://sf.net/p/docutils/code/HEAD/tree/trunk/docutils/test/functional/expected/standalone_rst_latex.tex?format=raw
+
+
.. _style sheet:
.. _custom style sheets:
@@ -295,7 +277,7 @@
stylesheet_
It is possible to specify multiple style sheets and mix `LaTeX
- packages`_ with `custom style sheets`_.
+ packages`_ with custom style sheets.
You cannot specify package options with the stylesheet_ setting. If
you need to pass options to the package, use the ``\usepackage``
@@ -326,6 +308,8 @@
.. _clsguide:
http://mirror.ctan.org/macros/latex/doc/clsguide.pdf
+.. _stylesheet:
+ config.html#stylesheet-latex2e-writer
.. _embed-stylesheet:
config.html#embed-stylesheet-latex2e-writer
.. _repository of user-contributed style sheets:
@@ -401,7 +385,8 @@
\[x^3 + 3x^2a + 3xa^2 + a^3,\]
- (Drawback: the formula will be invisible in other output formats.)
+ (Drawback: the formula will be invisible in other output formats. Better
+ use the `math directive`_)
Most LaTeX code examples also work as raw LaTeX inside the document.
An exception are commands that need to be given in the document
@@ -423,6 +408,8 @@
.. _raw directive:
../ref/rst/directives.html#raw
+.. _math directive:
+ ../ref/rst/directives.html#math
@@ -492,12 +479,13 @@
Commands:
``\DUrole``: dispatcher command
- ``\DUrole«classargument»``: optional styling command
+ ``\DUrole«classargument»``: optional styling command with 1 argument (the
+ role content).
Default:
- The definition of ``\DUrole{«classargument»}{}`` calls the macro named
- ``\DUrole«classargument»{}`` if it is defined and silently ignores
- this class argument if a corresponding macro is not defined.
+ The default definition of ``\DUrole{«classargument»}{}`` calls the macro
+ named ``\DUrole«classargument»{}`` if it is defined and silently ignores
+ this class argument if not.
Example 1:
Typeset text in small caps::
@@ -1289,6 +1277,27 @@
http://mirror.ctan.org/macros/latex/contrib/listings/listings.pdf
+lists
+-----
+
+Remove extra vertical whitespace between items of bullet lists and
+enumerated lists.
+
+Example:
+ Pass the class argument "compact" to the list::
+
+ .. class:: compact
+
+ * first item
+ * second item
+
+ The following lines for the `LaTeX preamble`_ use the enumitem_ package to
+ remove spacing from all lists with class argument "compact"::
+
+ \usepackage{enumitem}
+ \newcommand*{\DUCLASScompact}{\setlist{noitemsep}}
+
+
list of figures/tables
----------------------
@@ -1481,7 +1490,7 @@
Indent the first line in a paragraph unless it is the first line of a
chapter, section, subsection, or subsubsection.
-Example:
+Example 1:
To set paragraph indentation to zero but add a vertical space between
load the `parskip` package with the command line argument::
@@ -1491,7 +1500,18 @@
\usepackage{parskip}
+Example 2:
+ To suppress the indentation of a specific paragraph, you may give it the
+ class "noindent" with, e.g. ::
+ .. class:: noindent
+
+ This paragraph should not be indented.
+
+ and define the `custom role`_ command::
+
+ \newcommand{\DUrolenoindent}[1]{\noindent #1}
+
rubric
------
@@ -1592,35 +1612,17 @@
topic element
-------------
-A topic_ is like a block quote with a title, or a self-contained section with
-no subsections.
+A topic_ is like a block quote with a title, or a self-contained section
+with no subsections. Topics and rubrics can be used at places where a
+`section title`_ is not allowed (e.g. inside a directive).
-Topics and rubrics can be used at places where a `section title`_ is not
-allowed (e.g. inside a directive).
+Example:
+ Use a standard paragraph for a topic::
-Command:
- ``DUtopic``
-
-Default:
- "quote" environment
-
-Example 1:
- If you generally prefer a "normal" section over a block quote, define::
-
- \newcommand{\DUtopic}[2][class-arg]{%
- \ifcsname DUtopic#1\endcsname%
- \csname DUtopic#1\endcsname{#2}%
- \else
- #2
- \fi
+ \newcommand{\DUCLASStopic}{%
+ \renewenvironment{quote}{}{}%
}
-Example 2:
- If you want a "normal" section for topics with class argument "noquote",
- define::
-
- \newcommand{\DUtopicnoquote}[1]{#1}
-
.. _topic: ../ref/rst/directives.html#topic
.. _section title: ../ref/rst/restructuredtext.html#sections
@@ -1860,14 +1862,12 @@
a) compile with pdflatex_,
- b) compile with `latex + dvipdfmx`_,
+ b) use the package breakurl_,
- c) use the package breakurl_,
+ c) (for printout) `disable hyperlinks`_ using the package "nohyperref".
- d) (for printout) `disable hyperlinks`_ using the package "nohyperref".
+See also the `Link text doesn’t break at end line`_ LaTeX FAQ entry.
-See also the `Link text doesn’t break at end line`_ FAQ entry.
-
.. _breakurl:
http://mirror.ctan.org/help/Catalogue/entries/breakurl.html
@@ -1893,24 +1893,9 @@
"latin1"). Newer versions of hyperref default to "unicode=true" if the
document language is "russian".
-However, this setting leads to "strange" characters in the bookmarks
-if used with xelatex_ in hyperref versions before v6.79g (2009/11/20).
-(cf `bugreport 3100778`__).
+.. _hyperref_option: config.html#stylesheet-latex2e-writer
-If updating the hyperref package is not an option, the workaround is
-to set ::
- --hyperref-option="unicode=false"
-
-or (in the config file)::
-
- [xetex writer]
-
- hyperref-option: unicode=false
-
-__ http://sourceforge.net/tracker/?func=detail&aid=3100778&group_id=38414&atid=422030
-.. _hyperref_option: config.html#stylesheet-latex2e-writer
-
image inclusion
```````````````
@@ -1917,10 +1902,10 @@
Images__ are included in LaTeX with the help of the `graphicx` package. The
supported file formats depend on the used driver:
+* pdflatex_ and xelatex_ work with PNG, JPG, or PDF, but **not EPS**.
* Standard latex_ can include **only EPS** graphics, no other format.
-* `latex + dvipdfmx`_ works with EPS and JPG (add 'dvipdfmx' to the
+* latex + dvipdfmx works with EPS and JPG (add 'dvipdfmx' to the
documentoptions_ and 'bmpsize' to the stylesheet_ setting).
-* pdflatex_ and xelatex_ work with PNG, JPG, or PDF, but **not EPS**.
If PDF-image inclusion in PDF files fails, specifying
``--graphicx-option=pdftex`` or ``--graphicx-option=auto`` might help.
@@ -2038,7 +2023,7 @@
.. _Docutils TODO list: ../dev/todo.html#latex-writer
.. _bugs: ../../BUGS.html
.. _SourceForge Bug Tracker:
- http://sourceforge.net/tracker/?group_id=38414&atid=422030
+ http://sf.net/tracker/?group_id=38414&atid=422030
Footnotes and citations
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2017-03-07 13:06:08 UTC (rev 8045)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2017-03-11 12:09:36 UTC (rev 8046)
@@ -476,7 +476,7 @@
PreambleCmds.abstract = r"""
% abstract title
-\providecommand*{\DUtitleabstract}[1]{\centering\textbf{#1}}"""
+\providecommand*{\DUtitleabstract}[1]{\centerline{\textbf{#1}}}"""
PreambleCmds.admonition = r"""
% admonition (specially marked topic)
@@ -504,7 +504,9 @@
PreambleCmds.dedication = r"""
% dedication topic
-\providecommand{\DUtopicdedication}[1]{\begin{center}#1\end{center}}"""
+\providecommand*{\DUCLASSdedication}{%
+ \renewenvironment{quote}{\begin{center}}{\end{center}}%
+}"""
PreambleCmds.duclass = r"""
% class handling for environments (block-level elements)
@@ -520,7 +522,6 @@
PreambleCmds.error = r"""
% error admonition title
\providecommand*{\DUtitleerror}[1]{\DUtitle{\color{red}#1}}"""
-# PreambleCmds.errortitle._depends = 'color'
PreambleCmds.fieldlist = r"""
% fieldlist environment
@@ -674,16 +675,6 @@
\fi
}"""
-PreambleCmds.topic = r"""
-% topic (quote with heading)
-\providecommand{\DUtopic}[2][class-arg]{%
- \ifcsname DUtopic#1\endcsname%
- \csname DUtopic#1\endcsname{#2}%
- \else
- \begin{quote}#2\end{quote}
- \fi
-}"""
-
PreambleCmds.transition = r"""
% transition (break, fancybreak, anonymous section)
\providecommand*{\DUtransition}{%
@@ -2441,8 +2432,8 @@
if isinstance(node.parent, nodes.line_block):
self.out.append('\\item[]\n'
'\\begin{DUlineblock}{\\DUlineblockindent}\n')
+ # nested line-blocks cannot be given class arguments
else:
- # nested line-blocks cannot be given class arguments
self.duclass_open(node)
self.out.append('\\begin{DUlineblock}{0em}\n')
self.insert_align_declaration(node)
@@ -3096,7 +3087,6 @@
depth = node.get('depth', 0)
if 'local' in node['classes']:
self.minitoc(node, title, depth)
- self.context.append('')
return
if depth:
self.out.append('\\setcounter{tocdepth}{%d}\n' % depth)
@@ -3108,29 +3098,31 @@
else: # Docutils generated contents list
# set flag for visit_bullet_list() and visit_title()
self.is_toc_list = True
- self.context.append('')
elif ('abstract' in node['classes'] and
self.settings.use_latex_abstract):
self.push_output_collector(self.abstract)
self.out.append('\\begin{abstract}')
- self.context.append('\\end{abstract}\n')
if isinstance(node.next_node(), nodes.title):
node.pop(0) # LaTeX provides its own title
else:
- self.fallbacks['topic'] = PreambleCmds.topic
# special topics:
if 'abstract' in node['classes']:
self.fallbacks['abstract'] = PreambleCmds.abstract
self.push_output_collector(self.abstract)
- if 'dedication' in node['classes']:
+ elif 'dedication' in node['classes']:
self.fallbacks['dedication'] = PreambleCmds.dedication
self.push_output_collector(self.dedication)
- self.out.append('\n\\DUtopic[%s]{\n' % ','.join(node['classes']))
- self.context.append('}\n')
+ else:
+ node['classes'].insert(0, 'topic')
+ self.visit_block_quote(node)
def depart_topic(self, node):
- self.out.append(self.context.pop())
self.is_toc_list = False
+ if ('abstract' in node['classes']
+ and self.settings.use_latex_abstract):
+ self.out.append('\\end{abstract}\n')
+ elif not 'contents' in node['classes']:
+ self.depart_block_quote(node)
if ('abstract' in node['classes'] or
'dedication' in node['classes']):
self.pop_output_collector()
Modified: trunk/docutils/docutils/writers/latex2e/xelatex.tex
===================================================================
--- trunk/docutils/docutils/writers/latex2e/xelatex.tex 2017-03-07 13:06:08 UTC (rev 8045)
+++ trunk/docutils/docutils/writers/latex2e/xelatex.tex 2017-03-11 12:09:36 UTC (rev 8046)
@@ -4,8 +4,8 @@
% \defaultfontfeatures{Scale=MatchLowercase}
% straight double quotes (defined T1 but missing in TU):
\ifdefined \UnicodeEncodingName
- \ProvideTextCommand{\textquotedbl}{\UnicodeEncodingName}{%
- {\addfontfeatures{Ligatures=ResetAll}\char"0022}}
+ \DeclareTextCommand{\textquotedbl}{\UnicodeEncodingName}{%
+ {\addfontfeatures{RawFeature=-tlig,Mapping=}\char34}}%
\fi
$requirements
%%% Custom LaTeX preamble
Modified: trunk/docutils/docutils/writers/xetex/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/xetex/__init__.py 2017-03-07 13:06:08 UTC (rev 8045)
+++ trunk/docutils/docutils/writers/xetex/__init__.py 2017-03-11 12:09:36 UTC (rev 8046)
@@ -99,6 +99,11 @@
for key in ('af', # 'afrikaans',
'de-AT', # 'naustrian',
'de-AT-1901', # 'austrian',
+ # TODO: use variant=... for English variants
+ 'en-CA', # 'canadian',
+ 'en-GB', # 'british',
+ 'en-NZ', # 'newzealand',
+ 'en-US', # 'american',
'fr-CA', # 'canadien',
'grc-ibycus', # 'ibycus', (Greek Ibycus encoding)
'sr-Latn', # 'serbian script=latin'
@@ -110,7 +115,7 @@
self.reporter = reporter
self.language = self.language_name(language_code)
self.otherlanguages = {}
- self.warn_msg = 'Language "%s" not supported by XeTeX (polyglossia).'
+ self.warn_msg = 'Language "%s" not supported by Polyglossia.'
self.quote_index = 0
self.quotes = ('"', '"')
# language dependent configuration:
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2017-03-07 13:06:08 UTC (rev 8045)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2017-03-11 12:09:36 UTC (rev 8046)
@@ -52,7 +52,7 @@
}
% abstract title
-\providecommand*{\DUtitleabstract}[1]{\centering\textbf{#1}}
+\providecommand*{\DUtitleabstract}[1]{\centerline{\textbf{#1}}}
% admonition (specially marked topic)
\providecommand{\DUadmonition}[2][class-arg]{%
@@ -67,7 +67,9 @@
}
% dedication topic
-\providecommand{\DUtopicdedication}[1]{\begin{center}#1\end{center}}
+\providecommand*{\DUCLASSdedication}{%
+ \renewenvironment{quote}{\begin{center}}{\end{center}}%
+}
% docinfo (width of docinfo table)
\DUprovidelength{\DUdocinfowidth}{0.9\linewidth}
@@ -172,15 +174,6 @@
% titlereference role
\providecommand*{\DUroletitlereference}[1]{\textsl{#1}}
-% topic (quote with heading)
-\providecommand{\DUtopic}[2][class-arg]{%
- \ifcsname DUtopic#1\endcsname%
- \csname DUtopic#1\endcsname{#2}%
- \else
- \begin{quote}#2\end{quote}
- \fi
-}
-
% transition (break, fancybreak, anonymous section)
\providecommand*{\DUtransition}{%
\hspace*{\fill}\hrulefill\hspace*{\fill}
@@ -261,19 +254,25 @@
\end{tabularx}
\end{center}
-\DUtopic[dedication]{
+\begin{DUclass}{dedication}
+\begin{quote}
\DUtitle[dedication]{Dedication}
For Docutils users \& co-developers.
-}
-\DUtopic[abstract]{
+\end{quote}
+\end{DUclass}
+
+\begin{DUclass}{abstract}
+\begin{quote}
\DUtitle[abstract]{Abstract}
This is a test document, containing at least one example of each
reStructuredText construct.
-}
+\end{quote}
+\end{DUclass}
+
% This is a comment. Note how any initial comments are moved by
% transforms to after the document title, subtitle, and docinfo.
@@ -1252,12 +1251,15 @@
A \emph{topic} is like a block quote with a title, or a self-contained section
with no subsections.
-\DUtopic[]{
-\DUtitle[title]{Topic Title}
+\begin{DUclass}{topic}
+\begin{quote}
+\DUtitle[topic]{Topic Title}
This is a topic.
-}
+\end{quote}
+\end{DUclass}
+
A \emph{rubric} is like an informal heading that doesn’t correspond to the
document’s structure. It is typically highlighted in red (hence the name).
@@ -1855,7 +1857,8 @@
Class arguments may contain numbers and hyphens, which need special
treatment in LaTeX command names.
-\DUrole{large}{\DUrole{custom4}{\DUrole{small-caps}{\DUrole{custom-role}{\DUrole{custom-role}{Interpreted Text}}}}}
+\DUrole{large}{\DUrole{custom4}{\DUrole{small-caps}{\DUrole{custom-role}{\DUrole{custom-role}{Text with role “custom4”}}}}} (but without styling by \texttt{DUrole*}
+macros).
\item With LaTeX, roles can be styled within the document using the \DUroletitlereference{raw}
directive.
@@ -1866,7 +1869,7 @@
\@namedef{DUrolecustom4}{\textbf}
\makeatother
-\DUrole{large}{\DUrole{custom4}{\DUrole{small-caps}{\DUrole{custom-role}{\DUrole{custom-role}{Interpreted Text}}}}} in large, bold, small-caps.
+\DUrole{large}{\DUrole{custom4}{\DUrole{small-caps}{\DUrole{custom-role}{\DUrole{custom-role}{inline text}}}}} in large, bold, small-caps.
\item Custom roles can be based on standard roles:
@@ -1885,7 +1888,119 @@
\end{itemize}
-\subsection{3.2~~~More Tables%
+\subsection{3.2~~~class handling%
+ \label{class-handling}%
+}
+
+This section tests class handling for block level elements by the LaTeX
+writer. See the input file \texttt{classes\_latex.txt} for the raw LaTeX code used
+to style the examples.
+
+An “epigraph” directive is exported as “quote” wrapped in a “DUclass”
+environment. Here, it is styled by a “DUCLASSepigraph” environment
+redefining the “quote” environment as “minipage”:
+
+\newcommand*{\DUCLASSepigraph}{%
+ \renewenvironment{quote}{\vspace{1em}
+ \footnotesize\hfill{}%
+ \begin{minipage}{0.4\columnwidth}}%
+ {\end{minipage}\vskip\baselineskip}}
+
+\begin{DUclass}{epigraph}
+\begin{quote}
+
+Do not play this piece fast. It is never right to play \emph{Ragtime} fast.
+\nopagebreak
+
+\raggedleft —Scott Joplin
+
+\end{quote}
+\end{DUclass}
+
+Raw latex is also used to style the following lists: “DUCLASSenumerateitems”
+redefines “itemize” as “enumerate”, “DUCLASSrules” draws horizontal lines
+above and below.
+
+\newcommand*{\DUCLASSenumerateitems}{%
+ \renewenvironment{itemize}{\begin{enumerate}}%
+ {\end{enumerate}}%
+}
+
+\newenvironment{DUCLASSrules}%
+ {\noindent\rule[0.5ex]{1\columnwidth}{1pt}}%
+ {\noindent\rule[0.5ex]{1\columnwidth}{1pt}}
+
+An “enumerated” bullet list:
+
+\begin{DUclass}{enumerateitems}
+\begin{itemize}
+
+\item item
+
+\item next item
+
+\item third item
+
+\end{itemize}
+\end{DUclass}
+
+A list with lines above and below:
+
+\begin{DUclass}{rules}
+\begin{itemize}
+
+\item item
+
+\item next item
+
+\end{itemize}
+\end{DUclass}
+
+A normal bullet list is kept unchanged by the above redefinitions:
+
+\begin{itemize}
+
+\item item
+
+\item next item
+
+\item third item
+
+\end{itemize}
+
+A container wraps several elements in a common “class wrapper”. Here, we use
+it to set 2 paragraphs and a list in small caps:
+
+\newcommand*{\DUCLASSscshape}{\scshape}
+
+\begin{DUclass}{scshape}
+
+paragraph 1
+
+paragraph 2
+
+\begin{itemize}
+
+\item bullet list
+
+\item still bullet list
+
+\end{itemize}
+\end{DUclass}
+
+A right-aligned line-block. Alignment handling is built into the latex
+writer for image, table, and line block elements.
+
+\begin{DUlineblock}{0em}
+\raggedleft
+\item[] Max Mustermann
+\item[] Waldstr. 22
+\item[] D 01234 Testdorf
+\item[] Tel.: 0123/456789
+\end{DUlineblock}
+
+
+\subsection{3.3~~~More Tables%
\label{more-tables}%
}
@@ -1987,7 +2102,7 @@
% This file is used by the standalone_rst_latex test.
-\subsection{3.3~~~Option lists%
+\subsection{3.4~~~Option lists%
\label{id23}%
}
@@ -2023,7 +2138,7 @@
\end{description}
-\subsection{3.4~~~Monospaced non-alphanumeric characters%
+\subsection{3.5~~~Monospaced non-alphanumeric characters%
\label{monospaced-non-alphanumeric-characters}%
}
@@ -2039,7 +2154,7 @@
width as the third line.
-\subsection{3.5~~~Non-ASCII characters%
+\subsection{3.6~~~Non-ASCII characters%
\label{non-ascii-characters}%
}
@@ -2425,36 +2540,10 @@
pdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrisch
-\item The currency sign (\textbackslash{}u00a4) is not supported by all fonts
-(some have an Euro sign at its place). You might see an error
-like:
-
-\begin{quote}
-\begin{alltt}
-! Package textcomp Error: Symbol \textbackslash{}textcurrency not provided by
-(textcomp) font family ptm in TS1 encoding.
-(textcomp) Default family used instead.
-\end{alltt}
-\end{quote}
-
-(which in case of font family ptm is a false positive). Add either
-
-\begin{DUfieldlist}
-\item[{warn:}]
-turn the error in a warning, use the default symbol (bitmap), or
-
-\item[{force,almostfull:}]
-use the symbol provided by the font at the users
-risk,
-
-\end{DUfieldlist}
-
-to the document options or use a different font package.
-
\end{itemize}
-\subsection{3.6~~~Encoding special chars%
+\subsection{3.7~~~Encoding special chars%
\label{encoding-special-chars}%
}
@@ -2525,7 +2614,7 @@
\end{quote}
-\subsection{3.7~~~Hyperlinks and -targets%
+\subsection{3.8~~~Hyperlinks and -targets%
\label{hyperlinks-and-targets}%
}
@@ -2571,7 +2660,7 @@
\hyperref[image-label]{image label}.
-\subsection{3.8~~~External references%
+\subsection{3.9~~~External references%
\label{external-references}%
}
@@ -2657,22 +2746,22 @@
\end{itemize}
-\subsection{3.9~~~Section titles with \hyperref[inline-markup]{inline markup}%
+\subsection{3.10~~~Section titles with \hyperref[inline-markup]{inline markup}%
\label{section-titles-with-inline-markup}%
}
-\subsubsection{3.9.1~~~\emph{emphasized}, H\textsubscript{2}O and $x^2$%
+\subsubsection{3.10.1~~~\emph{emphasized}, H\textsubscript{2}O and $x^2$%
\label{emphasized-h2o-and-x-2}%
}
-\subsubsection{3.9.2~~~Substitutions work%
+\subsubsection{3.10.2~~~Substitutions work%
\label{substitutions-fail}%
}
-\subsection{3.10~~~Deeply nested sections%
+\subsection{3.11~~~Deeply nested sections%
\label{deeply-nested-sections}%
}
@@ -2679,7 +2768,7 @@
In LaTeX and HTML,
-\subsubsection{3.10.1~~~Level 3%
+\subsubsection{3.11.1~~~Level 3%
\label{level-3}%
}
@@ -2686,7 +2775,7 @@
nested sections
-\paragraph{3.10.1.1~~~level 4%
+\paragraph{3.11.1.1~~~level 4%
\label{level-4}%
}
@@ -2693,7 +2782,7 @@
reach at some level
-\subparagraph{3.10.1.1.1~~~level 5%
+\subparagraph{3.11.1.1.1~~~level 5%
\label{level-5}%
}
@@ -2700,7 +2789,7 @@
(depending on the document class)
-\DUtitle[sectionVI]{3.10.1.1.1.1~~~level 6%
+\DUtitle[sectionVI]{3.11.1.1.1.1~~~level 6%
\label{level-6}%
}
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2017-03-07 13:06:08 UTC (rev 8045)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2017-03-11 12:09:36 UTC (rev 8046)
@@ -5,14 +5,14 @@
% \defaultfontfeatures{Scale=MatchLowercase}
% straight double quotes (defined T1 but missing in TU):
\ifdefined \UnicodeEncodingName
- \ProvideTextCommand{\textquotedbl}{\UnicodeEncodingName}{%
- {\addfontfeatures{Ligatures=ResetAll}\char"0022}}
+ \DeclareTextCommand{\textquotedbl}{\UnicodeEncodingName}{%
+ {\addfontfeatures{RawFeature=-tlig,Mapping=}\char34}}%
\fi
\usepackage{ifthen}
\usepackage{amsmath}
\usepackage{polyglossia}
\setdefaultlanguage{english}
-\setotherlanguages{british,french,german}
+\setotherlanguages{english,french,german}
\usepackage{color}
\usepackage{float} % float configuration
\floatplacement{figure}{H} % place figures here definitely
@@ -51,7 +51,7 @@
}
% abstract title
-\providecommand*{\DUtitleabstract}[1]{\centering\textbf{#1}}
+\providecommand*{\DUtitleabstract}[1]{\centerline{\textbf{#1}}}
% admonition (specially marked topic)
\providecommand{\DUadmonition}[2][class-arg]{%
@@ -66,7 +66,9 @@
}
% dedication topic
-\providecommand{\DUtopicdedication}[1]{\begin{center}#1\end{center}}
+\providecommand*{\DUCLASSdedication}{%
+ \renewenvironment{quote}{\begin{center}}{\end{center}}%
+}
% docinfo (width of docinfo table)
\DUprovidelength{\DUdocinfowidth}{0.9\linewidth}
@@ -174,15 +176,6 @@
% titlereference role
\providecommand*{\DUroletitlereference}[1]{\textsl{#1}}
-% topic (quote with heading)
-\providecommand{\DUtopic}[2][class-arg]{%
- \ifcsname DUtopic#1\endcsname%
- \csname DUtopic#1\endcsname{#2}%
- \else
- \begin{quote}#2\end{quote}
- \fi
-}
-
% transition (break, fancybreak, anonymous section)
\providecommand*{\DUtransition}{%
\hspace*{\fill}\hrulefill\hspace*{\fill}
@@ -263,19 +256,25 @@
\end{tabularx}
\end{center}
-\DUtopic[dedication]{
+\begin{DUclass}{dedication}
+\begin{quote}
\DUtitle[dedication]{Dedication}
For Docutils users \& co-developers.
-}
-\DUtopic[abstract]{
+\end{quote}
+\end{DUclass}
+
+\begin{DUclass}{abstract}
+\begin{quote}
\DUtitle[abstract]{Abstract}
This is a test document, containing at least one example of each
reStructuredText construct.
-}
+\end{quote}
+\end{DUclass}
+
% This is a comment. Note how any initial comments are moved by
% transforms to after the document title, subtitle, and docinfo.
@@ -353,7 +352,7 @@
(\url{http://www.python.org}), external hyperlinks (\href{http://www.python.org/}{Python}\DUfootnotemark{id30}{id29}{5}), internal
cross-references (\hyperref[example]{example}), external hyperlinks with embedded URIs
(\href{http://www.python.org}{Python web site}), \href{http://www.python.org/}{anonymous hyperlink
-references}\DUfootnotemark{id37}{id29}{5} (\href{http://docutils.sourceforge.net/}{a second reference}\DUfootnotemark{id39}{id38}{8}), footnote references (manually
+references}\DUfootnotemark{id40}{id29}{5} (\href{http://docutils.sourceforge.net/}{a second reference}\DUfootnotemark{id42}{id41}{9}), footnote references (manually
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]}),
substitution references (\includegraphics{../../../docs/user/rst/images/biohazard.png}), and %
\phantomsection\label{inline-hyperlink-targets}inline hyperlink targets
@@ -787,8 +786,8 @@
\DUfootnotetext{id16}{id16}{4}{%
Here’s an unreferenced footnote, with a reference to a
nonexistent footnote:%
-\raisebox{1em}{\hypertarget{id45}{}}%
-\raisebox{1em}{\hypertarget{id17}{}}\hyperlink{id44}{\textbf{\color{red}{[}5{]}\_}}.
+\raisebox{1em}{\hypertarget{id48}{}}%
+\raisebox{1em}{\hypertarget{id17}{}}\hyperlink{id47}{\textbf{\color{red}{[}5{]}\_}}.
}
@@ -801,8 +800,8 @@
\end{figure}
Here’s a reference to the above, \hyperlink{cit2002}{[CIT2002]}, and a %
-\raisebox{1em}{\hypertarget{id47}{}}%
-\raisebox{1em}{\hypertarget{id19}{}}\hyperlink{id46}{\textbf{\color{red}{[}nonexistent{]}\_}}
+\raisebox{1em}{\hypertarget{id50}{}}%
+\raisebox{1em}{\hypertarget{id19}{}}\hyperlink{id49}{\textbf{\color{red}{[}nonexistent{]}\_}}
citation.
@@ -826,7 +825,7 @@
refer to the \hyperref[targets]{Targets} section.
Here’s a %
-\raisebox{1em}{\hypertarget{id49}{}}\hyperlink{id48}{\textbf{\color{red}`hyperlink reference without a target`\_}}, which generates an
+\raisebox{1em}{\hypertarget{id52}{}}\hyperlink{id51}{\textbf{\color{red}`hyperlink reference without a target`\_}}, which generates an
error.
@@ -846,7 +845,7 @@
Since there are two “Duplicate Target Names” section headers, we
cannot uniquely refer to either of them by name. If we try to (like
this: %
-\raisebox{1em}{\hypertarget{id51}{}}\hyperlink{id50}{\textbf{\color{red}`Duplicate Target Names`\_}}), an error is generated.
+\raisebox{1em}{\hypertarget{id54}{}}\hyperlink{id53}{\textbf{\color{red}`Duplicate Target Names`\_}}), an error is generated.
\subsection{2.14 Directives%
@@ -1254,12 +1253,15 @@
A \emph{topic} is like a block quote with a title, or a self-contained section
with no subsections.
-\DUtopic[]{
-\DUtitle[title]{Topic Title}
+\begin{DUclass}{topic}
+\begin{quote}
+\DUtitle[topic]{Topic Title}
This is a topic.
-}
+\end{quote}
+\end{DUclass}
+
A \emph{rubric} is like an informal heading that doesn’t correspond to the
document’s structure. It is typically highlighted in red (hence the name).
@@ -1282,14 +1284,18 @@
}
%
\DUfootnotetext{id35}{id36}{7}{%
+\url{ftp://ftp.ams.org/ams/doc/amsmath/short-math-guide.pdf}
+}
+%
+\DUfootnotetext{id38}{id39}{8}{%
\url{http://ctan.org/pkg/polyglossia}
}
%
-\DUfootnotetext{id38}{id39}{8}{%
+\DUfootnotetext{id41}{id42}{9}{%
\url{http://docutils.sourceforge.net/}
}
%
-\DUfootnotetext{id40}{id41}{9}{%
+\DUfootnotetext{id43}{id44}{10}{%
\url{A:DOS\\path\\}
}
@@ -1704,11 +1710,137 @@
\end{alltt}
\end{quote}
-\DUrole{green}{\DUrole{sc}{\foreignlanguage{british}{British colourful text in small-caps}}}.
+\DUrole{green}{\DUrole{sc}{\foreignlanguage{english}{British colourful text in small-caps}}}.
\end{itemize}
+\subsection{2.22 Mathematics%
+ \label{mathematics}%
+}
+
+Docutils supports inline math with the prefix or postfix \texttt{:math:}
+role specificator, $n! + \sin(x_n^2)$ and $A_\text{c} =
+\frac{\pi}{4} d^2$, as well as displayed math via the
+\DUroletitlereference{math} directive:
+%
+\begin{equation*}
+f(\epsilon) = \frac{1}{1 + \exp\left(\frac{\varepsilon}{k_\text{B}T}\right)}
+\end{equation*}
+Content may start on the first line of the directive, e.g.
+%
+\begin{equation*}
+N = \frac{\text{number of apples}}{7}
+\end{equation*}
+Equations can be labeled with a reference name using the \texttt{:name:} option.
+See \hyperref[eq-m]{eq:M} and \hyperref[eq-schrodinger]{eq:schrödinger} below.
+
+The determinant of the matrix
+%
+\begin{equation*}
+\mathbf{M} = \left(\begin{matrix}a&b\\c&d\end{matrix}\right)
+\phantomsection
+\label{eq-m}
+\end{equation*}
+is $|\mathbf{M}| = ad - bc$.
+
+More than one display math block can be put in one math directive.
+For example, the following sum and integral with limits:
+%
+\begin{equation*}
+\int_0^1 x^n dx = \frac{1}{n + 1}
+\end{equation*}%
+\begin{equation*}
+\sum_{n=1}^m n = \frac{m(m+1)}{2}
+\end{equation*}
+LaTeX-supported Unicode math symbols can be used in math roles and
+directives:
+
+The Schrödinger equation
+%
+\begin{equation*}
+i\hbar \frac{\partial }{\partial t}\Psi = \hat{H}\Psi ,
+\phantomsection
+\label{eq-schrodinger}
+\end{equation*}
+with the \emph{wave function} $\Psi $, describes how the quantum state of a
+physical system changes in time.
+
+\begin{description}
+\item[{Math-Accents:}] \leavevmode
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable*}[c]{p{0.315\DUtablewidth}p{0.315\DUtablewidth}p{0.315\DUtablewidth}}
+
+$\acute{a}$ \texttt{\textbackslash{}acute\{a\}}
+ &
+$\dot{t}$ \texttt{\textbackslash{}dot\{t\}}
+ &
+$\hat{\gamma}$ \texttt{\textbackslash{}hat\{\textbackslash{}gamma\}}
+ \\
+
+$\grave{a}$ \texttt{\textbackslash{}grave\{a\}}
+ &
+$\ddot{t}$ \texttt{\textbackslash{}ddot\{t\}}
+ &
+$\tilde{\alpha}$ \texttt{\textbackslash{}tilde\{\textbackslash{}alpha\}}
+ \\
+
+$\breve{x}$ \texttt{\textbackslash{}breve\{x\}}
+ &
+$\dddot{t}$ \texttt{\textbackslash{}dddot\{t\}}
+ &
+$\vec{\imath}$ \texttt{\textbackslash{}vec\{\textbackslash{}imath\}}
+ \\
+
+$\check{a}$ \texttt{\textbackslash{}check\{a\}}
+ &
+$\bar{a}$ \texttt{\textbackslash{}bar\{a\}}
+ &
+$\vec{R}$ \texttt{\textbackslash{}vec\{R\}}
+ \\
+\end{longtable*}
+
+\end{description}
+
+% \widetilde{xxx}
+% \widehat{xxx}
+
+Modulation Transfer Function:
+%
+\begin{equation*}
+\text{MTF} = \left|\frac{\mathcal{F}\{s(x)\}}
+ {\mathcal{F}\{ s(x)\} |_{\omega _{x}=0}}\right|
+ = \mathrm{abs}\left(\frac
+ {\int _{-\infty }^{\infty }s(x) \mathrm{e}^{\mathrm{i}\omega _{x}x}\mathrm{d}{x}}
+ {\int _{-\infty }^{\infty }s(x)\mathrm{d}{x}}
+ \right).
+\end{equation*}
+Math split over two lines: If a double backslash is detected outside a
+\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}
+\texttt{align} environment:
+%
+\begin{align*}
+s_{\mathrm{out}}(x) & = s_{\mathrm{in}}(x') * s_\delta (x-x') \\
+ & = \int s_{\mathrm{in}}(x')s_\delta (x-x')\mathrm{d}x'
+\end{align*}
+Cases (“manually”, with \texttt{matrix} environment):
+%
+\begin{equation*}
+\mathrm{sgn}(x) = \left\{\begin{matrix}
+ -1 & x<0\\
+ 1 & x>0
+ \end{matrix}\right.
+\end{equation*}
+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
+HTML writers with \texttt{--math-output=MathML}):
+%
+\begin{equation*}
+\mathrm{sgn}(x) = \begin{cases}
+ -1 & x<0\\
+ 1 & x>0
+ \end{cases}
+\end{equation*}
+
\section{3 Tests for the LaTeX writer%
\label{tests-for-the-latex-writer}%
}
@@ -1731,7 +1863,8 @@
Class arguments may contain numbers and hyphens, which need special
treatment in LaTeX command names.
-\DUrole{large}{\DUrole{custom4}{\DUrole{small-caps}{\DUrole{custom-role}{\DUrole{custom-role}{Interpreted Text}}}}}
+\DUrole{large}{\DUrole{custom4}{\DUrole{small-caps}{\DUrole{custom-role}{\DUrole{custom-role}{Text with role “custom4”}}}}} (but without styling by \texttt{DUrole*}
+macros).
\item With LaTeX, roles can be styled within the document using the \DUroletitlereference{raw}
directive.
@@ -1742,7 +1875,7 @@
\@namedef{DUrolecustom4}{\textbf}
\makeatother
-\DUrole{large}{\DUrole{custom4}{\DUrole{small-caps}{\DUrole{custom-role}{\DUrole{custom-role}{Interpreted Text}}}}} in large, bold, small-caps.
+\DUrole{large}{\DUrole{custom4}{\DUrole{small-caps}{\DUrole{custom-role}{\DUrole{custom-role}{inline text}}}}} in large, bold, small-caps.
\item Custom roles can be based on standard roles:
@@ -1760,10 +1893,222 @@
\end{itemize}
+
+\subsection{3.2 class handling%
+ \label{class-handling}%
+}
+
+This section tests class handling for block level elements by the LaTeX
+writer. See the input file \texttt{classes\_latex.txt} for the raw LaTeX code used
+to style the examples.
+
+An “epigraph” directive is exported as “quote” wrapped in a “DUclass”
+environment. Here, it is styled by a “DUCLASSepigraph” environment
+redefining the “quote” environment as “minipage”:
+
+\newcommand*{\DUCLASSepigraph}{%
+ \renewenvironment{quote}{\vspace{1em}
+ \footnotesize\hfill{}%
+ \begin{minipage}{0.4\columnwidth}}%
+ {\end{minipage}\vskip\baselineskip}}
+
+\begin{DUclass}{epigraph}
+\begin{quote}
+
+Do not play this piece fast. It is never right to play \emph{Ragtime} fast.
+\nopagebreak
+
+\raggedleft —Scott Joplin
+
+\end{quote}
+\end{DUclass}
+
+Raw latex is also used to style the following lists: “DUCLASSenumerateitems”
+redefines “itemize” as “enumerate”, “DUCLASSrules” draws horizontal lines
+above and below.
+
+\newcommand*{\DUCLASSenumerateitems}{%
+ \renewenvironment{itemize}{\begin{enumerate}}%
+ {\end{enumerate}}%
+}
+
+\newenvironment{DUCLASSrules}%
+ {\noindent\rule[0.5ex]{1\columnwidth}{1pt}}%
+ {\noindent\rule[0.5ex]{1\columnwidth}{1pt}}
+
+An “enumerated” bullet list:
+
+\begin{DUclass}{enumerateitems}
+\begin{itemize}
+
+\item item
+
+\item next item
+
+\item third item
+
+\end{itemize}
+\end{DUclass}
+
+A list with lines above and below:
+
+\begin{DUclass}{rules}
+\begin{itemize}
+
+\item item
+
+\item next item
+
+\end{itemize}
+\end{DUclass}
+
+A normal bullet list is kept unchanged by the above redefinitions:
+
+\begin{itemize}
+
+\item item
+
+\item next item
+
+\item third item
+
+\end{itemize}
+
+A container wraps several elements in a common “class wrapper”. Here, we use
+it to set 2 paragraphs and a list in small caps:
+
+\newcommand*{\DUCLASSscshape}{\scshape}
+
+\begin{DUclass}{scshape}
+
+paragraph 1
+
+paragraph 2
+
+\begin{itemize}
+
+\item bullet list
+
+\item still bullet list
+
+\end{itemize}
+\end{DUclass}
+
+A right-aligned line-block. Alignment handling is built into the latex
+writer for image, table, and line block elements.
+
+\begin{DUlineblock}{0em}
+\raggedleft
+\item[] Max Mustermann
+\item[] Waldstr. 22
+\item[] D 01234 Testdorf
+\item[] Tel.: 0123/456789
+\end{DUlineblock}
+
+
+\subsection{3.3 More Tables%
+ \label{more-tables}%
+}
+
+A table with multi-paragraph multicolumn cells:
+
+\setlength{\DUtablewidth}{\linewidth}
+\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}|}
+\hline
+
+test
+ &
+\textbf{bold hd}
+ & \multicolumn{3}{p{0.41\DUtablewidth}|}{%
+multicolumn 1
+
+With a second paragraph
+} &
+\emph{emph hd}
+ \\
+\hline
+\multicolumn{2}{|p{0.31\DUtablewidth}|}{%
+multicolumn 2
+
+With a second paragraph
+} &
+cell
+ &
+cell
+ &
+cell
+ &
+cell
+ \\
+\hline
+
+cell
+ & \multicolumn{2}{p{0.36\DUtablewidth}|}{%
+multicolumn 3 (one line,
+but very very very very
+very looooong)
+} &
+cell
+ &
+cell
+ &
+cell
+ \\
+\hline
+
+cell
+ &
+cell
+ &
+cell
+ & \multicolumn{3}{p{0.38\DUtablewidth}|}{%
+Short multicolumn 4
+} \\
+\hline
+\end{longtable*}
+
+Tables with multi-paragraph multirow cells currently fail due to a LaTeX
+limitation (see \url{https://sourceforge.net/p/docutils/bugs/225/}).
+
+A table with multirow header and column-widths set by LaTeX:
+
+\begin{longtable*}[c]{|l|l|}
+\hline
+\multirow{2}{*}{\textbf{XXX}} & \textbf{Variable Summary} \\
+\cline{2-2}
+ & \textbf{Description} \\
+\hline
+\endfirsthead
+\hline
+\multirow{2}{*}{\textbf{XXX}} & \textbf{Variable Summary} \\
+\cline{2-2}
+ & \textbf{Description} \\
+\hline
+\endhead
+\multicolumn{2}{c}{\hfill ... continued on next page} \\
+\endfoot
+\endlastfoot
+\multicolumn{2}{|l|}{multicollumn cell} \\
+\hline
+\end{longtable*}
+
+In a table with column-widths set by LaTeX, each cell has just one line.
+Paragraphs are merged (a warning is given).
+
+\begin{longtable*}[c]{|l|l|}
+\hline
+11 & first paragraph
+second paragraph
+third paragraph \\
+\hline
+21 & 22 \\
+\hline
+\end{longtable*}
+
% This file is used by the standalone_rst_latex test.
-\subsection{3.2 Option lists%
+\subsection{3.4 Option lists%
\label{id23}%
}
@@ -1799,7 +2144,7 @@
\end{description}
-\subsection{3.3 Monospaced non-alphanumeric characters%
+\subsection{3.5 Monospaced non-alphanumeric characters%
\label{monospaced-non-alphanumeric-characters}%
}
@@ -1815,7 +2160,7 @@
width as the third line.
-\subsection{3.4 Non-ASCII characters%
+\subsection{3.6 Non-ASCII characters%
\label{non-ascii-characters}%
}
@@ -2201,36 +2546,10 @@
pdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrisch
-\item The currency sign (\textbackslash{}u00a4) is not supported by all fonts
-(some have an Euro sign at its place). You might see an error
-like:
-
-\begin{quote}
-\begin{alltt}
-! Package textcomp Error: Symbol \textbackslash{}textcurrency not provided by
-(textcomp) font family ptm in TS1 encoding.
-(textcomp) Default family used instead.
-\end{alltt}
-\end{quote}
-
-(which in case of font family ptm is a false positive). Add either
-
-\begin{DUfieldlist}
-\item[{warn:}]
-turn the error in a warning, use the default symbol (bitmap), or
-
-\item[{force,almostfull:}]
-use the symbol provided by the font at the users
-risk,
-
-\end{DUfieldlist}
-
-to the document options or use a different font package.
-
\end{itemize}
-\subsection{3.5 Encoding special chars%
+\subsection{3.7 Encoding special chars%
\label{encoding-special-chars}%
}
@@ -2301,7 +2620,7 @@
\end{quote}
-\subsection{3.6 Hyperlinks and -targets%
+\subsection{3.8 Hyperlinks and -targets%
\label{hyperlinks-and-targets}%
}
@@ -2347,7 +2666,7 @@
\hyperref[image-label]{image label}.
-\subsection{3.7 External references%
+\subsection{3.9 External references%
\label{external-references}%
}
@@ -2388,7 +2707,7 @@
\url{http://www.w3.org/XML/Schema\#dev}
\item[] \href{http://www.w3.org/XML/Schema\%dev}{URL with \%}
\url{http://example.org/Schema\%dev}
-\item[] \href{A:DOS\\path\\}{file with DOS path}\DUfootnotemark{id41}{id40}{9} \url{A:DOS\\path\\}\DUfootnotemark{id42}{id40}{9}
+\item[] \href{A:DOS\\path\\}{file with DOS path}\DUfootnotemark{id44}{id43}{10} \url{A:DOS\\path\\}\DUfootnotemark{id45}{id43}{10}
\end{DUlineblock}
\DUadmonition[note]{
@@ -2399,7 +2718,7 @@
\begin{DUlineblock}{0em}
\item[] \url{http://www.w3.org/XML/Schema\#dev}
\item[] \url{http://example.org/Schema\%dev}
-\item[] \url{A:DOS\\path\\}\DUfootnotemark{id43}{id40}{9}
+\item[] \url{A:DOS\\path\\}\DUfootnotemark{id46}{id43}{10}
\end{DUlineblock}
}
@@ -2433,22 +2752,22 @@
\end{itemize}
-\subsection{3.8 Section titles with \hyperref[inline-markup]{inline markup}%
+\subsection{3.10 Section titles with \hyperref[inline-markup]{inline markup}%
\label{section-titles-with-inline-markup}%
}
-\subsubsection{3.8.1 \emph{emphasized}, H\textsubscript{2}O and $x^2$%
+\subsubsection{3.10.1 \emph{emphasized}, H\textsubscript{2}O and $x^2$%
\label{emphasized-h2o-and-x-2}%
}
-\subsubsection{3.8.2 Substitutions work%
+\subsubsection{3.10.2 Substitutions work%
\label{substitutions-fail}%
}
-\subsection{3.9 Deeply nested sections%
+\subsection{3.11 Deeply nested sections%
\label{deeply-nested-sections}%
}
@@ -2455,7 +2774,7 @@
In LaTeX and HTML,
-\subsubsection{3.9.1 Level 3%
+\subsubsection{3.11.1 Level 3%
\label{level-3}%
}
@@ -2462,7 +2781,7 @@
nested sections
-\paragraph{3.9.1.1 level 4%
+\paragraph{3.11.1.1 level 4%
\label{level-4}%
}
@@ -2469,7 +2788,7 @@
reach at some level
-\subparagraph{3.9.1.1.1 level 5%
+\subparagraph{3.11.1.1.1 level 5%
\label{level-5}%
}
@@ -2476,7 +2795,7 @@
(depending on the document class)
-\DUtitle[sectionVI]{3.9.1.1.1.1 level 6%
+\DUtitle[sectionVI]{3.11.1.1.1.1 level 6%
\label{level-6}%
}
@@ -2495,7 +2814,7 @@
Русский, Slovenščina, Српски, Türkçe, Українська, Tiếng Việt, Volapük,
Võro, ייִדיש , Žemaitėška.
Currently, there is extended support for 28 languages in the
-\href{http://ctan.org/pkg/polyglossia}{polyglossia}\DUfootnotemark{id36}{id35}{7} package.
+\href{http://ctan.org/pkg/polyglossia}{polyglossia}\DUfootnotemark{id39}{id38}{8} package.
% System Messages:
@@ -2527,41 +2846,41 @@
\DUadmonition[system-message]{
\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{id44}{}}
+\raisebox{1em}{\hypertarget{id47}{}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~391
-\hyperlink{id45}{
+\hyperlink{id48}{
Unknown target name: \textquotedbl{}5\textquotedbl{}.
}}
\DUadmonition[system-message]{
\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{id46}{}}
+\raisebox{1em}{\hypertarget{id49}{}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~400
-\hyperlink{id47}{
+\hyperlink{id50}{
Unknown target name: \textquotedbl{}nonexistent\textquotedbl{}.
}}
\DUadmonition[system-message]{
\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{id48}{}}
+\raisebox{1em}{\hypertarget{id51}{}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~427
-\hyperlink{id49}{
+\hyperlink{id52}{
Unknown target name: \textquotedbl{}hyperlink reference without a target\textquotedbl{}.
}}
\DUadmonition[system-message]{
\DUtitle[system-message]{system-message}
-\raisebox{1em}{\hypertarget{id50}{}}
+\raisebox{1em}{\hypertarget{id53}{}}
{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~440
-\hyperlink{id51}{
+\hyperlink{id54}{
Duplicate target name, cannot be used as a unique reference: \textquotedbl{}duplicate target names\textquotedbl{}.
}}
Modified: trunk/docutils/test/functional/expected/xetex-cyrillic.tex
===================================================================
--- trunk/docutils/test/functional/expected/xetex-cyrillic.tex 2017-03-07 13:06:08 UTC (rev 8045)
+++ trunk/docutils/test/functional/expected/xetex-cyrillic.tex 2017-03-11 12:09:36 UTC (rev 8046)
@@ -5,8 +5,8 @@
% \defaultfontfeatures{Scale=MatchLowercase}
% straight double quotes (defined T1 but missing in TU):
\ifdefined \UnicodeEncodingName
- \ProvideTextCommand{\textquotedbl}{\UnicodeEncodingName}{%
- {\addfontfeatures{Ligatures=ResetAll}\char"0022}}
+ \DeclareTextCommand{\textquotedbl}{\UnicodeEncodingName}{%
+ {\addfontfeatures{RawFeature=-tlig,Mapping=}\char34}}%
\fi
\usepackage{ifthen}
\usepackage{polyglossia}
Added: trunk/docutils/test/functional/input/data/classes_latex.txt
===================================================================
--- trunk/docutils/test/functional/input/data/classes_latex.txt (rev 0)
+++ trunk/docutils/test/functional/input/data/classes_latex.txt 2017-03-11 12:09:36 UTC (rev 8046)
@@ -0,0 +1,87 @@
+class handling
+--------------
+
+This section tests class handling for block level elements by the LaTeX
+writer. See the input file ``classes_latex.txt`` for the raw LaTeX code used
+to style the examples.
+
+An "epigraph" directive is exported as "quote" wrapped in a "DUclass"
+environment. Here, it is styled by a "DUCLASSepigraph" environment
+redefining the "quote" environment as "minipage":
+
+.. raw:: latex
+
+ \newcommand*{\DUCLASSepigraph}{%
+ \renewenvironment{quote}{\vspace{1em}
+ \footnotesize\hfill{}%
+ \begin{minipage}{0.4\columnwidth}}%
+ {\end{minipage}\vskip\baselineskip}}
+
+.. epigraph::
+
+ Do not play this piece fast. It is never right to play *Ragtime* fast.
+
+ -- Scott Joplin
+
+Raw latex is also used to style the following lists: "DUCLASSenumerateitems"
+redefines "itemize" as "enumerate", "DUCLASSrules" draws horizontal lines
+above and below.
+
+.. raw:: latex
+
+ \newcommand*{\DUCLASSenumerateitems}{%
+ \renewenvironment{itemize}{\begin{enumerate}}%
+ {\end{enumerate}}%
+ }
+
+ \newenvironment{DUCLASSrules}%
+ {\noindent\rule[0.5ex]{1\columnwidth}{1pt}}%
+ {\noindent\rule[0.5ex]{1\columnwidth}{1pt}}
+
+An "enumerated" bullet list:
+
+.. class:: enumerateItems
+
+* item
+* next item
+* third item
+
+A list with lines above and below:
+
+.. class:: rules
+
+* item
+* next item
+
+A normal bullet list is kept unchanged by the above redefinitions:
+
+* item
+* next item
+* third item
+
+A container wraps several elements in a common "class wrapper". Here, we use
+it to set 2 paragraphs and a list in small caps:
+
+.. raw:: latex
+
+ \newcommand*{\DUCLASSscshape}{\scshape}
+
+.. container:: scshape
+
+ paragraph 1
+
+ paragraph 2
+
+ * bullet list
+ * still bullet list
+
+
+A right-aligned line-block. Alignment handling is built into the latex
+writer for image, table, and line block elements.
+
+.. class:: align-right
+
+| Max Mustermann
+| Waldstr. 22
+| D 01234 Testdorf
+| Tel.: 0123/456789
Property changes on: trunk/docutils/test/functional/input/data/classes_latex.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Modified: trunk/docutils/test/functional/input/data/custom_roles_latex.txt
===================================================================
--- trunk/docutils/test/functional/input/data/custom_roles_latex.txt 2017-03-07 13:06:08 UTC (rev 8045)
+++ trunk/docutils/test/functional/input/data/custom_roles_latex.txt 2017-03-11 12:09:36 UTC (rev 8046)
@@ -12,7 +12,8 @@
.. role:: custom4
:class: large custom4 small_caps custom.role custom\role
- :custom4:`Interpreted Text`
+ :custom4:`Text with role "custom4"` (but without styling by ``DUrole*``
+ macros).
* With LaTeX, roles can be styled within the document using the `raw`
directive.
@@ -25,7 +26,7 @@
\@namedef{DUrolecustom4}{\textbf}
\ma...
[truncated message content] |