summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY.txt1
-rw-r--r--docs/user/config.txt40
-rw-r--r--docs/user/latex.txt66
-rw-r--r--docutils/writers/latex2e/__init__.py243
-rw-r--r--docutils/writers/latex2e/default.tex3
-rw-r--r--test/functional/expected/latex_docinfo.tex7
-rw-r--r--test/functional/expected/standalone_rst_latex.tex8
-rwxr-xr-xtest/test_writers/test_latex2e.py12
8 files changed, 251 insertions, 129 deletions
diff --git a/HISTORY.txt b/HISTORY.txt
index 1a3420128..871e5df1b 100644
--- a/HISTORY.txt
+++ b/HISTORY.txt
@@ -29,6 +29,7 @@ Changes Since 0.7
- Fix [ 3043986 ] AttributeError using :local: with table of content.
- Place title data in the document preamble.
+ - Load `babel` package only if required.
- Update list of supported languages.
- New config setting "hyperref-options".
No hard-coded "unicode" hyperref option (clash with xetex).
diff --git a/docs/user/config.txt b/docs/user/config.txt
index 935e0a45f..c07ba9d6a 100644
--- a/docs/user/config.txt
+++ b/docs/user/config.txt
@@ -319,8 +319,16 @@ _`input_encoding_error_handler`
--input-encoding, -i``.
_`language_code`
- `ISO 639`_ 2-letter language code (3-letter codes used only if no
- 2-letter code exists).
+ Case-insensitive `language tag`_ as defined in `BCP 47`_.
+
+ A typical language identifier consists of a 2-letter language code
+ from `ISO 639`_ (3-letter codes can be used if no 2-letter code
+ exists). The language identifier can have an optional subtag,
+ typically for variations based on country (from `ISO 3166`_
+ 2-letter country codes). Avoid subtags except where they add
+ useful distinguishing information. Examples of language tags
+ include "fr", "en-GB", "pt_br" (the same as "pt-BR"), and
+ "de-1901".
Default: English ("en"). Options: ``--language, -l``.
@@ -935,11 +943,31 @@ _`use_latex_abstract`
Default: off. Options: ``--use-latex-abstract, --topic-abstract``.
_`hyperlink_color`
- Color of any hyperlinks embedded in text. Use "0" to disable
- coloring of links.
+ Color of any hyperlinks embedded in text.
+
+ * "0" or "false" disable coloring of links. (Links will be marked
+ by red boxes that are not printed),
+ * "black" results in “invisible“ links,
+
+ Set hyperref_options_ to "draft" to completely disable
+ hyperlinking.
Default: "blue". Option: ``--hyperlink-color``.
+_`hyperref_options`
+ Options for the `hyperref TeX package`_. If hyperlink_color_ is
+ not "false", the expansion of ::
+
+ 'colorlinks=true,linkcolor=%s,urlcolor=%s' % (
+ hyperlink_color, self.hyperlink_color
+
+ is prepended. For documents typeset in Cyrillic script,
+ ``--hyperref-options=unicode`` is recommended.
+
+ Default: "". Option: ``--hyperref-options``.
+
+ .. _hyperref TeX package: http://tug.org/applications/hyperref/
+
_`documentclass`
Specify latex documentclass.
@@ -1232,7 +1260,11 @@ _`_source`
Default: stdin (None). No command-line options.
+.. _language tag: http://www.w3.org/International/articles/language-tags/
+.. _BCP 47: http://www.rfc-editor.org/rfc/bcp/bcp47.txt
.. _ISO 639: http://www.loc.gov/standards/iso639-2/php/English_list.php
+.. _ISO 3166: http://www.iso.ch/iso/en/prods-services/iso3166ma/
+ 02iso-3166-code-lists/index.html
.. [#pwd] Path relative to the working directory of the process at
launch.
diff --git a/docs/user/latex.txt b/docs/user/latex.txt
index e59b245aa..1fe67b024 100644
--- a/docs/user/latex.txt
+++ b/docs/user/latex.txt
@@ -211,14 +211,12 @@ The LaTeX code generation can be configured via
Options
-------
-Options to the Docutils LaTeX writer are specified as
+Options can be specified as
-command-line options
- to the conversion command (run ``rst2latex.py --help`` to get a list of
+* command-line options (run ``rst2latex.py --help`` to get a list of
available options), or
-configuration settings
- in a configuration file (see `Docutils Configuration`_ for details).
+* configuration settings (see `Docutils Configuration`_ for details).
.. _Docutils Configuration:
../user/config.html
@@ -296,8 +294,8 @@ Example:
latex-preamble_ setting in a configuration file::
latex-preamble: \renewcommand{\ttdefault}{txtt}
- \usepackage{mathptmx} % Times
- \usepackage[scaled=.92]{helvet} % Helvetica
+ \usepackage{mathptmx} % Times
+ \usepackage[scaled=.92]{helvet} % Helvetica
.. _latex-preamble:
../user/config.html#latex-preamble
@@ -819,7 +817,7 @@ d) PSNFSS_ Postscript fonts
old-style figures
-1 bad rendering in xpdf viewer (auto-hinting leads to different
x-hight for different characters at some magnifications)
- (this is fixed in recent versions).
+ (this is fixed in recent versions).
Times
+1 the serif `PDF Standard Font`_,
@@ -1048,15 +1046,17 @@ Example:
hyperlinks
----------
+Options:
+ hyperlink-color_, hyperref-options_
+
Hyperlinks are realized using the hyperref_ package. As it re-defines many
standard LaTeX macros, this package is loaded last, *after* the style
sheets.
-However, you can load hyperref with custom options (or before a
-package that requires its presence) in a `style sheet`_ or the `LaTeX
-preamble`_, e.g. ::
-
- \usepackage[unicode,colorlinks=true,linkcolor=green]{hyperref}
+However, you can load hyperref before a package that requires its
+presence in a `style sheet`_ or the `LaTeX preamble`_ (see example
+below). This will ignore options set with hyperlink-color_ and
+hyperref-options_.
URLs are typeset with the "url" package (loaded implicitely by "hyperref").
The font of URLs can be defined with the ``\urlstyle`` command. Valid
@@ -1077,19 +1077,27 @@ Example:
See also `non-breaking hyperlinks`_.
+.. _hyperlink-color:
+ ../user/config.html#hyperlink-color
+.. _hyperref-options:
+ ../user/config.html#hyperref-options
+
+
disable hyperlinks
``````````````````
-To suppress the hyper-linking completely (e.g. for printing or to avoid
-clashes with other packages), load the "nohyperref" package that comes with
-the "hyperref" bundle.
+To suppress the hyper-linking completely (e.g. for printing or to
+avoid clashes with other packages), set hyperref-options_ to "draft"
+or load the "nohyperref" package that comes with the "hyperref"
+bundle.
Option:
- ``--stylesheet=nohyperref,url``
+ ``--hyperref-options=draft``
LaTeX code::
\usepackage{nohyperref,url}
+ \urlstyle{same}
.. _hyperref:
http://mirror.ctan.org/help/Catalogue/entries/hyperref.html
@@ -1715,6 +1723,7 @@ not wrap and sometimes stick into the margin.
Wrong:
::
+
\usepackage[breaklinks=true]{hyperref}
"breaklinks" is an internal option that indicates whether the chosen
@@ -1740,6 +1749,27 @@ See also the `Link text doesn’t break at end line`_ FAQ entry.
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=breaklinks
+Glyph not defined in PD1 encoding
+`````````````````````````````````
+
+If a section title or other link contains e.g. cyrillic characters,
+the LaTeX log contains lots of warnings like::
+
+ Package hyperref Warning: Glyph not defined in PD1 encoding,
+ (hyperref) removing `\CYRZ' on input line 6.
+ ...
+
+This can be solved with the "unicode" hyperref_option_ setting::
+
+ --hyperref-option=unicode
+
+(works also with non-unicode input/output encoding (e.g. "koi8r" or
+"latin1"). However, this setting clashes with the XeTeX_ engine and is
+therefore not made a default.
+
+.. _hyperref_option: ../user/config.html#stylesheet-latex2e-writer
+
+
image inclusion
```````````````
@@ -1812,7 +1842,7 @@ an Euro sign at its place). You might see an error like::
:warn: turn the error in a warning, use the default symbol (bitmap), or
:force,almostfull: use the symbol provided by the font at the users
- risk,
+ risk,
to the document options or use a different font package.
diff --git a/docutils/writers/latex2e/__init__.py b/docutils/writers/latex2e/__init__.py
index 467f5f9ed..b69796151 100644
--- a/docutils/writers/latex2e/__init__.py
+++ b/docutils/writers/latex2e/__init__.py
@@ -134,8 +134,11 @@ class Writer(writers.Writer):
{'default': 0, 'action': 'store_true',
'validator': frontend.validate_boolean}),
('Color of any hyperlinks embedded in text '
- '(default: "blue", "0" to disable).',
+ '(default: "blue", "false" to disable).',
['--hyperlink-color'], {'default': 'blue'}),
+ ('Additional options to the "hyperref" package '
+ '(default: "").',
+ ['--hyperref-options'], {'default': ''}),
('Enable compound enumerators for nested enumerated lists '
'(e.g. "1.2.a.ii"). Default: disabled.',
['--compound-enumerators'],
@@ -229,7 +232,6 @@ class Writer(writers.Writer):
# transform_list.append(footnotes.collect)
return transform_list
-
def translate(self):
visitor = self.translator_class(self.document)
self.document.walkabout(visitor)
@@ -240,7 +242,7 @@ class Writer(writers.Writer):
try:
file = open(self.document.settings.template, 'rb')
except IOError:
- file = open(os.path.join(os.path.dirname(__file__),
+ file = open(os.path.join(self.default_template_path,
self.document.settings.template), 'rb')
template = string.Template(unicode(file.read(), 'utf-8'))
file.close()
@@ -264,70 +266,120 @@ class Writer(writers.Writer):
class Babel(object):
"""Language specifics for LaTeX."""
- # country code by a.schlock.
- # partly manually converted from iso and babel stuff, dialects and some
- _ISO639_TO_BABEL = {
- 'no': 'norsk', #XXX added by hand ( forget about nynorsk?)
- 'gd': 'scottish', #XXX added by hand
- 'hu': 'magyar', #XXX added by hand
- 'pt': 'portuguese',#XXX added by hand
- 'sl': 'slovenian',
- 'af': 'afrikaans',
- 'bg': 'bulgarian',
- 'br': 'breton',
- 'ca': 'catalan',
- 'cs': 'czech',
- 'cy': 'welsh',
- 'da': 'danish',
- 'fr': 'french',
- # french, francais, canadien, acadian
- 'de': 'ngerman', #XXX rather than german
- # ngerman, naustrian, german, germanb, austrian
- 'el': 'greek',
- 'en': 'english',
- # english, USenglish, american, UKenglish, british, canadian
- 'eo': 'esperanto',
- 'es': 'spanish',
- 'et': 'estonian',
- 'eu': 'basque',
- 'fi': 'finnish',
- 'ga': 'irish',
- 'gl': 'galician',
- 'he': 'hebrew',
- 'hr': 'croatian',
- 'hu': 'hungarian',
- 'is': 'icelandic',
- 'it': 'italian',
- 'la': 'latin',
- 'nl': 'dutch',
- 'pl': 'polish',
- 'pt': 'portuguese',
- 'ro': 'romanian',
- 'ru': 'russian',
- 'sk': 'slovak',
- 'sr': 'serbian',
- 'sv': 'swedish',
- 'tr': 'turkish',
- 'uk': 'ukrainian'
- }
-
- def __init__(self, lang):
- self.language = lang
+
+ # TeX (babel) language names:
+ # ! not all of these are supported by Docutils!
+ #
+ # based on LyX' languages file with adaptions to `BCP 47`_
+ # (http://www.rfc-editor.org/rfc/bcp/bcp47.txt) and
+ # http://www.tug.org/TUGboat/Articles/tb29-3/tb93miklavec.pdf
+ # * the key without subtags is the default
+ # * case is ignored
+ # cf. http://docutils.sourceforge.net/docs/howto/i18n.html
+ # http://www.w3.org/International/articles/language-tags/
+ # and http://www.iana.org/assignments/language-subtag-registry
+ language_codes = {
+ # code TeX/Babel-name comment
+ 'af': 'afrikaans',
+ 'ar': 'arabic',
+ # 'be': 'belarusian',
+ 'bg': 'bulgarian',
+ 'br': 'breton',
+ 'ca': 'catalan',
+ # 'cop': 'coptic',
+ 'cs': 'czech',
+ 'cy': 'welsh',
+ 'da': 'danish',
+ 'de': 'ngerman', # new spelling (de_1996)
+ 'de_1901': 'german', # old spelling
+ 'de_at': 'naustrian',
+ 'de_at_1901': 'austrian',
+ 'dsb': 'lowersorbian',
+ 'el': 'greek', # monotonic (el-monoton)
+ 'el_polyton': 'polutonikogreek',
+ 'en': 'english', # TeX' default language
+ 'en_au': 'australian',
+ 'en_ca': 'canadian',
+ 'en_gb': 'british',
+ 'en_nz': 'newzealand',
+ 'en_us': 'american',
+ 'eo': 'esperanto', # '^' is made active!
+ 'es': 'spanish',
+ 'et': 'estonian',
+ 'eu': 'basque',
+ # 'fa': 'farsi',
+ 'fi': 'finnish',
+ 'fr': 'french',
+ 'fr_ca': 'canadien',
+ 'ga': 'irish', # Irish Gaelic
+ # 'grc': # Ancient Greek
+ 'grc_x_ibycus': 'ibycus', # Ibycus encoding
+ 'grc_ibycus': 'ibycus',
+ 'gd': 'scottish', # Scottish Gaelic
+ 'gl': 'galician',
+ 'he': 'hebrew',
+ 'hr': 'croatian',
+ 'hsb': 'uppersorbian',
+ 'hu': 'magyar',
+ 'ia': 'interlingua',
+ 'id': 'bahasai', # Bahasa (Indonesian)
+ 'is': 'icelandic',
+ 'it': 'italian',
+ 'ja': 'japanese',
+ 'kk': 'kazakh',
+ 'la': 'latin',
+ 'lt': 'lithuanian',
+ 'lv': 'latvian',
+ 'mn': 'mongolian', # Mongolian, Cyrillic script (mn-cyrl)
+ 'ms': 'bahasam', # Bahasa (Malay)
+ 'nb': 'norsk', # Norwegian Bokmal
+ 'nl': 'dutch',
+ 'nn': 'nynorsk', # Norwegian Nynorsk
+ 'no': 'norsk', # Norwegian Bokmal
+ 'pl': 'polish',
+ 'pt': 'portuges',
+ 'pt_br': 'brazil',
+ 'ro': 'romanian',
+ 'ru': 'russian', # " active
+ 'se': 'samin', # North Sami
+ # sh-cyrl: Serbo-Croatian, Cyrillic script
+ 'sh-latn': 'serbian', # Serbo-Croatian, Latin script
+ 'sk': 'slovak',
+ 'sl': 'slovene',
+ 'sq': 'albanian',
+ # 'sr-cyrl': Serbian, Cyrillic script (sr-cyrl)
+ 'sr-latn': 'serbian', # Serbian, Latin script, " active.
+ 'sv': 'swedish',
+ # 'th': 'thai',
+ 'tr': 'turkish',
+ 'uk': 'ukrainian',
+ 'vi': 'vietnam',
+ # zh-latn: Chinese Pinyin
+ }
+
+ def __init__(self, language_code):
+ self.language_code = language_code
+ self.get_language() # set self.language, self.warning
self.quote_index = 0
self.quotes = ('``', "''")
- self.setup = '' # language dependent configuration code
+ self.setup = [r'\usepackage{babel}']
+ # language dependent configuration:
# double quotes are "active" in some languages (e.g. German).
- # TODO: use \textquotedbl in OT1 font encoding?
+ # TODO: use \textquotedbl in T1 font encoding?
self.literal_double_quote = u'"'
- if self.language.startswith('de'):
+ if self.language in ('ngerman', 'german', 'austrian', 'naustrian'):
self.quotes = (r'\glqq{}', r'\grqq{}')
self.literal_double_quote = ur'\dq{}'
- if self.language.startswith('it'):
+ if self.language == 'italian':
self.literal_double_quote = ur'{\char`\"}'
- if self.language.startswith('es'):
- # reset tilde ~ to the original binding (nobreakspace):
- self.setup = ('\n'
+ if self.language == 'spanish':
+ # reset active chars to the original meaning:
+ self.setup.append(
r'\addto\shorthandsspanish{\spanishdeactivate{."~<>}}')
+ # or prepend r'\def\spanishoptions{es-noshorthands}'
+ # don't use babel for (american) English or unknown languages:
+ if self.language in ('english', ''):
+ self.setup = []
def next_quote(self):
q = self.quotes[self.quote_index]
@@ -344,8 +396,20 @@ class Babel(object):
return t
def get_language(self):
- lang = self.language.split('_')[0] # filter dialects
- return self._ISO639_TO_BABEL.get(lang, "")
+ """Set TeX language name"""
+ for tag in utils.normalize_language_tag(self.language_code):
+ try:
+ self.language = self.language_codes[tag]
+ self.warning = ''
+ break
+ except KeyError:
+ continue
+ else:
+ self.language = ''
+ self.warning = ('language "%s" not supported by XeTeX' +
+ 'defaulting to "english"') % self.language_code
+
+
# Building blocks for the latex preamble
# --------------------------------------
@@ -506,7 +570,7 @@ PreambleCmds.lineblock = r"""
PreambleCmds.linking = r"""
%% hyperlinks:
\ifthenelse{\isundefined{\hypersetup}}{
- \usepackage[unicode,colorlinks=%s,linkcolor=%s,urlcolor=%s]{hyperref}
+ \usepackage[%s]{hyperref}
\urlstyle{same} %% normal text font (alternatives: tt, rm, sf)
}{}"""
@@ -662,7 +726,6 @@ class Table(object):
self.stubs = []
def is_open(self):
return self._open
-
def set_table_style(self, table_style):
if not table_style in ('standard','booktabs','borderless','nolines'):
return
@@ -851,9 +914,6 @@ class LaTeXTranslator(nodes.NodeVisitor):
# prefix from the regular list enumerator.
section_enumerator_separator = '-'
- # default link color
- hyperlink_color = 'blue'
-
# Auxiliary variables
# -------------------
@@ -888,7 +948,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
self._reference_label = settings.reference_label
self.hyperlink_color = settings.hyperlink_color
self.compound_enumerators = settings.compound_enumerators
- self.font_encoding = settings.font_encoding
+ self.font_encoding = getattr(settings, 'font_encoding', '')
self.section_prefix_for_enumerators = (
settings.section_prefix_for_enumerators)
self.section_enumerator_separator = (
@@ -913,9 +973,12 @@ class LaTeXTranslator(nodes.NodeVisitor):
# (labels, bibliographic_fields, and author_separators)
self.language = languages.get_language(settings.language_code)
self.babel = Babel(settings.language_code)
+ if self.babel.language == '':
+ self.warn(self.babel.warning)
self.author_separator = self.language.author_separators[0]
- self.d_options = [self.settings.documentoptions,
- self.babel.get_language()]
+ self.d_options = [self.settings.documentoptions]
+ if self.babel.language and self.babel.language != 'english':
+ self.d_options.append(self.babel.language)
self.d_options = ','.join([opt for opt in self.d_options if opt])
self.d_class = DocumentClass(settings.documentclass,
settings.use_part_section)
@@ -1010,17 +1073,14 @@ class LaTeXTranslator(nodes.NodeVisitor):
if self.font_encoding:
encodings = [r'\usepackage[%s]{fontenc}' % self.font_encoding]
else:
- encodings = [r'%\usepackage[OT1]{fontenc}'] # just a comment
+ encodings = []
# Docutils' output-encoding => TeX input encoding:
if self.latex_encoding != 'ascii':
encodings.append(r'\usepackage[%s]{inputenc}'
% self.latex_encoding)
- self.requirements['_static'] = '\n'.join(
- encodings + [
- r'\usepackage{ifthen}',
- # multi-language support (language is in document options)
- '\\usepackage{babel}%s' % self.babel.setup,
- ])
+ self.requirements['_static'] = '\n'.join(encodings +
+ [r'\usepackage{ifthen}'] +
+ self.babel.setup)
# page layout with typearea (if there are relevant document options)
if (settings.documentclass.find('scr') == -1 and
(self.d_options.find('DIV') != -1 or
@@ -1054,11 +1114,13 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.stylesheet.append(r'\input{%s}' % sheet)
# PDF setup
- if self.hyperlink_color == '0':
- self.hyperlink_color = 'black'
- self.colorlinks = 'false'
+ if self.hyperlink_color in ('0', 'false', 'False', ''):
+ self.hyperref_options = ''
else:
- self.colorlinks = 'true'
+ self.hyperref_options = 'colorlinks=true,linkcolor=%s,urlcolor=%s' % (
+ self.hyperlink_color, self.hyperlink_color)
+ if settings.hyperref_options:
+ self.hyperref_options += ',' + settings.hyperref_options
# LaTeX Toc
# include all supported sections in toc and PDF bookmarks
@@ -1723,9 +1785,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
# * coditional fallback definitions (after style sheet)
self.fallbacks = self.fallbacks.sortedvalues()
# * PDF properties
- self.pdfsetup.append(PreambleCmds.linking % (self.colorlinks,
- self.hyperlink_color,
- self.hyperlink_color))
+ self.pdfsetup.append(PreambleCmds.linking % self.hyperref_options)
if self.pdfauthor:
authors = self.author_separator.join(self.pdfauthor)
self.pdfinfo.append(' pdfauthor={%s}' % authors)
@@ -1736,22 +1796,23 @@ class LaTeXTranslator(nodes.NodeVisitor):
# 'author', 'organization', 'contact', 'address' and 'date')
if self.title or (
self.use_latex_docinfo and (self.author_stack or self.date)):
- # always write \title (to prevent error with \maketitle)
+ # with the default template, titledata is written to the preamble
+ self.titledata.append('%%% Title Data')
+ # \title (empty \title prevents error with \maketitle)
title = [''.join(self.title)] + self.title_labels
if self.subtitle:
title += [r'\\ % subtitle',
r'\large{%s}' % ''.join(self.subtitle)
] + self.subtitle_labels
self.titledata.append(r'\title{%s}' % '%\n '.join(title))
- # author only required if non-empty
- if self.author_stack:
- authors = ['\\\\\n'.join(author_entry)
- for author_entry in self.author_stack]
- self.titledata.append(r'\author{%s}' %
+ # \author (empty \author prevents warning with \maketitle)
+ authors = ['\\\\\n'.join(author_entry)
+ for author_entry in self.author_stack]
+ self.titledata.append(r'\author{%s}' %
' \\and\n'.join(authors))
- # always write \date (to prevent defaulting to \today)
+ # \date (empty \date prevents defaulting to \today)
self.titledata.append(r'\date{%s}' % ', '.join(self.date))
- # format title with LaTeX
+ # \maketitle in the body formats title with LaTeX
self.body_pre_docinfo.append('\\maketitle\n')
# * bibliography
diff --git a/docutils/writers/latex2e/default.tex b/docutils/writers/latex2e/default.tex
index d3229b383..69e99fd7b 100644
--- a/docutils/writers/latex2e/default.tex
+++ b/docutils/writers/latex2e/default.tex
@@ -1,5 +1,4 @@
-% generated by Docutils <http://docutils.sourceforge.net/>
-$head_prefix
+$head_prefix% generated by Docutils <http://docutils.sourceforge.net/>
\usepackage{fixltx2e} % LaTeX patches, \textsubscript
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
$requirements
diff --git a/test/functional/expected/latex_docinfo.tex b/test/functional/expected/latex_docinfo.tex
index 492e36b8b..4e40add85 100644
--- a/test/functional/expected/latex_docinfo.tex
+++ b/test/functional/expected/latex_docinfo.tex
@@ -1,12 +1,10 @@
+\documentclass[a4paper]{article}
% generated by Docutils <http://docutils.sourceforge.net/>
-\documentclass[a4paper,english]{article}
-
\usepackage{fixltx2e} % LaTeX patches, \textsubscript
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{ifthen}
-\usepackage{babel}
%%% Custom LaTeX preamble
% PDF Standard Fonts
@@ -20,13 +18,14 @@
% hyperlinks:
\ifthenelse{\isundefined{\hypersetup}}{
- \usepackage[unicode,colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
+ \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
\urlstyle{same} % normal text font (alternatives: tt, rm, sf)
}{}
\hypersetup{
pdfauthor={Foo Fred;Bar Barney}
}
+%%% Title Data
\title{}
\author{Foo Fred\\
Food Foomatics \& Friends\\
diff --git a/test/functional/expected/standalone_rst_latex.tex b/test/functional/expected/standalone_rst_latex.tex
index 7ae11596c..08e5ec6b2 100644
--- a/test/functional/expected/standalone_rst_latex.tex
+++ b/test/functional/expected/standalone_rst_latex.tex
@@ -1,12 +1,10 @@
+\documentclass[a4paper]{article}
% generated by Docutils <http://docutils.sourceforge.net/>
-\documentclass[a4paper,english]{article}
-
\usepackage{fixltx2e} % LaTeX patches, \textsubscript
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{ifthen}
-\usepackage{babel}
\usepackage{color}
\usepackage{float} % float configuration
\floatplacement{figure}{H} % place figures here definitely
@@ -172,7 +170,7 @@
% hyperlinks:
\ifthenelse{\isundefined{\hypersetup}}{
- \usepackage[unicode,colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
+ \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
\urlstyle{same} % normal text font (alternatives: tt, rm, sf)
}{}
\hypersetup{
@@ -180,6 +178,7 @@
pdfauthor={David Goodger;Me;Myself;I}
}
+%%% Title Data
\title{reStructuredText Test Document%
\phantomsection%
\label{restructuredtext-test-document}%
@@ -188,6 +187,7 @@
\large{Examples of Syntax Constructs}%
\label{examples-of-syntax-constructs}%
\label{subtitle}}
+\author{}
\date{}
%%% Body
diff --git a/test/test_writers/test_latex2e.py b/test/test_writers/test_latex2e.py
index e92cfd0d5..1b1acea0a 100755
--- a/test/test_writers/test_latex2e.py
+++ b/test/test_writers/test_latex2e.py
@@ -38,8 +38,7 @@ def suite():
return s
head_template = string.Template(
-r"""% generated by Docutils <http://docutils.sourceforge.net/>
-$head_prefix
+r"""$head_prefix% generated by Docutils <http://docutils.sourceforge.net/>
\usepackage{fixltx2e} % LaTeX patches, \textsubscript
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
$requirements
@@ -55,12 +54,11 @@ $titledata
""")
parts = dict(
-head_prefix = r"""\documentclass[a4paper,english]{article}
+head_prefix = r"""\documentclass[a4paper]{article}
""",
requirements = r"""\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{ifthen}
-\usepackage{babel}
""",
latex_preamble = r"""% PDF Standard Fonts
\usepackage{mathptmx} % Times
@@ -72,7 +70,7 @@ fallbacks = '',
pdfsetup = r"""
% hyperlinks:
\ifthenelse{\isundefined{\hypersetup}}{
- \usepackage[unicode,colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
+ \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
\urlstyle{same} % normal text font (alternatives: tt, rm, sf)
}{}
""",
@@ -604,12 +602,14 @@ head_template.substitute(
dict(parts, pdfsetup=parts['pdfsetup'] + r"""\hypersetup{
pdftitle={This is the Title},
}
-""", titledata=r"""\title{This is the \emph{Title}%
+""", titledata=r"""%%% Title Data
+\title{This is the \emph{Title}%
\phantomsection%
\label{this-is-the-title}%
\\ % subtitle%
\large{This is the \emph{Subtitle}}%
\label{this-is-the-subtitle}}
+\author{}
\date{}
""")) + r"""\maketitle