summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrubert <grubert@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2007-06-20 08:35:57 +0000
committergrubert <grubert@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2007-06-20 08:35:57 +0000
commitca0fa8c8115059d8d945c2061cc6ebf4e4e4f2f0 (patch)
tree5e4f66eb78ab7128ff8cd283b4bfd97bac31fed1
parenteaa43df408253d18731cf63105834fa6d0261eea (diff)
downloaddocutils-ca0fa8c8115059d8d945c2061cc6ebf4e4e4f2f0.tar.gz
Merge smaller differences from latex2e_adaptive_preamble.subdocs@5264
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@5261 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r--HISTORY.txt1
-rw-r--r--docutils/writers/latex2e/__init__.py44
-rw-r--r--test/functional/expected/latex_docinfo.tex3
-rw-r--r--test/functional/expected/standalone_rst_latex.tex3
-rwxr-xr-xtest/test_writers/test_latex2e.py2
5 files changed, 30 insertions, 23 deletions
diff --git a/HISTORY.txt b/HISTORY.txt
index a44a0dfa6..fc7ab200f 100644
--- a/HISTORY.txt
+++ b/HISTORY.txt
@@ -116,6 +116,7 @@ Changes Since 0.4
* docutils/writers/latex2e/__init__.py:
+ - Merge smaller differences from latex2e_adaptive_preamble.
- Add ``use-part-section``.
- Put leavevmode before longtable to avoid having it moved before sub/pargraph.
- Using leavemode optoin_list no longer needs to check if parent
diff --git a/docutils/writers/latex2e/__init__.py b/docutils/writers/latex2e/__init__.py
index ab15c2349..a4916d771 100644
--- a/docutils/writers/latex2e/__init__.py
+++ b/docutils/writers/latex2e/__init__.py
@@ -173,11 +173,9 @@ class Writer(writers.Writer):
visitor = self.translator_class(self.document)
self.document.walkabout(visitor)
self.output = visitor.astext()
- self.head_prefix = visitor.head_prefix
- self.head = visitor.head
- self.body_prefix = visitor.body_prefix
- self.body = visitor.body
- self.body_suffix = visitor.body_suffix
+ # copy parts
+ for attr in self.visitor_attributes:
+ setattr(self, attr, getattr(visitor, attr))
def assemble_parts(self):
writers.Writer.assemble_parts(self)
@@ -192,6 +190,9 @@ Notes on LaTeX
* LaTeX does not support multiple tocs in one document.
(might be no limitation except for docutils documentation)
+ The "minitoc" latex package can produce per-chapter tocs in
+ book and report document classes.
+
* width
* linewidth - width of a line in the local environment
@@ -407,6 +408,7 @@ class Table:
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
@@ -562,12 +564,17 @@ class LaTeXTranslator(nodes.NodeVisitor):
# When options are given to the documentclass, latex will pass them
# to other packages, as done with babel.
# Dummy settings might be taken from document settings
-
+
+ # Templates
+ # ---------
+
latex_head = '\\documentclass[%s]{%s}\n'
linking = '\\usepackage[colorlinks=%s,linkcolor=%s,urlcolor=%s]{hyperref}\n'
stylesheet = '\\input{%s}\n'
# add a generated on day , machine by user using docutils version.
- generator = '%% generator Docutils: http://docutils.sourceforge.net/\n'
+ generator = '% generated by Docutils <http://docutils.sourceforge.net/>\n'
+ # Config setting defaults
+ # -----------------------
# use latex tableofcontents or let docutils do it.
use_latex_toc = 0
@@ -623,10 +630,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.author_separator = self.language.author_separators[0]
self.d_options = self.settings.documentoptions
if self.babel.get_language():
- self.d_options += ',%s' % \
- self.babel.get_language()
+ self.d_options += ',%s' % self.babel.get_language()
- self.d_class = DocumentClass(settings.documentclass, settings.use_part_section)
+ self.d_class = DocumentClass(settings.documentclass,
+ settings.use_part_section)
# object for a table while proccessing.
self.table_stack = []
self.active_table = Table('longtable',settings.table_style)
@@ -714,13 +721,14 @@ class LaTeXTranslator(nodes.NodeVisitor):
if self.linking: # and maybe check for pdf
self.pdfinfo = [ ]
self.pdfauthor = None
- # pdftitle, pdfsubject, pdfauthor, pdfkeywords, pdfcreator, pdfproducer
+ # pdftitle, pdfsubject, pdfauthor, pdfkeywords,
+ # pdfcreator, pdfproducer
else:
self.pdfinfo = None
# NOTE: Latex wants a date and an author, rst puts this into
- # docinfo, so normally we donot want latex author/date handling.
+ # docinfo, so normally we do not want latex author/date handling.
# latex article has its own handling of date and author, deactivate.
- # So we always emit \title{...} \author{...} \date{...}, even if the
+ # self.astext() adds \title{...} \author{...} \date{...}, even if the
# "..." are empty strings.
self.head = [ ]
# separate title, so we can appen subtitle.
@@ -953,9 +961,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
return self.encode(whitespace.sub(' ', text))
def astext(self):
- if self.pdfinfo is not None:
- if self.pdfauthor:
- self.pdfinfo.append('pdfauthor={%s}' % self.pdfauthor)
+ if self.pdfinfo is not None and self.pdfauthor:
+ self.pdfinfo.append('pdfauthor={%s}' % self.pdfauthor)
if self.pdfinfo:
pdfinfo = '\\hypersetup{\n' + ',\n'.join(self.pdfinfo) + '\n}\n'
else:
@@ -1258,9 +1265,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body_prefix.append('\\begin{document}\n')
# titled document?
if self.use_latex_docinfo or len(node) and isinstance(node[0], nodes.title):
- self.body_prefix.append('\\maketitle\n\n')
+ self.body_prefix.append('\\maketitle\n')
# alternative use titlepage environment.
# \begin{titlepage}
+ # ...
self.body.append('\n\\setlength{\\locallinewidth}{\\linewidth}\n')
def depart_document(self, node):
@@ -2050,7 +2058,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
(l, text, id))
def visit_title(self, node):
- """Only 3 section levels are supported by LaTeX article (AFAIR)."""
+ """Section and other titles."""
if isinstance(node.parent, nodes.topic):
# the table of contents.
diff --git a/test/functional/expected/latex_docinfo.tex b/test/functional/expected/latex_docinfo.tex
index 04d9438f7..b1a9a1962 100644
--- a/test/functional/expected/latex_docinfo.tex
+++ b/test/functional/expected/latex_docinfo.tex
@@ -14,7 +14,7 @@
\usepackage{ifthen}
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
\usepackage[DIV12]{typearea}
-%% generator Docutils: http://docutils.sourceforge.net/
+% generated by Docutils <http://docutils.sourceforge.net/>
\newlength{\admonitionwidth}
\setlength{\admonitionwidth}{0.9\textwidth}
\newlength{\docinfowidth}
@@ -73,7 +73,6 @@ pdfauthor={Foo Fred;Bar Barney}
\raggedbottom
\begin{document}
\maketitle
-
%___________________________________________________________________________
\begin{center}
\begin{tabularx}{\docinfowidth}{lX}
diff --git a/test/functional/expected/standalone_rst_latex.tex b/test/functional/expected/standalone_rst_latex.tex
index 979e4dd82..837af1d99 100644
--- a/test/functional/expected/standalone_rst_latex.tex
+++ b/test/functional/expected/standalone_rst_latex.tex
@@ -14,7 +14,7 @@
\usepackage{ifthen}
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
\usepackage[DIV12]{typearea}
-%% generator Docutils: http://docutils.sourceforge.net/
+% generated by Docutils <http://docutils.sourceforge.net/>
\newlength{\admonitionwidth}
\setlength{\admonitionwidth}{0.9\textwidth}
\newlength{\docinfowidth}
@@ -67,7 +67,6 @@ pdfauthor={David Goodger;Me;Myself;I}
\raggedbottom
\begin{document}
\maketitle
-
%___________________________________________________________________________
\begin{center}
\begin{tabularx}{\docinfowidth}{lX}
diff --git a/test/test_writers/test_latex2e.py b/test/test_writers/test_latex2e.py
index 5b1b41c9f..ea7a81f2e 100755
--- a/test/test_writers/test_latex2e.py
+++ b/test/test_writers/test_latex2e.py
@@ -38,7 +38,7 @@ latex_head = """\
\\usepackage{ifthen}
\\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
\\usepackage[DIV12]{typearea}
-%% generator Docutils: http://docutils.sourceforge.net/
+% generated by Docutils <http://docutils.sourceforge.net/>
\\newlength{\\admonitionwidth}
\\setlength{\\admonitionwidth}{0.9\\textwidth}
\\newlength{\\docinfowidth}