From a58c4e1ca6bb97836fee8cad7e6059995b884441 Mon Sep 17 00:00:00 2001 From: milde Date: Thu, 26 Jan 2012 13:08:04 +0000 Subject: [PATCH] Do not use ``\\\\section*``-macros to suppress LaTeX section numbering. Use ``\\\\DUtitle`` for section levels not supported by LaTeX. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@7325 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- HISTORY.txt | 5 +- docutils/writers/latex2e/__init__.py | 105 +++---- test/functional/expected/cyrillic.tex | 19 +- test/functional/expected/standalone_rst_latex.tex | 355 +++++++--------------- test/functional/expected/standalone_rst_xetex.tex | 351 +++++++-------------- test/functional/expected/xetex-cyrillic.tex | 19 +- test/functional/input/data/urls.txt | 2 +- test/functional/input/standalone_rst_latex.txt | 1 + test/functional/input/standalone_rst_xetex.txt | 4 +- test/test_writers/test_latex2e.py | 57 ++-- 10 files changed, 292 insertions(+), 626 deletions(-) diff --git a/HISTORY.txt b/HISTORY.txt index 835a7e67c..bde1fb7fd 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -21,7 +21,7 @@ Changes Since 0.8.1 - New reStructuredText "code" role and directive and "code" option of the "include" directive with syntax highlighting by Pygments_. - Fix parse_option_marker for option arguments containing ``=``. - + .. _Pygments: http://pygments.org/ * setup.py @@ -60,6 +60,9 @@ Changes Since 0.8.1 - Support the `abbreviation` and `acronym` standard roles. - Record only files required to generate the LaTeX source as dependencies. - Fix handling of missing stylesheets. + - Use ``\setcounter{secnumdepth}{0}`` instead of ``*``-versions + when suppressing LaTeX section numbering. + - Use ``\DUtitle`` for unsupported section levels * docutils/writers/html4css1/__init__.py diff --git a/docutils/writers/latex2e/__init__.py b/docutils/writers/latex2e/__init__.py index f0a59402d..8e4f55da5 100644 --- a/docutils/writers/latex2e/__init__.py +++ b/docutils/writers/latex2e/__init__.py @@ -19,6 +19,10 @@ import time import re import string import urllib +try: + import roman +except ImportError: + import docutils.utils.roman as roman from docutils import frontend, nodes, languages, writers, utils, io from docutils.error_reporting import SafeString from docutils.transforms import writer_aux @@ -648,7 +652,7 @@ PreambleCmds.titlereference = r""" \providecommand*{\DUroletitlereference}[1]{\textsl{#1}}""" PreambleCmds.title = r""" -% title for topics, admonitions and sidebar +% title for topics, admonitions, unsupported section levels, and sidebar \providecommand*{\DUtitle}[2][class-arg]{% % call \DUtitle#1{#2} if it exists: \ifcsname DUtitle#1\endcsname% @@ -696,12 +700,10 @@ class DocumentClass(object): The name depends on the specific document class. Level is 1,2,3..., as level 0 is the title. """ - if level <= len(self.sections): return self.sections[level-1] - else: - return self.sections[-1] - + else: # unsupported levels + return 'DUtitle[section%s]' % roman.toRoman(level) class Table(object): """Manage a table while traversing. @@ -1127,33 +1129,32 @@ class LaTeXTranslator(nodes.NodeVisitor): ## len(self.d_class.sections)) # Section numbering - # TODO: use \secnumdepth instead of starred commands - ## if self.settings.sectnum_xform: # section numbering by Docutils - ## sectnum_depth = 0 - ## else: - if not self.settings.sectnum_xform: # section numbering by LaTeX: - # sectnum_depth: - # None "sectnum" directive without depth arg -> LaTeX default - # 0 no "sectnum" directive -> no section numbers - # else value of the "depth" argument: translate to LaTeX level - # -1 part (0 with "article" document class) - # 0 chapter (missing in "article" document class) - # 1 section - # 2 subsection - # 3 subsubsection - # 4 paragraph - # 5 subparagraph - if settings.sectnum_depth is not None: + if not self.settings.sectnum_xform: # section numbering by Docutils + PreambleCmds.secnumdepth = r'\setcounter{secnumdepth}{0}' + else: # section numbering by LaTeX: + secnumdepth = settings.sectnum_depth + # Possible values of settings.sectnum_depth: + # None "sectnum" directive without depth arg -> LaTeX default + # 0 no "sectnum" directive -> no section numbers + # >0 value of "depth" argument -> translate to LaTeX levels: + # -1 part (0 with "article" document class) + # 0 chapter (missing in "article" document class) + # 1 section + # 2 subsection + # 3 subsubsection + # 4 paragraph + # 5 subparagraph + if secnumdepth is not None: # limit to supported levels - sectnum_depth = min(settings.sectnum_depth, - len(self.d_class.sections)) + secnumdepth = min(secnumdepth, len(self.d_class.sections)) # adjust to document class and use_part_section settings if 'chapter' in self.d_class.sections: - sectnum_depth -= 1 + secnumdepth -= 1 if self.d_class.sections[0] == 'part': - sectnum_depth -= 1 - self.requirements['sectnum_depth'] = ( - r'\setcounter{secnumdepth}{%d}' % sectnum_depth) + secnumdepth -= 1 + PreambleCmds.secnumdepth = \ + r'\setcounter{secnumdepth}{%d}' % secnumdepth + # start with specified number: if (hasattr(settings, 'sectnum_start') and settings.sectnum_start != 1): @@ -1164,7 +1165,6 @@ class LaTeXTranslator(nodes.NodeVisitor): ## settings.sectnum_prefix ## settings.sectnum_suffix - # Auxiliary Methods # ----------------- @@ -2850,18 +2850,6 @@ class LaTeXTranslator(nodes.NodeVisitor): node.walkabout(self) self._thead_depth -= 1 - def bookmark(self, node): - """Return label and pdfbookmark string for titles.""" - result = [''] - if self.settings.sectnum_xform: # "starred" section cmd - # add to the toc and pdfbookmarks - section_name = self.d_class.section(max(self.section_level, 1)) - section_title = self.encode(node.astext()) - result.append(r'\addcontentsline{toc}{%s}{%s}' % - (section_name, section_title)) - result += self.ids_to_labels(node.parent, set_anchor=False) - return '%\n '.join(result) + '%\n' - def visit_title(self, node): """Append section and other titles.""" # Document title @@ -2886,26 +2874,31 @@ class LaTeXTranslator(nodes.NodeVisitor): self.context.append('') # Section title else: - self.out.append('\n\n') - self.out.append('%' + '_' * 75) - self.out.append('\n\n') - # + self.requirements['secnumdepth'] = PreambleCmds.secnumdepth section_name = self.d_class.section(self.section_level) - section_star = '' - pdfanchor = '' - # number sections? - if (self.settings.sectnum_xform # numbering by Docutils - or (self.section_level > len(self.d_class.sections))): - section_star = '*' - pdfanchor = '\\phantomsection%\n ' - self.out.append(r'\%s%s{%s' % - (section_name, section_star, pdfanchor)) + self.out.append('\n\n') # System messages heading in red: if ('system-messages' in node.parent['classes']): self.requirements['color'] = PreambleCmds.color - self.out.append('\color{red}') + section_title = self.encode(node.astext()) + self.out.append(r'\%s[%s]{\color{red}' % ( + section_name,section_title)) + else: + self.out.append(r'\%s{' % section_name) + if self.section_level > len(self.d_class.sections): + # section level not supported by LaTeX + self.fallbacks['title'] = PreambleCmds.title + # self.out.append('\\phantomsection%\n ') # label and ToC entry: - self.context.append(self.bookmark(node) + '}\n') + bookmark = [''] + # add sections with unsupported level to toc and pdfbookmarks? + ## if self.section_level > len(self.d_class.sections): + ## section_title = self.encode(node.astext()) + ## bookmark.append(r'\addcontentsline{toc}{%s}{%s}' % + ## (section_name, section_title)) + bookmark += self.ids_to_labels(node.parent, set_anchor=False) + self.context.append('%\n '.join(bookmark) + '%\n}\n') + # MAYBE postfix paragraph and subparagraph with \leavemode to # ensure floats stay in the section and text starts on a new line. diff --git a/test/functional/expected/cyrillic.tex b/test/functional/expected/cyrillic.tex index d0d251b5c..892d4d093 100644 --- a/test/functional/expected/cyrillic.tex +++ b/test/functional/expected/cyrillic.tex @@ -6,6 +6,7 @@ \usepackage[T1,T2A]{fontenc} \usepackage[utf8]{inputenc} \usepackage[english,russian]{babel} +\setcounter{secnumdepth}{0} %%% Custom LaTeX preamble % PDF Standard Fonts @@ -32,33 +33,21 @@ \begin{document} -%___________________________________________________________________________ - -\section*{\phantomsection% - Заголовок% - \addcontentsline{toc}{section}{Заголовок}% +\section{Заголовок% \label{id1}% } первый пример: \glqq{}Здравствуй, мир!\grqq{} -%___________________________________________________________________________ - -\section*{\phantomsection% - Title% - \addcontentsline{toc}{section}{Title}% +\section{Title% \label{title}% } \otherlanguage{english}{first example: \glqq{}Hello world\grqq{}.} -%___________________________________________________________________________ - -\section*{\phantomsection% - Notes% - \addcontentsline{toc}{section}{Notes}% +\section{Notes% \label{notes}% } diff --git a/test/functional/expected/standalone_rst_latex.tex b/test/functional/expected/standalone_rst_latex.tex index df158bb2a..4a217eec5 100644 --- a/test/functional/expected/standalone_rst_latex.tex +++ b/test/functional/expected/standalone_rst_latex.tex @@ -16,6 +16,7 @@ \usepackage{graphicx} \usepackage{multirow} \usepackage{pifont} +\setcounter{secnumdepth}{0} \usepackage{longtable,ltcaption,array} \setlength{\extrarowheight}{2pt} \newlength{\DUtablewidth} % internal use in tables @@ -149,7 +150,7 @@ % subtitle (for topic/sidebar) \providecommand*{\DUsubtitle}[2][class-arg]{\par\emph{#2}\smallskip} -% title for topics, admonitions and sidebar +% title for topics, admonitions, unsupported section levels, and sidebar \providecommand*{\DUtitle}[2][class-arg]{% % call \DUtitle#1{#2} if it exists: \ifcsname DUtitle#1\endcsname% @@ -280,20 +281,12 @@ reStructuredText construct. -%___________________________________________________________________________ - -\section*{\phantomsection% - 1~~~Structural Elements% - \addcontentsline{toc}{section}{1~~~Structural Elements}% +\section{1~~~Structural Elements% \label{structural-elements}% } -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 1.1~~~Section Title% - \addcontentsline{toc}{subsection}{1.1~~~Section Title}% +\subsection{1.1~~~Section Title% \label{section-title}% } \subsubsection*{Section Subtitle} @@ -303,20 +296,12 @@ activated with the \texttt{-{}-section-subtitles} command line option or the \texttt{sectsubtitle-xform} configuration value. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 1.2~~~Empty Section% - \addcontentsline{toc}{subsection}{1.2~~~Empty Section}% +\subsection{1.2~~~Empty Section% \label{empty-section}% } -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 1.3~~~Transitions% - \addcontentsline{toc}{subsection}{1.3~~~Transitions}% +\subsection{1.3~~~Transitions% \label{transitions}% } @@ -335,31 +320,19 @@ It divides the section. Transitions may also occur between sections: -%___________________________________________________________________________ - -\section*{\phantomsection% - 2~~~Body Elements% - \addcontentsline{toc}{section}{2~~~Body Elements}% +\section{2~~~Body Elements% \label{body-elements}% } -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.1~~~Paragraphs% - \addcontentsline{toc}{subsection}{2.1~~~Paragraphs}% +\subsection{2.1~~~Paragraphs% \label{paragraphs}% } A paragraph. -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.1.1~~~Inline Markup% - \addcontentsline{toc}{subsubsection}{2.1.1~~~Inline Markup}% +\subsubsection{2.1.1~~~Inline Markup% \label{inline-markup}% } @@ -398,11 +371,7 @@ If the \texttt{-{}-pep-references} option was supplied, there should be a live link to PEP 258 here. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.2~~~Bullet Lists% - \addcontentsline{toc}{subsection}{2.2~~~Bullet Lists}% +\subsection{2.2~~~Bullet Lists% \label{bullet-lists}% } % @@ -448,11 +417,7 @@ Paragraph 2 of item 2. \end{itemize} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.3~~~Enumerated Lists% - \addcontentsline{toc}{subsection}{2.3~~~Enumerated Lists}% +\subsection{2.3~~~Enumerated Lists% \label{enumerated-lists}% } \newcounter{listcnt0} @@ -540,11 +505,7 @@ Paragraph 2 of item 2. \end{list} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.4~~~Definition Lists% - \addcontentsline{toc}{subsection}{2.4~~~Definition Lists}% +\subsection{2.4~~~Definition Lists% \label{definition-lists}% } % @@ -569,11 +530,7 @@ Definition \end{description} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.5~~~Field Lists% - \addcontentsline{toc}{subsection}{2.5~~~Field Lists}% +\subsection{2.5~~~Field Lists% \label{field-lists}% } % @@ -597,11 +554,7 @@ doesn't get stripped away.)} \end{DUfieldlist} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.6~~~Option Lists% - \addcontentsline{toc}{subsection}{2.6~~~Option Lists}% +\subsection{2.6~~~Option Lists% \label{option-lists}% } @@ -638,11 +591,7 @@ There must be at least two spaces between the option and the description. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.7~~~Literal Blocks% - \addcontentsline{toc}{subsection}{2.7~~~Literal Blocks}% +\subsection{2.7~~~Literal Blocks% \label{literal-blocks}% } @@ -667,11 +616,7 @@ Or they can be quoted without indentation: \end{quote} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.8~~~Line Blocks% - \addcontentsline{toc}{subsection}{2.8~~~Line Blocks}% +\subsection{2.8~~~Line Blocks% \label{line-blocks}% } @@ -767,11 +712,7 @@ also be centre-aligned: \end{DUlineblock} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.9~~~Block Quotes% - \addcontentsline{toc}{subsection}{2.9~~~Block Quotes}% +\subsection{2.9~~~Block Quotes% \label{block-quotes}% } @@ -803,11 +744,7 @@ notamment dans la documentation du langage Python. \end{quote} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.10~~~Doctest Blocks% - \addcontentsline{toc}{subsection}{2.10~~~Doctest Blocks}% +\subsection{2.10~~~Doctest Blocks% \label{doctest-blocks}% } % @@ -820,11 +757,7 @@ Python-specific~usage~examples;~begun~with~">{}>{}>"\\ \end{quote} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.11~~~Footnotes% - \addcontentsline{toc}{subsection}{2.11~~~Footnotes}% +\subsection{2.11~~~Footnotes% \label{footnotes}% } % @@ -868,11 +801,7 @@ nonexistent footnote:% } -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.12~~~Citations% - \addcontentsline{toc}{subsection}{2.12~~~Citations}% +\subsection{2.12~~~Citations% \label{citations}% } \begin{figure}[b]\raisebox{1em}{\hypertarget{cit2002}{}}[CIT2002] @@ -886,11 +815,7 @@ Here's a reference to the above, \hyperlink{cit2002}{[CIT2002]}, and a % citation. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.13~~~Targets% - \addcontentsline{toc}{subsection}{2.13~~~Targets}% +\subsection{2.13~~~Targets% \label{targets}% \label{another-target}% } @@ -914,11 +839,7 @@ Here's a % error. -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.13.1~~~Duplicate Target Names% - \addcontentsline{toc}{subsubsection}{2.13.1~~~Duplicate Target Names}% +\subsubsection{2.13.1~~~Duplicate Target Names% \label{duplicate-target-names}% } @@ -927,11 +848,7 @@ generate ``info'' (level-1) system messages. Duplicate names in explicit targets will generate ``warning'' (level-2) system messages. -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.13.2~~~Duplicate Target Names% - \addcontentsline{toc}{subsubsection}{2.13.2~~~Duplicate Target Names}% +\subsubsection{2.13.2~~~Duplicate Target Names% \label{id21}% } @@ -941,11 +858,7 @@ this: % \raisebox{1em}{\hypertarget{id52}{}}\hyperlink{id51}{\textbf{\color{red}`Duplicate Target Names`\_}}), an error is generated. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.14~~~Directives% - \addcontentsline{toc}{subsection}{2.14~~~Directives}% +\subsection{2.14~~~Directives% \label{directives}% } @@ -955,11 +868,7 @@ others, please see \url{http://docutils.sourceforge.net/docs/ref/rst/directives.html}. -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.1~~~Document Parts% - \addcontentsline{toc}{subsubsection}{2.14.1~~~Document Parts}% +\subsubsection{2.14.1~~~Document Parts% \label{document-parts}% } @@ -968,11 +877,7 @@ An example of the ``contents'' directive can be seen above this section document (a document-wide \hyperref[table-of-contents]{table of contents}). -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.2~~~Images and Figures% - \addcontentsline{toc}{subsubsection}{2.14.2~~~Images and Figures}% +\subsubsection{2.14.2~~~Images and Figures% \label{images-and-figures}% } @@ -1106,11 +1011,7 @@ This paragraph might flow around the figure. The specific behavior depends upon the style sheet and the browser or rendering software used. -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.3~~~Admonitions% - \addcontentsline{toc}{subsubsection}{2.14.3~~~Admonitions}% +\subsubsection{2.14.3~~~Admonitions% \label{admonitions}% } @@ -1186,11 +1087,7 @@ You can make up your own admonition too. } -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.4~~~Topics, Sidebars, and Rubrics% - \addcontentsline{toc}{subsubsection}{2.14.4~~~Topics, Sidebars, and Rubrics}% +\subsubsection{2.14.4~~~Topics, Sidebars, and Rubrics% \label{topics-sidebars-and-rubrics}% } @@ -1228,11 +1125,7 @@ Topics and rubrics can be used at places where a \hyperref[section-title]{sectio allowed (e.g. inside a directive). -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.5~~~Target Footnotes% - \addcontentsline{toc}{subsubsection}{2.14.5~~~Target Footnotes}% +\subsubsection{2.14.5~~~Target Footnotes% \label{target-footnotes}% } % @@ -1257,22 +1150,14 @@ allowed (e.g. inside a directive). } -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.6~~~Replacement Text% - \addcontentsline{toc}{subsubsection}{2.14.6~~~Replacement Text}% +\subsubsection{2.14.6~~~Replacement Text% \label{replacement-text}% } I recommend you try \href{http://www.python.org/}{Python, \emph{the} best language around}\DUfootnotemark{id32}{id29}{5}. -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.7~~~Compound Paragraph% - \addcontentsline{toc}{subsubsection}{2.14.7~~~Compound Paragraph}% +\subsubsection{2.14.7~~~Compound Paragraph% \label{compound-paragraph}% } @@ -1349,11 +1234,7 @@ Compound 7, a paragraph after the table. Compound 7, another paragraph. -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.8~~~Parsed Literal Blocks% - \addcontentsline{toc}{subsubsection}{2.14.8~~~Parsed Literal Blocks}% +\subsubsection{2.14.8~~~Parsed Literal Blocks% \label{parsed-literal-blocks}% } % @@ -1368,11 +1249,7 @@ text},~footnotes\DUfootnotemark{id22}{id8}{1},~% \end{quote} -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.9~~~Code% - \addcontentsline{toc}{subsubsection}{2.14.9~~~Code}% +\subsubsection{2.14.9~~~Code% \label{code}% } @@ -1421,11 +1298,7 @@ as a code block, here the rst file \texttt{header\_footer.txt} with line numbers \end{quote} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.15~~~Substitution Definitions% - \addcontentsline{toc}{subsection}{2.15~~~Substitution Definitions}% +\subsection{2.15~~~Substitution Definitions% \label{substitution-definitions}% } @@ -1434,11 +1307,7 @@ An inline image (\includegraphics{../../../docs/user/rst/images/biohazard.png}) (Substitution definitions are not visible in the HTML source.) -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.16~~~Comments% - \addcontentsline{toc}{subsection}{2.16~~~Comments}% +\subsection{2.16~~~Comments% \label{comments}% } @@ -1455,11 +1324,7 @@ Here's one: (View the HTML source to see the comment.) -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.17~~~Raw text% - \addcontentsline{toc}{subsection}{2.17~~~Raw text}% +\subsection{2.17~~~Raw text% \label{raw-text}% } @@ -1478,11 +1343,7 @@ This is the \DUrole{myrawroleclass}{fourth test} with myrawroleclass set. Fifth test in LaTeX.\\Line two. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.18~~~Container% - \addcontentsline{toc}{subsection}{2.18~~~Container}% +\subsection{2.18~~~Container% \label{container}% } @@ -1494,11 +1355,7 @@ paragraph 2 % .. include:: data/header_footer.txt -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.19~~~Colspanning tables% - \addcontentsline{toc}{subsection}{2.19~~~Colspanning tables}% +\subsection{2.19~~~Colspanning tables% \label{colspanning-tables}% } @@ -1576,11 +1433,7 @@ True \end{longtable*} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.20~~~Rowspanning tables% - \addcontentsline{toc}{subsection}{2.20~~~Rowspanning tables}% +\subsection{2.20~~~Rowspanning tables% \label{rowspanning-tables}% } @@ -1639,11 +1492,7 @@ body row 3 \end{longtable*} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.21~~~Custom Roles% - \addcontentsline{toc}{subsection}{2.21~~~Custom Roles}% +\subsection{2.21~~~Custom Roles% \label{custom-roles}% } % @@ -1688,11 +1537,7 @@ The following works in most browsers but does not validate \end{itemize} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.22~~~Mathematics% - \addcontentsline{toc}{subsection}{2.22~~~Mathematics}% +\subsection{2.22~~~Mathematics% \label{mathematics}% } @@ -1818,11 +1663,7 @@ HTML writers with \texttt{-{}-math-output=MathML}): \end{cases} \end{equation*} -%___________________________________________________________________________ - -\section*{\phantomsection% - 3~~~Tests for the LaTeX writer% - \addcontentsline{toc}{section}{3~~~Tests for the LaTeX writer}% +\section{3~~~Tests for the LaTeX writer% \label{tests-for-the-latex-writer}% } @@ -1830,11 +1671,7 @@ Test syntax elements which may cause trouble for the LaTeX writer but might not need to be tested with other writers (e.g. the HTML writer). -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 3.1~~~Custom Roles in LaTeX% - \addcontentsline{toc}{subsection}{3.1~~~Custom Roles in LaTeX}% +\subsection{3.1~~~Custom Roles in LaTeX% \label{custom-roles-in-latex}% } % @@ -1878,11 +1715,7 @@ This is a \DUroletitlereference{\DUrole{custom-title-reference}{customized title \end{itemize} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 3.2~~~More Tables% - \addcontentsline{toc}{subsection}{3.2~~~More Tables}% +\subsection{3.2~~~More Tables% \label{more-tables}% } @@ -1946,11 +1779,7 @@ Short multicolumn 4 % This file is used by the standalone_rst_latex test. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 3.3~~~Option lists% - \addcontentsline{toc}{subsection}{3.3~~~Option lists}% +\subsection{3.3~~~Option lists% \label{id23}% } @@ -1986,11 +1815,7 @@ is contained in a quote \end{description} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 3.4~~~Monospaced non-alphanumeric characters% - \addcontentsline{toc}{subsection}{3.4~~~Monospaced non-alphanumeric characters}% +\subsection{3.4~~~Monospaced non-alphanumeric characters% \label{monospaced-non-alphanumeric-characters}% } @@ -2006,11 +1831,7 @@ The two lines of non-alphanumeric characters should both have the same width as the third line. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 3.5~~~Non-ASCII characters% - \addcontentsline{toc}{subsection}{3.5~~~Non-ASCII characters}% +\subsection{3.5~~~Non-ASCII characters% \label{non-ascii-characters}% } @@ -2424,11 +2245,7 @@ to the document options or use a different font package. \end{itemize} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 3.6~~~Encoding special chars% - \addcontentsline{toc}{subsection}{3.6~~~Encoding special chars}% +\subsection{3.6~~~Encoding special chars% \label{encoding-special-chars}% } @@ -2497,11 +2314,7 @@ greater-than and bar, < | >, except for typewriter font \DUroletitlereference{cm \end{quote} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 3.7~~~Hyperlinks and -targets% - \addcontentsline{toc}{subsection}{3.7~~~Hyperlinks and -targets}% +\subsection{3.7~~~Hyperlinks and -targets% \label{hyperlinks-and-targets}% } @@ -2546,17 +2359,13 @@ See \hyperref[hypertarget-in-plain-text]{hypertarget in plain text}, \hyperref[image-label]{image label}. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 3.8~~~External references% - \addcontentsline{toc}{subsection}{3.8~~~External references}% +\subsection{3.8~~~External references% \label{external-references}% } Long URLs should be wrapped in the PDF. This can be achieved with the url command which is used by the LaTeX writer -wheneve the content (name) of a reference node equals the link URL. +whenever the content (name) of a reference node equals the link URL. % \begin{description} \item[{Example:}] \leavevmode @@ -2634,17 +2443,63 @@ while balanced braces are suported: \end{itemize} + +\subsection{3.9~~~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$% + \label{emphasized-h2o-and-x-2}% +} + + +\subsubsection{3.9.2~~~Substitutions work% + \label{substitutions-fail}% +} + + +\subsection{3.10~~~Deeply nested sections% + \label{deeply-nested-sections}% +} + +In LaTeX and HTML, + + +\subsubsection{3.10.1~~~Level 3% + \label{level-3}% +} + +nested sections + + +\paragraph{3.10.1.1~~~level 4% + \label{level-4}% +} + +reach at some level + + +\subparagraph{3.10.1.1.1~~~level 5% + \label{level-5}% +} + +(depending on the document class) + + +\DUtitle[sectionVI]{3.10.1.1.1.1~~~level 6% + \label{level-6}% +} + +an unsupported level. + % unusual combinations (from newlatex, for interactive testing) % .. include:: data/latex.txt % Preface for System Messages: -%___________________________________________________________________________ - -\section*{\phantomsection% - 4~~~Error Handling% - \addcontentsline{toc}{section}{4~~~Error Handling}% +\section{4~~~Error Handling% \label{error-handling}% } @@ -2656,11 +2511,7 @@ section, ``Docutils System Messages'': % section should be added by Docutils automatically -%___________________________________________________________________________ - -\section*{\phantomsection% - \color{red}Docutils System Messages% - \addcontentsline{toc}{section}{Docutils System Messages}% +\section[Docutils System Messages]{\color{red}Docutils System Messages% } \DUadmonition[system-message]{ diff --git a/test/functional/expected/standalone_rst_xetex.tex b/test/functional/expected/standalone_rst_xetex.tex index c3d35cb97..2cd742178 100644 --- a/test/functional/expected/standalone_rst_xetex.tex +++ b/test/functional/expected/standalone_rst_xetex.tex @@ -13,6 +13,7 @@ \floatplacement{figure}{H} % place figures here definitely \usepackage{graphicx} \usepackage{multirow} +\setcounter{secnumdepth}{0} \usepackage{longtable,ltcaption,array} \setlength{\extrarowheight}{2pt} \newlength{\DUtablewidth} % internal use in tables @@ -148,7 +149,7 @@ % subtitle (for topic/sidebar) \providecommand*{\DUsubtitle}[2][class-arg]{\par\emph{#2}\smallskip} -% title for topics, admonitions and sidebar +% title for topics, admonitions, unsupported section levels, and sidebar \providecommand*{\DUtitle}[2][class-arg]{% % call \DUtitle#1{#2} if it exists: \ifcsname DUtitle#1\endcsname% @@ -279,20 +280,12 @@ reStructuredText construct. -%___________________________________________________________________________ - -\section*{\phantomsection% - 1   Structural Elements% - \addcontentsline{toc}{section}{1   Structural Elements}% +\section{1   Structural Elements% \label{structural-elements}% } -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 1.1   Section Title% - \addcontentsline{toc}{subsection}{1.1   Section Title}% +\subsection{1.1   Section Title% \label{section-title}% } \subsubsection*{Section Subtitle} @@ -302,20 +295,12 @@ activated with the \texttt{--section-subtitles} command line option or the \texttt{sectsubtitle-xform} configuration value. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 1.2   Empty Section% - \addcontentsline{toc}{subsection}{1.2   Empty Section}% +\subsection{1.2   Empty Section% \label{empty-section}% } -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 1.3   Transitions% - \addcontentsline{toc}{subsection}{1.3   Transitions}% +\subsection{1.3   Transitions% \label{transitions}% } @@ -334,31 +319,19 @@ It divides the section. Transitions may also occur between sections: -%___________________________________________________________________________ - -\section*{\phantomsection% - 2   Body Elements% - \addcontentsline{toc}{section}{2   Body Elements}% +\section{2   Body Elements% \label{body-elements}% } -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.1   Paragraphs% - \addcontentsline{toc}{subsection}{2.1   Paragraphs}% +\subsection{2.1   Paragraphs% \label{paragraphs}% } A paragraph. -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.1.1   Inline Markup% - \addcontentsline{toc}{subsubsection}{2.1.1   Inline Markup}% +\subsubsection{2.1.1   Inline Markup% \label{inline-markup}% } @@ -397,11 +370,7 @@ If the \texttt{--pep-references} option was supplied, there should be a live link to PEP 258 here. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.2   Bullet Lists% - \addcontentsline{toc}{subsection}{2.2   Bullet Lists}% +\subsection{2.2   Bullet Lists% \label{bullet-lists}% } % @@ -447,11 +416,7 @@ Paragraph 2 of item 2. \end{itemize} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.3   Enumerated Lists% - \addcontentsline{toc}{subsection}{2.3   Enumerated Lists}% +\subsection{2.3   Enumerated Lists% \label{enumerated-lists}% } \newcounter{listcnt0} @@ -539,11 +504,7 @@ Paragraph 2 of item 2. \end{list} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.4   Definition Lists% - \addcontentsline{toc}{subsection}{2.4   Definition Lists}% +\subsection{2.4   Definition Lists% \label{definition-lists}% } % @@ -568,11 +529,7 @@ Definition \end{description} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.5   Field Lists% - \addcontentsline{toc}{subsection}{2.5   Field Lists}% +\subsection{2.5   Field Lists% \label{field-lists}% } % @@ -596,11 +553,7 @@ doesn't get stripped away.)} \end{DUfieldlist} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.6   Option Lists% - \addcontentsline{toc}{subsection}{2.6   Option Lists}% +\subsection{2.6   Option Lists% \label{option-lists}% } @@ -637,11 +590,7 @@ There must be at least two spaces between the option and the description. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.7   Literal Blocks% - \addcontentsline{toc}{subsection}{2.7   Literal Blocks}% +\subsection{2.7   Literal Blocks% \label{literal-blocks}% } @@ -666,11 +615,7 @@ Or they can be quoted without indentation: \end{quote} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.8   Line Blocks% - \addcontentsline{toc}{subsection}{2.8   Line Blocks}% +\subsection{2.8   Line Blocks% \label{line-blocks}% } @@ -766,11 +711,7 @@ also be centre-aligned: \end{DUlineblock} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.9   Block Quotes% - \addcontentsline{toc}{subsection}{2.9   Block Quotes}% +\subsection{2.9   Block Quotes% \label{block-quotes}% } @@ -802,11 +743,7 @@ notamment dans la documentation du langage Python. \end{quote} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.10   Doctest Blocks% - \addcontentsline{toc}{subsection}{2.10   Doctest Blocks}% +\subsection{2.10   Doctest Blocks% \label{doctest-blocks}% } % @@ -819,11 +756,7 @@ Python-specific~usage~examples;~begun~with~">>>"\\ \end{quote} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.11   Footnotes% - \addcontentsline{toc}{subsection}{2.11   Footnotes}% +\subsection{2.11   Footnotes% \label{footnotes}% } % @@ -867,11 +800,7 @@ nonexistent footnote:% } -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.12   Citations% - \addcontentsline{toc}{subsection}{2.12   Citations}% +\subsection{2.12   Citations% \label{citations}% } \begin{figure}[b]\raisebox{1em}{\hypertarget{cit2002}{}}[CIT2002] @@ -885,11 +814,7 @@ Here's a reference to the above, \hyperlink{cit2002}{[CIT2002]}, and a % citation. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.13   Targets% - \addcontentsline{toc}{subsection}{2.13   Targets}% +\subsection{2.13   Targets% \label{targets}% \label{another-target}% } @@ -913,11 +838,7 @@ Here's a % error. -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.13.1   Duplicate Target Names% - \addcontentsline{toc}{subsubsection}{2.13.1   Duplicate Target Names}% +\subsubsection{2.13.1   Duplicate Target Names% \label{duplicate-target-names}% } @@ -926,11 +847,7 @@ generate "info" (level-1) system messages. Duplicate names in explicit targets will generate "warning" (level-2) system messages. -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.13.2   Duplicate Target Names% - \addcontentsline{toc}{subsubsection}{2.13.2   Duplicate Target Names}% +\subsubsection{2.13.2   Duplicate Target Names% \label{id21}% } @@ -940,11 +857,7 @@ this: % \raisebox{1em}{\hypertarget{id51}{}}\hyperlink{id50}{\textbf{\color{red}`Duplicate Target Names`\_}}), an error is generated. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.14   Directives% - \addcontentsline{toc}{subsection}{2.14   Directives}% +\subsection{2.14   Directives% \label{directives}% } @@ -954,11 +867,7 @@ others, please see \url{http://docutils.sourceforge.net/docs/ref/rst/directives.html}. -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.1   Document Parts% - \addcontentsline{toc}{subsubsection}{2.14.1   Document Parts}% +\subsubsection{2.14.1   Document Parts% \label{document-parts}% } @@ -967,11 +876,7 @@ An example of the "contents" directive can be seen above this section document (a document-wide \hyperref[table-of-contents]{table of contents}). -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.2   Images and Figures% - \addcontentsline{toc}{subsubsection}{2.14.2   Images and Figures}% +\subsubsection{2.14.2   Images and Figures% \label{images-and-figures}% } @@ -1105,11 +1010,7 @@ This paragraph might flow around the figure. The specific behavior depends upon the style sheet and the browser or rendering software used. -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.3   Admonitions% - \addcontentsline{toc}{subsubsection}{2.14.3   Admonitions}% +\subsubsection{2.14.3   Admonitions% \label{admonitions}% } @@ -1185,11 +1086,7 @@ You can make up your own admonition too. } -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.4   Topics, Sidebars, and Rubrics% - \addcontentsline{toc}{subsubsection}{2.14.4   Topics, Sidebars, and Rubrics}% +\subsubsection{2.14.4   Topics, Sidebars, and Rubrics% \label{topics-sidebars-and-rubrics}% } @@ -1227,11 +1124,7 @@ Topics and rubrics can be used at places where a \hyperref[section-title]{sectio allowed (e.g. inside a directive). -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.5   Target Footnotes% - \addcontentsline{toc}{subsubsection}{2.14.5   Target Footnotes}% +\subsubsection{2.14.5   Target Footnotes% \label{target-footnotes}% } % @@ -1244,7 +1137,7 @@ allowed (e.g. inside a directive). } % \DUfootnotetext{id35}{id36}{7}{% -\url{http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=polyglossia} +\url{http://ctan.org/pkg/polyglossia} } % \DUfootnotetext{id38}{id39}{8}{% @@ -1256,22 +1149,14 @@ allowed (e.g. inside a directive). } -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.6   Replacement Text% - \addcontentsline{toc}{subsubsection}{2.14.6   Replacement Text}% +\subsubsection{2.14.6   Replacement Text% \label{replacement-text}% } I recommend you try \href{http://www.python.org/}{Python, \emph{the} best language around}\DUfootnotemark{id32}{id29}{5}. -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.7   Compound Paragraph% - \addcontentsline{toc}{subsubsection}{2.14.7   Compound Paragraph}% +\subsubsection{2.14.7   Compound Paragraph% \label{compound-paragraph}% } @@ -1348,11 +1233,7 @@ Compound 7, a paragraph after the table. Compound 7, another paragraph. -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.8   Parsed Literal Blocks% - \addcontentsline{toc}{subsubsection}{2.14.8   Parsed Literal Blocks}% +\subsubsection{2.14.8   Parsed Literal Blocks% \label{parsed-literal-blocks}% } % @@ -1367,11 +1248,7 @@ text},~footnotes\DUfootnotemark{id22}{id8}{1},~% \end{quote} -%___________________________________________________________________________ - -\subsubsection*{\phantomsection% - 2.14.9   Code% - \addcontentsline{toc}{subsubsection}{2.14.9   Code}% +\subsubsection{2.14.9   Code% \label{code}% } @@ -1420,11 +1297,7 @@ as a code block, here the rst file \texttt{header\_footer.txt} with line numbers \end{quote} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.15   Substitution Definitions% - \addcontentsline{toc}{subsection}{2.15   Substitution Definitions}% +\subsection{2.15   Substitution Definitions% \label{substitution-definitions}% } @@ -1433,11 +1306,7 @@ An inline image (\includegraphics{../../../docs/user/rst/images/biohazard.png}) (Substitution definitions are not visible in the HTML source.) -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.16   Comments% - \addcontentsline{toc}{subsection}{2.16   Comments}% +\subsection{2.16   Comments% \label{comments}% } @@ -1454,11 +1323,7 @@ Here's one: (View the HTML source to see the comment.) -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.17   Raw text% - \addcontentsline{toc}{subsection}{2.17   Raw text}% +\subsection{2.17   Raw text% \label{raw-text}% } @@ -1477,11 +1342,7 @@ This is the \DUrole{myrawroleclass}{fourth test} with myrawroleclass set. Fifth test in LaTeX.\\Line two. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.18   Container% - \addcontentsline{toc}{subsection}{2.18   Container}% +\subsection{2.18   Container% \label{container}% } @@ -1493,11 +1354,7 @@ paragraph 2 % .. include:: data/header_footer.txt -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.19   Colspanning tables% - \addcontentsline{toc}{subsection}{2.19   Colspanning tables}% +\subsection{2.19   Colspanning tables% \label{colspanning-tables}% } @@ -1575,11 +1432,7 @@ True \end{longtable*} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.20   Rowspanning tables% - \addcontentsline{toc}{subsection}{2.20   Rowspanning tables}% +\subsection{2.20   Rowspanning tables% \label{rowspanning-tables}% } @@ -1638,11 +1491,7 @@ body row 3 \end{longtable*} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 2.21   Custom Roles% - \addcontentsline{toc}{subsection}{2.21   Custom Roles}% +\subsection{2.21   Custom Roles% \label{custom-roles}% } % @@ -1687,11 +1536,7 @@ The following works in most browsers but does not validate \end{itemize} -%___________________________________________________________________________ - -\section*{\phantomsection% - 3   Tests for the LaTeX writer% - \addcontentsline{toc}{section}{3   Tests for the LaTeX writer}% +\section{3   Tests for the LaTeX writer% \label{tests-for-the-latex-writer}% } @@ -1699,11 +1544,7 @@ Test syntax elements which may cause trouble for the LaTeX writer but might not need to be tested with other writers (e.g. the HTML writer). -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 3.1   Custom Roles in LaTeX% - \addcontentsline{toc}{subsection}{3.1   Custom Roles in LaTeX}% +\subsection{3.1   Custom Roles in LaTeX% \label{custom-roles-in-latex}% } % @@ -1749,11 +1590,7 @@ This is a \DUroletitlereference{\DUrole{custom-title-reference}{customized title % This file is used by the standalone_rst_latex test. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 3.2   Option lists% - \addcontentsline{toc}{subsection}{3.2   Option lists}% +\subsection{3.2   Option lists% \label{id23}% } @@ -1789,11 +1626,7 @@ is contained in a quote \end{description} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 3.3   Monospaced non-alphanumeric characters% - \addcontentsline{toc}{subsection}{3.3   Monospaced non-alphanumeric characters}% +\subsection{3.3   Monospaced non-alphanumeric characters% \label{monospaced-non-alphanumeric-characters}% } @@ -1809,11 +1642,7 @@ The two lines of non-alphanumeric characters should both have the same width as the third line. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 3.4   Non-ASCII characters% - \addcontentsline{toc}{subsection}{3.4   Non-ASCII characters}% +\subsection{3.4   Non-ASCII characters% \label{non-ascii-characters}% } @@ -2227,11 +2056,7 @@ to the document options or use a different font package. \end{itemize} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 3.5   Encoding special chars% - \addcontentsline{toc}{subsection}{3.5   Encoding special chars}% +\subsection{3.5   Encoding special chars% \label{encoding-special-chars}% } @@ -2300,11 +2125,7 @@ greater-than and bar, < | >, except for typewriter font \DUroletitlereference{cm \end{quote} -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 3.6   Hyperlinks and -targets% - \addcontentsline{toc}{subsection}{3.6   Hyperlinks and -targets}% +\subsection{3.6   Hyperlinks and -targets% \label{hyperlinks-and-targets}% } @@ -2349,17 +2170,13 @@ See \hyperref[hypertarget-in-plain-text]{hypertarget in plain text}, \hyperref[image-label]{image label}. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - 3.7   External references% - \addcontentsline{toc}{subsection}{3.7   External references}% +\subsection{3.7   External references% \label{external-references}% } Long URLs should be wrapped in the PDF. This can be achieved with the url command which is used by the LaTeX writer -wheneve the content (name) of a reference node equals the link URL. +whenever the content (name) of a reference node equals the link URL. % \begin{description} \item[{Example:}] \leavevmode @@ -2438,11 +2255,57 @@ while balanced braces are suported: \end{itemize} -%___________________________________________________________________________ +\subsection{3.8   Section titles with \hyperref[inline-markup]{inline markup}% + \label{section-titles-with-inline-markup}% +} -\section*{\phantomsection% - 4   Tests for the XeTeX writer% - \addcontentsline{toc}{section}{4   Tests for the XeTeX writer}% + +\subsubsection{3.8.1   \emph{emphasized}, H\textsubscript{2}O and $x^2$% + \label{emphasized-h2o-and-x-2}% +} + + +\subsubsection{3.8.2   Substitutions work% + \label{substitutions-fail}% +} + + +\subsection{3.9   Deeply nested sections% + \label{deeply-nested-sections}% +} + +In LaTeX and HTML, + + +\subsubsection{3.9.1   Level 3% + \label{level-3}% +} + +nested sections + + +\paragraph{3.9.1.1   level 4% + \label{level-4}% +} + +reach at some level + + +\subparagraph{3.9.1.1.1   level 5% + \label{level-5}% +} + +(depending on the document class) + + +\DUtitle[sectionVI]{3.9.1.1.1.1   level 6% + \label{level-6}% +} + +an unsupported level. + + +\section{4   Tests for the XeTeX writer% \label{tests-for-the-xetex-writer}% } @@ -2454,16 +2317,12 @@ Latviešu, Lietuvių, Македонски, Монгол, Nāhuatl, Português, Русский, 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://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=polyglossia}{polyglossia}\DUfootnotemark{id36}{id35}{7} package. +\href{http://ctan.org/pkg/polyglossia}{polyglossia}\DUfootnotemark{id36}{id35}{7} package. % System Messages: -%___________________________________________________________________________ - -\section*{\phantomsection% - 5   Error Handling% - \addcontentsline{toc}{section}{5   Error Handling}% +\section{5   Error Handling% \label{error-handling}% } @@ -2475,11 +2334,7 @@ section, "Docutils System Messages": % section should be added by Docutils automatically -%___________________________________________________________________________ - -\section*{\phantomsection% - \color{red}Docutils System Messages% - \addcontentsline{toc}{section}{Docutils System Messages}% +\section[Docutils System Messages]{\color{red}Docutils System Messages% } \DUadmonition[system-message]{ diff --git a/test/functional/expected/xetex-cyrillic.tex b/test/functional/expected/xetex-cyrillic.tex index af07cc3bc..e16687a2b 100644 --- a/test/functional/expected/xetex-cyrillic.tex +++ b/test/functional/expected/xetex-cyrillic.tex @@ -7,6 +7,7 @@ \usepackage{polyglossia} \setdefaultlanguage{russian} \setotherlanguages{english} +\setcounter{secnumdepth}{0} %%% Custom LaTeX preamble % Linux Libertine (free, wide coverage, not only for Linux) @@ -32,33 +33,21 @@ \begin{document} -%___________________________________________________________________________ - -\section*{\phantomsection% - Заголовок% - \addcontentsline{toc}{section}{Заголовок}% +\section{Заголовок% \label{id1}% } первый пример: "Здравствуй, мир!" -%___________________________________________________________________________ - -\section*{\phantomsection% - Title% - \addcontentsline{toc}{section}{Title}% +\section{Title% \label{title}% } \otherlanguage{english}{first example: "Hello world".} -%___________________________________________________________________________ - -\section*{\phantomsection% - Notes% - \addcontentsline{toc}{section}{Notes}% +\section{Notes% \label{notes}% } diff --git a/test/functional/input/data/urls.txt b/test/functional/input/data/urls.txt index fc3d788cb..9b17e5801 100644 --- a/test/functional/input/data/urls.txt +++ b/test/functional/input/data/urls.txt @@ -3,7 +3,7 @@ External references Long URLs should be wrapped in the PDF. This can be achieved with the \url command which is used by the LaTeX writer -wheneve the content (name) of a reference node equals the link URL. +whenever the content (name) of a reference node equals the link URL. Example: a long URL that should wrap in the output diff --git a/test/functional/input/standalone_rst_latex.txt b/test/functional/input/standalone_rst_latex.txt index 7078faec2..f5f229da6 100644 --- a/test/functional/input/standalone_rst_latex.txt +++ b/test/functional/input/standalone_rst_latex.txt @@ -20,6 +20,7 @@ not need to be tested with other writers (e.g. the HTML writer). .. include:: data/latex_encoding.txt .. include:: data/hyperlinking.txt .. include:: data/urls.txt +.. include:: data/section_titles.txt .. unusual combinations (from newlatex, for interactive testing) .. include:: data/latex.txt diff --git a/test/functional/input/standalone_rst_xetex.txt b/test/functional/input/standalone_rst_xetex.txt index 3ce341b3d..c2c796f30 100644 --- a/test/functional/input/standalone_rst_xetex.txt +++ b/test/functional/input/standalone_rst_xetex.txt @@ -18,6 +18,7 @@ not need to be tested with other writers (e.g. the HTML writer). .. include:: data/latex_encoding.txt .. include:: data/hyperlinking.txt .. include:: data/urls.txt +.. include:: data/section_titles.txt Tests for the XeTeX writer ========================== @@ -32,8 +33,7 @@ Võro, ייִדיש , Žemaitėška. Currently, there is extended support for 28 languages in the polyglossia_ package. -.. _polyglossia: - http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=polyglossia +.. _polyglossia: http://ctan.org/pkg/polyglossia .. System Messages: .. include:: data/errors.txt diff --git a/test/test_writers/test_latex2e.py b/test/test_writers/test_latex2e.py index 9f04f1f33..bad705c5f 100755 --- a/test/test_writers/test_latex2e.py +++ b/test/test_writers/test_latex2e.py @@ -143,8 +143,10 @@ Title 2 Paragraph 2. """, ## # expected output -head_template.substitute(dict(parts, fallbacks = r""" -% title for topics, admonitions and sidebar +head_template.substitute(dict(parts, + requirements=parts['requirements'] + '\\setcounter{secnumdepth}{0}\n', + fallbacks=r""" +% title for topics, admonitions, unsupported section levels, and sidebar \providecommand*{\DUtitle}[2][class-arg]{% % call \DUtitle#1{#2} if it exists: \ifcsname DUtitle#1\endcsname% @@ -171,22 +173,14 @@ head_template.substitute(dict(parts, fallbacks = r""" \end{list} -%___________________________________________________________________________ - -\section*{\phantomsection% - Title 1% - \addcontentsline{toc}{section}{Title 1}% +\section{Title 1% \label{title-1}% } Paragraph 1. -%___________________________________________________________________________ - -\subsection*{\phantomsection% - Title 2% - \addcontentsline{toc}{subsection}{Title 2}% +\subsection{Title 2% \label{title-2}% } @@ -206,18 +200,16 @@ first section ------------- """, ## # expected output -head + r""" +head_template.substitute(dict(parts, + requirements=parts['requirements'] + '\\setcounter{secnumdepth}{0}\n' +)) + r""" \phantomsection\label{contents} \pdfbookmark[1]{Contents}{contents} \tableofcontents -%___________________________________________________________________________ - -\section*{\phantomsection% - first section% - \addcontentsline{toc}{section}{first section}% +\section{first section% \label{first-section}% } @@ -235,18 +227,16 @@ first section ------------- """, ## # expected output -head + r""" +head_template.substitute(dict(parts, + requirements=parts['requirements'] + '\\setcounter{secnumdepth}{0}\n' +)) + r""" \phantomsection\label{contents} \pdfbookmark[1]{Contents}{contents} \tableofcontents -%___________________________________________________________________________ - -\section*{\phantomsection% - 1~~~first section% - \addcontentsline{toc}{section}{1~~~first section}% +\section{1~~~first section% \label{first-section}% } @@ -270,8 +260,6 @@ r"""\setcounter{secnumdepth}{0} some text -%___________________________________________________________________________ - \section{first section% \label{first-section}% } @@ -291,12 +279,12 @@ first section ------------- """, ## # expected output -head + r""" +head_template.substitute(dict(parts, + requirements=parts['requirements'] + '\\setcounter{secnumdepth}{0}\n' +)) + r""" some text -%___________________________________________________________________________ - \section{first section% \label{first-section}% } @@ -611,8 +599,9 @@ This is a *section title* This is the *document*. """, -head_template.substitute( - dict(parts, pdfsetup=parts['pdfsetup'] + r"""\hypersetup{ +head_template.substitute(dict(parts, + requirements=parts['requirements'] + '\\setcounter{secnumdepth}{0}\n', + pdfsetup=parts['pdfsetup'] + r"""\hypersetup{ pdftitle={This is the Title}, } """, titledata=r"""%%% Title Data @@ -627,11 +616,7 @@ head_template.substitute( """)) + r"""\maketitle -%___________________________________________________________________________ - -\section*{\phantomsection% - This is a \emph{section title}% - \addcontentsline{toc}{section}{This is a section title}% +\section{This is a \emph{section title}% \label{this-is-a-section-title}% } -- 2.11.4.GIT