From 2ae2aa14f8807561564dc3a908acb15e59bb7dce Mon Sep 17 00:00:00 2001 From: grubert Date: Thu, 14 Jun 2007 12:21:41 +0000 Subject: [PATCH] Add ``use-part-section``. git-svn-id: https://docutils.svn.sourceforge.net/svnroot/docutils/trunk/docutils@5237 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- HISTORY.txt | 1 + docutils/writers/latex2e/__init__.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/HISTORY.txt b/HISTORY.txt index dbc0b52c0..a44a0dfa6 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -116,6 +116,7 @@ Changes Since 0.4 * docutils/writers/latex2e/__init__.py: + - 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 is a definition list. diff --git a/docutils/writers/latex2e/__init__.py b/docutils/writers/latex2e/__init__.py index d5f67ffd1..ab15c2349 100644 --- a/docutils/writers/latex2e/__init__.py +++ b/docutils/writers/latex2e/__init__.py @@ -76,6 +76,10 @@ class Writer(writers.Writer): ['--use-latex-toc'], {'default': 0, 'action': 'store_true', 'validator': frontend.validate_boolean}), + ('Add parts on top of the section hierarchy.', + ['--use-part-section'], + {'default': 0, 'action': 'store_true', + 'validator': frontend.validate_boolean}), ('Let LaTeX print author and date, do not show it in docutils ' 'document info.', ['--use-latex-docinfo'], @@ -347,8 +351,9 @@ latex_headings = { class DocumentClass: """Details of a LaTeX document class.""" - def __init__(self, document_class): + def __init__(self, document_class, with_part=False): self.document_class = document_class + self._with_part = with_part def section(self, level): """ Return the section name at the given level for the specific @@ -360,6 +365,8 @@ class DocumentClass: 'paragraph', 'subparagraph' ] if self.document_class in ('book', 'report', 'scrartcl', 'scrbook'): sections.insert(0, 'chapter') + if self._with_part: + sections.insert(0, 'part') if level <= len(sections): return sections[level-1] else: @@ -619,7 +626,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.d_options += ',%s' % \ self.babel.get_language() - self.d_class = DocumentClass(settings.documentclass) + 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) -- 2.11.4.GIT