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
commitdf9a46444fb1184886ee10e88ba0e8bba254d6cb (patch)
tree7651f456cd1a1377b701a62533915cf1dea6dc1d
parent064403f805a6e52bcb15ac50e907c231d4b5bc2c (diff)
downloaddocutils-df9a46444fb1184886ee10e88ba0e8bba254d6cb.tar.gz
Merge smaller differences from latex2e_adaptive_preamble.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils/docutils@5261 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r--writers/latex2e/__init__.py44
1 files changed, 26 insertions, 18 deletions
diff --git a/writers/latex2e/__init__.py b/writers/latex2e/__init__.py
index ab15c2349..a4916d771 100644
--- a/writers/latex2e/__init__.py
+++ b/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.