diff options
9 files changed, 46 insertions, 229 deletions
diff --git a/docutils/docutils/writers/latex2e/__init__.py b/docutils/docutils/writers/latex2e/__init__.py index 8bf57a9eb..160757b13 100644 --- a/docutils/docutils/writers/latex2e/__init__.py +++ b/docutils/docutils/writers/latex2e/__init__.py @@ -660,6 +660,12 @@ PreambleCmds.table = r"""\usepackage{longtable,ltcaption,array} PreambleCmds.textcomp = """\ \\usepackage{textcomp} % text symbol macros""" +PreambleCmds.textsubscript = r""" +% text mode subscript +\ifx\textsubscript\undefined + \usepackage{fixltx2e} % since 2015 loaded by default +\fi""" + PreambleCmds.titlereference = r""" % titlereference role \providecommand*{\DUroletitlereference}[1]{\textsl{#1}}""" @@ -1655,7 +1661,7 @@ class LaTeXTranslator(nodes.NodeVisitor): # strip the generic 'admonition' from the list of classes node['classes'] = [cls for cls in node['classes'] if cls != 'admonition'] - self.out.append('\n\\DUadmonition[%s]{\n' % ','.join(node['classes'])) + self.out.append('\n\\DUadmonition[%s]{' % ','.join(node['classes'])) def depart_admonition(self, node=None): self.out.append('}\n') @@ -1675,24 +1681,24 @@ class LaTeXTranslator(nodes.NodeVisitor): def visit_block_quote(self, node): self.duclass_open(node) - self.out.append( '\\begin{quote}\n') + self.out.append( '\\begin{quote}') def depart_block_quote(self, node): - self.out.append( '\n\\end{quote}\n') + self.out.append( '\\end{quote}\n') self.duclass_close(node) def visit_bullet_list(self, node): self.duclass_open(node) if self.is_toc_list: - self.out.append( '\\begin{list}{}{}\n' ) + self.out.append( '\\begin{list}{}{}' ) else: - self.out.append( '\\begin{itemize}\n' ) + self.out.append( '\\begin{itemize}' ) def depart_bullet_list(self, node): if self.is_toc_list: - self.out.append( '\n\\end{list}\n' ) + self.out.append( '\\end{list}\n' ) else: - self.out.append( '\n\\end{itemize}\n' ) + self.out.append( '\\end{itemize}\n' ) self.duclass_close(node) def visit_superscript(self, node): @@ -1706,7 +1712,8 @@ class LaTeXTranslator(nodes.NodeVisitor): self.out.append('}') def visit_subscript(self, node): - self.out.append(r'\textsubscript{') # requires `fixltx2e` + self.fallbacks['textsubscript'] = PreambleCmds.textsubscript + self.out.append(r'\textsubscript{') if node['classes']: self.visit_inline(node) @@ -1792,7 +1799,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.out.append( '(\\textbf{' ) def depart_classifier(self, node): - self.out.append( '})\n' ) + self.out.append( '})' ) def visit_colspec(self, node): self.active_table.visit_colspec(node) @@ -2126,18 +2133,18 @@ class LaTeXTranslator(nodes.NodeVisitor): self.duclass_open(node) if enumeration_level <= 4: - self.out.append('\\begin{enumerate}\n') + self.out.append('\\begin{enumerate}') if (prefix, enumtype, suffix ) != labels[enumeration_level-1]: - self.out.append('\\renewcommand{\\label%s}{%s}\n' % + self.out.append('\n\\renewcommand{\\label%s}{%s}' % (counter_name, label)) else: self.fallbacks[counter_name] = '\\newcounter{%s}' % counter_name self.out.append('\\begin{list}') self.out.append('{%s}' % label) - self.out.append('{\\usecounter{%s}}\n' % counter_name) + self.out.append('{\\usecounter{%s}}' % counter_name) if 'start' in node: - self.out.append('\\setcounter{%s}{%d}\n' % + self.out.append('\n\\setcounter{%s}{%d}' % (counter_name,node['start']-1)) @@ -2154,7 +2161,7 @@ class LaTeXTranslator(nodes.NodeVisitor): pass def depart_field(self, node): - self.out.append('\n') + pass ##self.out.append('%[depart_field]\n') def visit_field_argument(self, node): @@ -2168,13 +2175,13 @@ class LaTeXTranslator(nodes.NodeVisitor): def depart_field_body(self, node): if self.out is self.docinfo: - self.out.append(r'\\') + self.out.append(r'\\'+'\n') def visit_field_list(self, node): self.duclass_open(node) if self.out is not self.docinfo: self.fallbacks['fieldlist'] = PreambleCmds.fieldlist - self.out.append('\\begin{DUfieldlist}\n') + self.out.append('\\begin{DUfieldlist}') def depart_field_list(self, node): if self.out is not self.docinfo: @@ -2187,7 +2194,7 @@ class LaTeXTranslator(nodes.NodeVisitor): else: # Commands with optional args inside an optional arg must be put # in a group, e.g. ``\item[{\hyperref[label]{text}}]``. - self.out.append('\\item[{') + self.out.append('\n\\item[{') def depart_field_name(self, node): if self.out is self.docinfo: @@ -2618,10 +2625,10 @@ class LaTeXTranslator(nodes.NodeVisitor): self.fallbacks['_providelength'] = PreambleCmds.providelength self.fallbacks['optionlist'] = PreambleCmds.optionlist self.duclass_open(node) - self.out.append('\\begin{DUoptionlist}\n') + self.out.append('\\begin{DUoptionlist}') def depart_option_list(self, node): - self.out.append('\n\\end{DUoptionlist}\n') + self.out.append('\\end{DUoptionlist}\n') self.duclass_close(node) def visit_option_list_item(self, node): @@ -2784,7 +2791,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.duclass_open(node) self.requirements['color'] = PreambleCmds.color self.fallbacks['sidebar'] = PreambleCmds.sidebar - self.out.append('\\DUsidebar{\n') + self.out.append('\\DUsidebar{') def depart_sidebar(self, node): self.out.append('}\n') @@ -2850,7 +2857,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.fallbacks['title'] = PreambleCmds.title node['classes'] = ['system-message'] self.visit_admonition(node) - self.out.append('\\DUtitle[system-message]{system-message}\n') + self.out.append('\n\\DUtitle[system-message]{system-message}\n') self.append_hypertargets(node) try: line = ', line~%s' % node['line'] @@ -2989,7 +2996,7 @@ class LaTeXTranslator(nodes.NodeVisitor): classes = ','.join(node.parent['classes']) if not classes: classes = node.tagname - self.out.append('\\DUtitle[%s]{' % classes) + self.out.append('\n\\DUtitle[%s]{' % classes) self.context.append('}\n') # Table caption elif isinstance(node.parent, nodes.table): @@ -3075,7 +3082,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.out += self.ids_to_labels(node) # add contents to PDF bookmarks sidebar if isinstance(node.next_node(), nodes.title): - self.out.append('\n\\pdfbookmark[%d]{%s}{%s}\n' % + self.out.append('\n\\pdfbookmark[%d]{%s}{%s}' % (self.section_level+1, node.next_node().astext(), node.get('ids', ['contents'])[0] @@ -3091,9 +3098,9 @@ class LaTeXTranslator(nodes.NodeVisitor): if depth: self.out.append('\\setcounter{tocdepth}{%d}\n' % depth) if title != 'Contents': - self.out.append('\\renewcommand{\\contentsname}{%s}\n' % + self.out.append('\n\\renewcommand{\\contentsname}{%s}' % title) - self.out.append('\\tableofcontents\n\n') + self.out.append('\n\\tableofcontents\n') self.has_latex_toc = True else: # Docutils generated contents list # set flag for visit_bullet_list() and visit_title() @@ -3129,10 +3136,8 @@ class LaTeXTranslator(nodes.NodeVisitor): def visit_transition(self, node): self.fallbacks['transition'] = PreambleCmds.transition - self.out.append('\n\n') - self.out.append('%' + '_' * 75 + '\n') - self.out.append(r'\DUtransition') - self.out.append('\n\n') + self.out.append('\n%' + '_' * 75 + '\n') + self.out.append('\\DUtransition\n') def depart_transition(self, node): pass diff --git a/docutils/docutils/writers/latex2e/default.tex b/docutils/docutils/writers/latex2e/default.tex index 84c209433..98f6396cb 100644 --- a/docutils/docutils/writers/latex2e/default.tex +++ b/docutils/docutils/writers/latex2e/default.tex @@ -1,7 +1,4 @@ $head_prefix% generated by Docutils <http://docutils.sourceforge.net/> -\ifx\textsubscript\undefined - \usepackage{fixltx2e} % since 2015 loaded by default -\fi \usepackage{cmap} % fix search and cut-and-paste in Acrobat $requirements %%% Custom LaTeX preamble diff --git a/docutils/test/functional/expected/cyrillic.tex b/docutils/test/functional/expected/cyrillic.tex index 496fce61a..d562fd6ca 100644 --- a/docutils/test/functional/expected/cyrillic.tex +++ b/docutils/test/functional/expected/cyrillic.tex @@ -1,8 +1,5 @@ \documentclass[a4paper,russian]{article} % generated by Docutils <http://docutils.sourceforge.net/> -\ifx\textsubscript\undefined - \usepackage{fixltx2e} % since 2015 loaded by default -\fi \usepackage{cmap} % fix search and cut-and-paste in Acrobat \usepackage{ifthen} \usepackage[T1,T2A]{fontenc} diff --git a/docutils/test/functional/expected/latex_babel.tex b/docutils/test/functional/expected/latex_babel.tex index f33430180..bc4e780e3 100644 --- a/docutils/test/functional/expected/latex_babel.tex +++ b/docutils/test/functional/expected/latex_babel.tex @@ -1,8 +1,5 @@ \documentclass[a4paper]{article} % generated by Docutils <http://docutils.sourceforge.net/> -\ifx\textsubscript\undefined - \usepackage{fixltx2e} % since 2015 loaded by default -\fi \usepackage{cmap} % fix search and cut-and-paste in Acrobat \usepackage{ifthen} \usepackage[T1]{fontenc} diff --git a/docutils/test/functional/expected/latex_cornercases.tex b/docutils/test/functional/expected/latex_cornercases.tex index 7d43dda39..25079a4a1 100644 --- a/docutils/test/functional/expected/latex_cornercases.tex +++ b/docutils/test/functional/expected/latex_cornercases.tex @@ -1,8 +1,5 @@ \documentclass[a4paper]{article} % generated by Docutils <http://docutils.sourceforge.net/> -\ifx\textsubscript\undefined - \usepackage{fixltx2e} % since 2015 loaded by default -\fi \usepackage{cmap} % fix search and cut-and-paste in Acrobat \usepackage{ifthen} \usepackage[T1]{fontenc} @@ -60,7 +57,6 @@ trouble for the LaTeX writer but do not need to be tested with other writers. } \begin{quote} - This block quote comes directly after the section heading and is followed by a paragraph. @@ -70,23 +66,18 @@ empty. \nopagebreak \raggedleft —Attribution - \end{quote} This is a paragraph. \begin{quote} - This block quote does not have an attribution. - \end{quote} This is another paragraph. \begin{quote} - Another block quote at the end of the section. - \end{quote} @@ -95,20 +86,14 @@ Another block quote at the end of the section. } \begin{quote} - Block quote followed by a transition. - \end{quote} - %___________________________________________________________________________ \DUtransition - \begin{quote} - Another block quote. - \end{quote} diff --git a/docutils/test/functional/expected/latex_docinfo.tex b/docutils/test/functional/expected/latex_docinfo.tex index 951c29b79..a51d15891 100644 --- a/docutils/test/functional/expected/latex_docinfo.tex +++ b/docutils/test/functional/expected/latex_docinfo.tex @@ -1,8 +1,5 @@ \documentclass[a4paper]{article} % generated by Docutils <http://docutils.sourceforge.net/> -\ifx\textsubscript\undefined - \usepackage{fixltx2e} % since 2015 loaded by default -\fi \usepackage{cmap} % fix search and cut-and-paste in Acrobat \usepackage{ifthen} \usepackage[T1]{fontenc} diff --git a/docutils/test/functional/expected/standalone_rst_latex.tex b/docutils/test/functional/expected/standalone_rst_latex.tex index 0de9df329..dc7feb914 100644 --- a/docutils/test/functional/expected/standalone_rst_latex.tex +++ b/docutils/test/functional/expected/standalone_rst_latex.tex @@ -1,8 +1,5 @@ \documentclass[a4paper]{article} % generated by Docutils <http://docutils.sourceforge.net/> -\ifx\textsubscript\undefined - \usepackage{fixltx2e} % since 2015 loaded by default -\fi \usepackage{cmap} % fix search and cut-and-paste in Acrobat \usepackage{ifthen} \usepackage[T1]{fontenc} @@ -161,6 +158,11 @@ % subtitle (for topic/sidebar) \providecommand*{\DUsubtitle}[1]{\par\emph{#1}\smallskip} +% text mode subscript +\ifx\textsubscript\undefined + \usepackage{fixltx2e} % since 2015 loaded by default +\fi + % title for topics, admonitions, unsupported section levels, and sidebar \providecommand*{\DUtitle}[2][class-arg]{% % call \DUtitle#1{#2} if it exists: @@ -259,7 +261,6 @@ Like this. \DUtitle[dedication]{Dedication} For Docutils users \& co-developers. - \end{quote} \end{DUclass} @@ -269,7 +270,6 @@ For Docutils users \& co-developers. This is a test document, containing at least one example of each reStructuredText construct. - \end{quote} \end{DUclass} @@ -289,7 +289,6 @@ reStructuredText construct. \tableofcontents - \section{1~~~Structural Elements% \label{structural-elements}% } @@ -316,19 +315,15 @@ activated with the \texttt{-{}-section-subtitles} command line option or the Here’s a transition: - %___________________________________________________________________________ \DUtransition - It divides the section. Transitions may also occur between sections: - %___________________________________________________________________________ \DUtransition - \section{2~~~Body Elements% \label{body-elements}% } @@ -385,15 +380,12 @@ live link to PEP 258 here. } \begin{itemize} - \item A bullet list \begin{itemize} - \item Nested bullet list. \item Nested item 2. - \end{itemize} \item Item 2. @@ -401,17 +393,14 @@ live link to PEP 258 here. Paragraph 2 of item 2. \begin{itemize} - \item Nested bullet list. \item Nested item 2. \begin{itemize} - \item Third level. \item Item 2. - \end{itemize} \item Nested item 3. @@ -420,9 +409,7 @@ Paragraph 2 of item 2. % \phantomsection\label{target} % Even if this item contains a target and a comment. - \end{itemize} - \end{itemize} @@ -431,25 +418,20 @@ Paragraph 2 of item 2. } \begin{enumerate} - \item Arabic numerals. \begin{enumerate} \renewcommand{\labelenumii}{\alph{enumii})} - \item lower alpha) \begin{enumerate} \renewcommand{\labelenumiii}{(\roman{enumiii})} - \item (lower roman) \begin{enumerate} - \item upper alpha. \begin{list}{\Roman{enumv})}{\usecounter{enumv}} - \item upper roman) \end{list} \end{enumerate} @@ -461,7 +443,6 @@ Paragraph 2 of item 2. \begin{enumerate} \renewcommand{\labelenumii}{\arabic{enumii}.} \setcounter{enumii}{2} - \item Three \item Four @@ -470,7 +451,6 @@ Paragraph 2 of item 2. \begin{enumerate} \renewcommand{\labelenumii}{\Alph{enumii}.} \setcounter{enumii}{2} - \item C \item D @@ -479,7 +459,6 @@ Paragraph 2 of item 2. \begin{enumerate} \renewcommand{\labelenumii}{\roman{enumii}.} \setcounter{enumii}{2} - \item iii \item iv @@ -496,7 +475,6 @@ Paragraph 2 of item 2. Definition \item[{Term}] \leavevmode (\textbf{classifier}) - Definition paragraph 1. Definition paragraph 2. @@ -504,9 +482,7 @@ Definition paragraph 2. \item[{Term}] \leavevmode Definition -\item[{Term}] \leavevmode (\textbf{classifier one}) -(\textbf{classifier two}) - +\item[{Term}] \leavevmode (\textbf{classifier one})(\textbf{classifier two}) Definition \end{description} @@ -532,7 +508,6 @@ relative to the field marker. \DUrole{credits}{This paragraph has the \DUroletitlereference{credits} class set. (This is actually not about credits but just for ensuring that the class attribute doesn’t get stripped away.)} - \end{DUfieldlist} @@ -543,7 +518,6 @@ doesn’t get stripped away.)} For listing command-line options: \begin{DUoptionlist} - \item[-a] command-line option “a” \item[-b file] options can have arguments @@ -566,7 +540,6 @@ regardless of where it starts. \item[-1 file, -{}-one=file, -{}-two file] Multiple options with arguments. \item[/V] DOS/VMS-style options too - \end{DUoptionlist} There must be at least two spaces between the option and the @@ -642,7 +615,6 @@ Another line block, surrounded by paragraphs: Take it away, Eric the Orchestra Leader! \begin{quote} - \begin{DUlineblock}{0em} \item[] A one, two, a one two three four \item[] @@ -673,7 +645,6 @@ Take it away, Eric the Orchestra Leader! \end{DUlineblock} \item[] Singing… \end{DUlineblock} - \end{quote} A line block, like the following poem by Christian Morgenstern, can @@ -704,7 +675,6 @@ also be centre-aligned: Block quotes consist of indented body elements: \begin{quote} - My theory by A. Elk. Brackets Miss, brackets. This theory goes as follows and begins now. All brontosauruses are thin at one end, much much thicker in the middle and then thin again at the @@ -713,7 +683,6 @@ own it, and what it is too. \nopagebreak \raggedleft —Anne Elk (Miss) - \end{quote} The language of a quote (like any other object) can be specified by @@ -723,10 +692,8 @@ a class attribute: \begin{selectlanguage}{french} \begin{quote} - ReStructuredText est un langage de balisage léger utilisé notamment dans la documentation du langage Python. - \end{quote} \end{selectlanguage} @@ -1190,7 +1157,6 @@ It’s bigger than a bread box. \DUtitle[important]{Important} \begin{itemize} - \item Wash behind your ears. \item Clean up your room. @@ -1198,7 +1164,6 @@ It’s bigger than a bread box. \item Call your mother. \item Back up your data. - \end{itemize} } @@ -1256,7 +1221,6 @@ with no subsections. \DUtitle[topic]{Topic Title} This is a topic. - \end{quote} \end{DUclass} @@ -1312,11 +1276,9 @@ Compound 1, paragraph 1. Compound 1, paragraph 2. \begin{itemize} - \item Compound 1, list item one. \item Compound 1, list item two. - \end{itemize} \end{DUclass} @@ -1668,7 +1630,6 @@ body row 3 } \begin{itemize} - \item A role based on an existing role. \texttt{\DUrole{custom}{one}} \texttt{\DUrole{custom}{two}} \texttt{\DUrole{custom}{three}} @@ -1705,7 +1666,6 @@ The following works in most browsers but does not validate \end{quote} \DUrole{green}{\DUrole{sc}{\foreignlanguage{british}{British colourful text in small-caps}}}. - \end{itemize} @@ -1848,7 +1808,6 @@ not need to be tested with other writers (e.g. the HTML writer). } \begin{itemize} - \item Role names and class arguments are converted to conform to the regular expression \texttt{{[}a-z{]}{[}-a-z0-9{]}*} (letters are downcased, accents and similar decoration is stripped, non-conforming @@ -1884,7 +1843,6 @@ This is a \textsubscript{\DUrole{custom-subscript}{customized subscript text rol This is a \textsuperscript{\DUrole{custom-superscript}{customized superscript text role}} This is a \DUroletitlereference{\DUrole{custom-title-reference}{customized title-reference text role}} - \end{itemize} @@ -1908,12 +1866,10 @@ redefining the “quote” environment as “minipage”: \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} @@ -1934,13 +1890,11 @@ An “enumerated” bullet list: \begin{DUclass}{enumerateitems} \begin{itemize} - \item item \item next item \item third item - \end{itemize} \end{DUclass} @@ -1948,24 +1902,20 @@ 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 @@ -1980,11 +1930,9 @@ paragraph 1 paragraph 2 \begin{itemize} - \item bullet list \item still bullet list - \end{itemize} \end{DUclass} @@ -2114,25 +2062,19 @@ If the option list is not at the first element in the definition, it is contained in a quote \begin{quote} - \begin{DUoptionlist} - \item[-{}-help] show help \item[-v] verbose - \end{DUoptionlist} - \end{quote} \begin{description} \item[{In a definition list:}] \leavevmode \begin{DUoptionlist} - \item[-{}-help] show help \item[-v] verbose - \end{DUoptionlist} \end{description} @@ -2527,7 +2469,6 @@ The \DUroletitlereference{Latin-1 extended} Unicode block \end{longtable*} \begin{itemize} - \item The following line should not be wrapped, because it uses no-break spaces (\textbackslash{}u00a0): @@ -2539,7 +2480,6 @@ 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~ pdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-sch pdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrisch - \end{itemize} @@ -2550,16 +2490,12 @@ pdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrisch The LaTeX Info pages lists under “2.18 Special Characters” \begin{quote} - The following characters play a special role in LaTeX and are called “special printing characters”, or simply “special characters”. \begin{quote} - \# \$ \% \& \textasciitilde{} \_ \textasciicircum{} \textbackslash{} \{ \} - \end{quote} - \end{quote} The special chars verbatim: @@ -2573,7 +2509,6 @@ The special chars verbatim: However also \emph{square brackets} {[}{]} need special care. \begin{quote} - Commands with optional arguments (e.g. \texttt{\textbackslash{}item}) check if the token right after the macro name is an opening bracket. In that case the contents between that bracket and the following @@ -2582,17 +2517,14 @@ optional argument. What makes this unintuitive is the fact that the square brackets aren’t grouping characters themselves, so in your last example item{[}{[}…{]}{]} the optional argument consists of {[}… (without the closing bracket). - \end{quote} Compare the items in the following lists: \begin{itemize} - \item simple item \item {[}bracketed{]} item - \end{itemize} \begin{description} @@ -2693,7 +2625,6 @@ They can, however be used in paths and/or filenames. Handling by the LaTeX writer: \begin{itemize} - \item \texttt{\#}, \texttt{\textbackslash{}} and \texttt{\%} are escaped: \begin{DUlineblock}{0em} @@ -2715,11 +2646,9 @@ These URLs are typeset inside a LaTeX command without error. \item[] \url{A:DOS\\path\\}\DUfootnotemark{id44}{id41}{9} \end{DUlineblock} } - \end{itemize} \begin{itemize} - \item \textasciicircum{}\textasciicircum{} LaTeX’s special syntax for characters results in “strange” replacements (both with href and url). A warning is given. @@ -2742,7 +2671,6 @@ while balanced braces are suported: \item[] \url{../st{r}ange{n}ame} \item[] \url{../{st{r}ange{n}ame}} \end{DUlineblock} - \end{itemize} diff --git a/docutils/test/functional/expected/standalone_rst_xetex.tex b/docutils/test/functional/expected/standalone_rst_xetex.tex index abd59b8f8..e496a49b8 100644 --- a/docutils/test/functional/expected/standalone_rst_xetex.tex +++ b/docutils/test/functional/expected/standalone_rst_xetex.tex @@ -163,6 +163,11 @@ % subtitle (for topic/sidebar) \providecommand*{\DUsubtitle}[1]{\par\emph{#1}\smallskip} +% text mode subscript +\ifx\textsubscript\undefined + \usepackage{fixltx2e} % since 2015 loaded by default +\fi + % title for topics, admonitions, unsupported section levels, and sidebar \providecommand*{\DUtitle}[2][class-arg]{% % call \DUtitle#1{#2} if it exists: @@ -261,7 +266,6 @@ Like this. \DUtitle[dedication]{Dedication} For Docutils users \& co-developers. - \end{quote} \end{DUclass} @@ -271,7 +275,6 @@ For Docutils users \& co-developers. This is a test document, containing at least one example of each reStructuredText construct. - \end{quote} \end{DUclass} @@ -291,7 +294,6 @@ reStructuredText construct. \tableofcontents - \section{1 Structural Elements% \label{structural-elements}% } @@ -318,19 +320,15 @@ activated with the \texttt{--section-subtitles} command line option or the Here’s a transition: - %___________________________________________________________________________ \DUtransition - It divides the section. Transitions may also occur between sections: - %___________________________________________________________________________ \DUtransition - \section{2 Body Elements% \label{body-elements}% } @@ -387,15 +385,12 @@ live link to PEP 258 here. } \begin{itemize} - \item A bullet list \begin{itemize} - \item Nested bullet list. \item Nested item 2. - \end{itemize} \item Item 2. @@ -403,17 +398,14 @@ live link to PEP 258 here. Paragraph 2 of item 2. \begin{itemize} - \item Nested bullet list. \item Nested item 2. \begin{itemize} - \item Third level. \item Item 2. - \end{itemize} \item Nested item 3. @@ -422,9 +414,7 @@ Paragraph 2 of item 2. % \phantomsection\label{target} % Even if this item contains a target and a comment. - \end{itemize} - \end{itemize} @@ -433,25 +423,20 @@ Paragraph 2 of item 2. } \begin{enumerate} - \item Arabic numerals. \begin{enumerate} \renewcommand{\labelenumii}{\alph{enumii})} - \item lower alpha) \begin{enumerate} \renewcommand{\labelenumiii}{(\roman{enumiii})} - \item (lower roman) \begin{enumerate} - \item upper alpha. \begin{list}{\Roman{enumv})}{\usecounter{enumv}} - \item upper roman) \end{list} \end{enumerate} @@ -463,7 +448,6 @@ Paragraph 2 of item 2. \begin{enumerate} \renewcommand{\labelenumii}{\arabic{enumii}.} \setcounter{enumii}{2} - \item Three \item Four @@ -472,7 +456,6 @@ Paragraph 2 of item 2. \begin{enumerate} \renewcommand{\labelenumii}{\Alph{enumii}.} \setcounter{enumii}{2} - \item C \item D @@ -481,7 +464,6 @@ Paragraph 2 of item 2. \begin{enumerate} \renewcommand{\labelenumii}{\roman{enumii}.} \setcounter{enumii}{2} - \item iii \item iv @@ -498,7 +480,6 @@ Paragraph 2 of item 2. Definition \item[{Term}] \leavevmode (\textbf{classifier}) - Definition paragraph 1. Definition paragraph 2. @@ -506,9 +487,7 @@ Definition paragraph 2. \item[{Term}] \leavevmode Definition -\item[{Term}] \leavevmode (\textbf{classifier one}) -(\textbf{classifier two}) - +\item[{Term}] \leavevmode (\textbf{classifier one})(\textbf{classifier two}) Definition \end{description} @@ -534,7 +513,6 @@ relative to the field marker. \DUrole{credits}{This paragraph has the \DUroletitlereference{credits} class set. (This is actually not about credits but just for ensuring that the class attribute doesn’t get stripped away.)} - \end{DUfieldlist} @@ -545,7 +523,6 @@ doesn’t get stripped away.)} For listing command-line options: \begin{DUoptionlist} - \item[-a] command-line option “a” \item[-b file] options can have arguments @@ -568,7 +545,6 @@ regardless of where it starts. \item[-1 file, --one=file, --two file] Multiple options with arguments. \item[/V] DOS/VMS-style options too - \end{DUoptionlist} There must be at least two spaces between the option and the @@ -644,7 +620,6 @@ Another line block, surrounded by paragraphs: Take it away, Eric the Orchestra Leader! \begin{quote} - \begin{DUlineblock}{0em} \item[] A one, two, a one two three four \item[] @@ -675,7 +650,6 @@ Take it away, Eric the Orchestra Leader! \end{DUlineblock} \item[] Singing… \end{DUlineblock} - \end{quote} A line block, like the following poem by Christian Morgenstern, can @@ -706,7 +680,6 @@ also be centre-aligned: Block quotes consist of indented body elements: \begin{quote} - My theory by A. Elk. Brackets Miss, brackets. This theory goes as follows and begins now. All brontosauruses are thin at one end, much much thicker in the middle and then thin again at the @@ -715,7 +688,6 @@ own it, and what it is too. \nopagebreak \raggedleft —Anne Elk (Miss) - \end{quote} The language of a quote (like any other object) can be specified by @@ -725,10 +697,8 @@ a class attribute: \begin{selectlanguage}{french} \begin{quote} - ReStructuredText est un langage de balisage léger utilisé notamment dans la documentation du langage Python. - \end{quote} \end{selectlanguage} @@ -1192,7 +1162,6 @@ It’s bigger than a bread box. \DUtitle[important]{Important} \begin{itemize} - \item Wash behind your ears. \item Clean up your room. @@ -1200,7 +1169,6 @@ It’s bigger than a bread box. \item Call your mother. \item Back up your data. - \end{itemize} } @@ -1258,7 +1226,6 @@ with no subsections. \DUtitle[topic]{Topic Title} This is a topic. - \end{quote} \end{DUclass} @@ -1318,11 +1285,9 @@ Compound 1, paragraph 1. Compound 1, paragraph 2. \begin{itemize} - \item Compound 1, list item one. \item Compound 1, list item two. - \end{itemize} \end{DUclass} @@ -1674,7 +1639,6 @@ body row 3 } \begin{itemize} - \item A role based on an existing role. \texttt{\DUrole{custom}{one}} \texttt{\DUrole{custom}{two}} \texttt{\DUrole{custom}{three}} @@ -1711,7 +1675,6 @@ The following works in most browsers but does not validate \end{quote} \DUrole{green}{\DUrole{sc}{\foreignlanguage{english}{British colourful text in small-caps}}}. - \end{itemize} @@ -1854,7 +1817,6 @@ not need to be tested with other writers (e.g. the HTML writer). } \begin{itemize} - \item Role names and class arguments are converted to conform to the regular expression \texttt{{[}a-z{]}{[}-a-z0-9{]}*} (letters are downcased, accents and similar decoration is stripped, non-conforming @@ -1890,7 +1852,6 @@ This is a \textsubscript{\DUrole{custom-subscript}{customized subscript text rol This is a \textsuperscript{\DUrole{custom-superscript}{customized superscript text role}} This is a \DUroletitlereference{\DUrole{custom-title-reference}{customized title-reference text role}} - \end{itemize} @@ -1914,12 +1875,10 @@ redefining the “quote” environment as “minipage”: \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} @@ -1940,13 +1899,11 @@ An “enumerated” bullet list: \begin{DUclass}{enumerateitems} \begin{itemize} - \item item \item next item \item third item - \end{itemize} \end{DUclass} @@ -1954,24 +1911,20 @@ 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 @@ -1986,11 +1939,9 @@ paragraph 1 paragraph 2 \begin{itemize} - \item bullet list \item still bullet list - \end{itemize} \end{DUclass} @@ -2120,25 +2071,19 @@ If the option list is not at the first element in the definition, it is contained in a quote \begin{quote} - \begin{DUoptionlist} - \item[--help] show help \item[-v] verbose - \end{DUoptionlist} - \end{quote} \begin{description} \item[{In a definition list:}] \leavevmode \begin{DUoptionlist} - \item[--help] show help \item[-v] verbose - \end{DUoptionlist} \end{description} @@ -2533,7 +2478,6 @@ The \DUroletitlereference{Latin-1 extended} Unicode block \end{longtable*} \begin{itemize} - \item The following line should not be wrapped, because it uses no-break spaces (\textbackslash{}u00a0): @@ -2545,7 +2489,6 @@ 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 pdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-schpdn\-derd\-mdtd\-ri\-sch pdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrisch - \end{itemize} @@ -2556,16 +2499,12 @@ pdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrischpdnderdmdtdrisch The LaTeX Info pages lists under “2.18 Special Characters” \begin{quote} - The following characters play a special role in LaTeX and are called “special printing characters”, or simply “special characters”. \begin{quote} - \# \$ \% \& \textasciitilde{} \_ \textasciicircum{} \textbackslash{} \{ \} - \end{quote} - \end{quote} The special chars verbatim: @@ -2579,7 +2518,6 @@ The special chars verbatim: However also \emph{square brackets} {[}{]} need special care. \begin{quote} - Commands with optional arguments (e.g. \texttt{\textbackslash{}item}) check if the token right after the macro name is an opening bracket. In that case the contents between that bracket and the following @@ -2588,17 +2526,14 @@ optional argument. What makes this unintuitive is the fact that the square brackets aren’t grouping characters themselves, so in your last example item{[}{[}…{]}{]} the optional argument consists of {[}… (without the closing bracket). - \end{quote} Compare the items in the following lists: \begin{itemize} - \item simple item \item {[}bracketed{]} item - \end{itemize} \begin{description} @@ -2699,7 +2634,6 @@ They can, however be used in paths and/or filenames. Handling by the LaTeX writer: \begin{itemize} - \item \texttt{\#}, \texttt{\textbackslash{}} and \texttt{\%} are escaped: \begin{DUlineblock}{0em} @@ -2721,11 +2655,9 @@ These URLs are typeset inside a LaTeX command without error. \item[] \url{A:DOS\\path\\}\DUfootnotemark{id46}{id43}{10} \end{DUlineblock} } - \end{itemize} \begin{itemize} - \item \textasciicircum{}\textasciicircum{} LaTeX’s special syntax for characters results in “strange” replacements (both with href and url). A warning is given. @@ -2748,7 +2680,6 @@ while balanced braces are suported: \item[] \url{../st{r}ange{n}ame} \item[] \url{../{st{r}ange{n}ame}} \end{DUlineblock} - \end{itemize} diff --git a/docutils/test/test_writers/test_latex2e.py b/docutils/test/test_writers/test_latex2e.py index 0e9a15130..159f38cd9 100755 --- a/docutils/test/test_writers/test_latex2e.py +++ b/docutils/test/test_writers/test_latex2e.py @@ -37,9 +37,6 @@ def suite(): head_template = string.Template( r"""$head_prefix% generated by Docutils <http://docutils.sourceforge.net/> -\ifx\textsubscript\undefined - \usepackage{fixltx2e} % since 2015 loaded by default -\fi \usepackage{cmap} % fix search and cut-and-paste in Acrobat $requirements %%% Custom LaTeX preamble @@ -203,15 +200,11 @@ head_template.substitute(dict(parts, \DUtitle[contents]{Table of Contents} \begin{list}{}{} - \item \hyperref[title-1]{Title 1} \begin{list}{}{} - \item \hyperref[title-2]{Title 2} - \end{list} - \end{list} @@ -265,7 +258,6 @@ paragraph % \DUfootnotetext{id3}{id3}{3}{ \begin{enumerate} - \item enumeration \end{enumerate} } @@ -291,7 +283,6 @@ head_template.substitute(dict(parts, \tableofcontents - \section{first section% \label{first-section}% } @@ -318,7 +309,6 @@ head_template.substitute(dict(parts, \tableofcontents - \section{1~~~first section% \label{first-section}% } @@ -455,40 +445,32 @@ totest['enumerated_lists'] = [ # expected output head + r""" \begin{enumerate} - \item Item 1. \item Second to the previous item this one will explain \end{enumerate} \begin{quote} - \begin{enumerate} \renewcommand{\labelenumi}{\alph{enumi})} - \item nothing. \item or some other. \end{enumerate} - \end{quote} \begin{enumerate} \setcounter{enumi}{2} - \item Third is \end{enumerate} \begin{quote} - \begin{enumerate} \renewcommand{\labelenumi}{(\Roman{enumi})} - \item having pre and postfixes \item in roman numerals. \end{enumerate} - \end{quote} \end{document} @@ -838,9 +820,7 @@ totest['bracket_protection'] = [ """, head + r""" \begin{itemize} - \item {[}no option{]} to this item - \end{itemize} \end{document} |
