* New LaTeX table handling.

* Support parts in LaTeX output.
This commit is contained in:
Georg Brandl
2008-05-03 18:14:13 +00:00
parent 4badbc4f8d
commit 5caa6d01c5
17 changed files with 696 additions and 423 deletions

View File

@@ -15,6 +15,12 @@ New features added
independently from the source directory. For that, a new command-line independently from the source directory. For that, a new command-line
option ``-c`` has been added. option ``-c`` has been added.
* A new directive ``tabularcolumns`` can be used to give a tabular column
specification for LaTeX output. Tables now use the ``tabulary`` package.
* A new config value, `latex_use_parts`, can be used to enable parts in LaTeX
documents.
Bugs fixed Bugs fixed
---------- ----------
@@ -22,6 +28,8 @@ Bugs fixed
master document. Also encode non-ASCII characters as entities in TOC master document. Also encode non-ASCII characters as entities in TOC
and index file. and index file.
* Lots of little fixes to the LaTeX output and style.
Release 0.2 (Apr 27, 2008) Release 0.2 (Apr 27, 2008)
========================== ==========================

View File

@@ -123,6 +123,8 @@ latex_documents = [('contents', 'sphinx.tex', 'Sphinx Documentation',
latex_logo = '_static/sphinx.png' latex_logo = '_static/sphinx.png'
#latex_use_parts = True
# Additional stuff for the LaTeX preamble. # Additional stuff for the LaTeX preamble.
#latex_preamble = '' #latex_preamble = ''

View File

@@ -310,6 +310,13 @@ These options influence LaTeX output.
configuration directory) that is the logo of the docs. It is placed at the configuration directory) that is the logo of the docs. It is placed at the
top of the title page. Default: ``None``. top of the title page. Default: ``None``.
.. confval:: latex_use_parts
If true, the topmost sectioning unit is parts, else it is chapters. Default:
``False``.
.. versionadded:: 0.2.1
.. confval:: latex_appendices .. confval:: latex_appendices
Documents to append as an appendix to all manuals. Documents to append as an appendix to all manuals.

View File

@@ -159,6 +159,8 @@ Sphinx core events
These events are known to the core: These events are known to the core:
.. tabularcolumns:: |l|L|L|
====================== =================================== ========= ====================== =================================== =========
Event name Emitted when Arguments Event name Emitted when Arguments
====================== =================================== ========= ====================== =================================== =========

View File

@@ -39,3 +39,40 @@ Meta-information markup
keep track of contributions), but you can set the configuration value keep track of contributions), but you can set the configuration value
:confval:`show_authors` to True to make them produce a paragraph in the :confval:`show_authors` to True to make them produce a paragraph in the
output. output.
Tables
------
Use standard reStructuredText tables. They work fine in HTML output, however
there are some gotchas when using tables in LaTeX: the column width is hard to
determine correctly automatically. For this reason, the following directive
exists:
.. directive:: .. tabularcolumns:: column spec
This directive gives a "column spec" for the next table occurring in the
source file. The spec is the second argument to the LaTeX ``tabulary``
package's environment (which Sphinx uses to translate tables). It can have
values like ::
|l|l|l|
which means three left-adjusted, nonbreaking columns. For columns with
longer text that should automatically be broken, use either the standard
``p{width}`` construct, or tabulary's automatic specifiers:
+-----+------------------------------------------+
|``L``| ragged-left column with automatic width |
+-----+------------------------------------------+
|``R``| ragged-right column with automatic width |
+-----+------------------------------------------+
|``C``| centered column with automatic width |
+-----+------------------------------------------+
|``J``| justified column with automatic width |
+-----+------------------------------------------+
The automatic width is determined by rendering the content in the table, and
scaling them according to their share of the total width.
.. versionadded:: 0.2.1

View File

@@ -66,10 +66,16 @@ class glossary(nodes.Element): pass
# module declaration # module declaration
class module(nodes.Element): pass class module(nodes.Element): pass
# make them known to docutils. this is needed, because the HTMl writer # start of a file, used in the LaTeX builder only
class start_of_file(nodes.Element): pass
# tabular column specification, used for the LaTeX writer
class tabular_col_spec(nodes.Element): pass
# make them known to docutils. this is needed, because the HTML writer
# will choke at some point if these are not added # will choke at some point if these are not added
nodes._add_node_class_names("""index desc desc_content desc_signature desc_type nodes._add_node_class_names("""index desc desc_content desc_signature desc_type
desc_classname desc_name desc_parameterlist desc_parameter desc_optional desc_classname desc_name desc_parameterlist desc_parameter desc_optional
centered versionmodified seealso productionlist production toctree centered versionmodified seealso productionlist production toctree
pending_xref compact_paragraph highlightlang literal_emphasis pending_xref compact_paragraph highlightlang literal_emphasis
glossary acks module""".split()) glossary acks module start_of_file tabular_col_spec""".split())

View File

@@ -775,6 +775,7 @@ class LaTeXBuilder(Builder):
self.warn('%s: toctree contains ref to nonexisting file %r' % self.warn('%s: toctree contains ref to nonexisting file %r' %
(docname, includefile)) (docname, includefile))
else: else:
newnodes.append(addnodes.start_of_file())
newnodes.extend(subtree.children) newnodes.extend(subtree.children)
toctreenode.parent.replace(toctreenode, newnodes) toctreenode.parent.replace(toctreenode, newnodes)
return tree return tree
@@ -813,7 +814,6 @@ class LaTeXBuilder(Builder):
# the logo is handled differently # the logo is handled differently
if self.config.latex_logo: if self.config.latex_logo:
logobase = path.basename(self.config.latex_logo) logobase = path.basename(self.config.latex_logo)
self.info(' '+logobase, nonl=1)
shutil.copyfile(path.join(self.confdir, self.config.latex_logo), shutil.copyfile(path.join(self.confdir, self.config.latex_logo),
path.join(self.outdir, logobase)) path.join(self.outdir, logobase))

View File

@@ -69,6 +69,7 @@ class Config(object):
latex_logo = (None, False), latex_logo = (None, False),
latex_preamble = ('', False), latex_preamble = ('', False),
latex_appendices = ([], False), latex_appendices = ([], False),
latex_use_parts = (False, False),
latex_use_modindex = (True, False), latex_use_modindex = (True, False),
) )

View File

@@ -815,3 +815,18 @@ def acks_directive(name, arguments, options, content, lineno,
acks_directive.content = 1 acks_directive.content = 1
acks_directive.arguments = (0, 0, 0) acks_directive.arguments = (0, 0, 0)
directives.register_directive('acks', acks_directive) directives.register_directive('acks', acks_directive)
# ------ tabularcolumns directive ---------------------------------------------------
def tabularcolumns_directive(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
# support giving explicit tabulary column definition to latex
node = addnodes.tabular_col_spec()
node['spec'] = arguments[0]
return [node]
tabularcolumns_directive.content = 0
tabularcolumns_directive.arguments = (1, 0, 1)
directives.register_directive('tabularcolumns', tabularcolumns_directive)

View File

@@ -264,6 +264,9 @@ class HTMLTranslator(BaseTranslator):
def visit_index(self, node): def visit_index(self, node):
raise nodes.SkipNode raise nodes.SkipNode
def visit_tabular_col_spec(self, node):
raise nodes.SkipNode
def visit_glossary(self, node): def visit_glossary(self, node):
pass pass
def depart_glossary(self, node): def depart_glossary(self, node):

View File

@@ -72,12 +72,14 @@ class LaTeXWriter(writers.Writer):
# Helper classes # Helper classes
class TableSpec: class Table(object):
def __init__(self): def __init__(self):
self.columnCount = 0 self.col = 0
self.firstRow = 1 self.colcount = 0
self.had_head = False
class Desc:
class Desc(object):
def __init__(self, node): def __init__(self, node):
self.env = LaTeXTranslator.desc_map.get(node['desctype'], 'describe') self.env = LaTeXTranslator.desc_map.get(node['desctype'], 'describe')
self.ni = node['noindex'] self.ni = node['noindex']
@@ -86,7 +88,7 @@ class Desc:
class LaTeXTranslator(nodes.NodeVisitor): class LaTeXTranslator(nodes.NodeVisitor):
sectionnames = ["chapter", "chapter", "section", "subsection", sectionnames = ["part", "chapter", "section", "subsection",
"subsubsection", "paragraph", "subparagraph"] "subsubsection", "paragraph", "subparagraph"]
def __init__(self, document, builder): def __init__(self, document, builder):
@@ -118,13 +120,19 @@ class LaTeXTranslator(nodes.NodeVisitor):
'latex', builder.config.pygments_style) 'latex', builder.config.pygments_style)
self.context = [] self.context = []
self.descstack = [] self.descstack = []
self.table = None
self.next_table_colspec = None
self.highlightlang = 'python' self.highlightlang = 'python'
self.highlightlinenothreshold = sys.maxint self.highlightlinenothreshold = sys.maxint
self.written_ids = set() self.written_ids = set()
if docclass == 'manual': if docclass == 'manual':
self.top_sectionlevel = 0 if builder.config.latex_use_parts:
self.top_sectionlevel = -1
else:
self.top_sectionlevel = 0
else: else:
self.top_sectionlevel = 1 self.top_sectionlevel = 1
self.next_section_target = None
# flags # flags
self.verbatim = None self.verbatim = None
self.in_title = 0 self.in_title = 0
@@ -141,20 +149,31 @@ class LaTeXTranslator(nodes.NodeVisitor):
(self.need_graphicx and GRAPHICX or '') + \ (self.need_graphicx and GRAPHICX or '') + \
'\n\n' + \ '\n\n' + \
u''.join(self.body) + \ u''.join(self.body) + \
(self.options['modindex'] and '\\printmodindex\n' or '') + \ (self.options['modindex'] and
'\\renewcommand{\\indexname}{Module Index}'
'\\printmodindex'
'\\renewcommand{\\indexname}{Index}\n' or '') + \
(FOOTER % self.options) (FOOTER % self.options)
def visit_document(self, node): def visit_document(self, node):
if self.first_document == 1: if self.first_document == 1:
# the first document is all the regular content ...
self.body.append('\\begin{document}\n\\maketitle\n\\tableofcontents\n') self.body.append('\\begin{document}\n\\maketitle\n\\tableofcontents\n')
self.first_document = 0 self.first_document = 0
elif self.first_document == 0: elif self.first_document == 0:
# ... and all others are the appendices
self.body.append('\n\\appendix\n') self.body.append('\n\\appendix\n')
self.first_document = -1 self.first_document = -1
self.sectionlevel = self.top_sectionlevel self.sectionlevel = self.top_sectionlevel
def depart_document(self, node): def depart_document(self, node):
pass pass
def visit_start_of_file(self, node):
# This marks the begin of a new file; therefore the current module and
# class must be reset
self.body.append('\n\\resetcurrentobjects\n')
raise nodes.SkipNode
def visit_highlightlang(self, node): def visit_highlightlang(self, node):
self.highlightlang = node['lang'] self.highlightlang = node['lang']
self.highlightlinenothreshold = node['linenothreshold'] self.highlightlinenothreshold = node['linenothreshold']
@@ -167,11 +186,14 @@ class LaTeXTranslator(nodes.NodeVisitor):
if not self.this_is_the_title: if not self.this_is_the_title:
self.sectionlevel += 1 self.sectionlevel += 1
self.body.append('\n\n') self.body.append('\n\n')
if node.get('ids'): if self.next_section_target:
for id in node['ids']: self.body.append(r'\hypertarget{%s}{}' % self.next_section_target)
if id not in self.written_ids: self.next_section_target = None
self.body.append(r'\hypertarget{%s}{}' % id) #if node.get('ids'):
self.written_ids.add(id) # for id in node['ids']:
# if id not in self.written_ids:
# self.body.append(r'\hypertarget{%s}{}' % id)
# self.written_ids.add(id)
def depart_section(self, node): def depart_section(self, node):
self.sectionlevel -= 1 self.sectionlevel -= 1
@@ -355,75 +377,64 @@ class LaTeXTranslator(nodes.NodeVisitor):
def visit_label(self, node): def visit_label(self, node):
raise nodes.SkipNode raise nodes.SkipNode
def visit_tabular_col_spec(self, node):
self.next_table_colspec = node['spec']
raise nodes.SkipNode
def visit_table(self, node): def visit_table(self, node):
self.tableSpec = TableSpec() if self.table:
raise NotImplementedError('Nested tables are not supported.')
self.table = Table()
self.body.append('\n\\begin{tabulary}{\\textwidth}')
def depart_table(self, node): def depart_table(self, node):
self.tableSpec = None self.body.append('\\end{tabulary}\n\n')
self.table = None
def visit_colspec(self, node): def visit_colspec(self, node):
pass self.table.colcount += 1
def depart_colspec(self, node): def depart_colspec(self, node):
pass pass
def visit_tgroup(self, node): def visit_tgroup(self, node):
columnCount = int(node.get('cols', 0)) pass
self.tableSpec.columnCount = columnCount
if columnCount == 2:
self.body.append('\\begin{tableii}{l|l}{textrm}')
elif columnCount == 3:
self.body.append('\\begin{tableiii}{l|l|l}{textrm}')
elif columnCount == 4:
self.body.append('\\begin{tableiv}{l|l|l|l}{textrm}')
elif columnCount == 5:
self.body.append('\\begin{tablev}{l|l|l|l|l}{textrm}')
else:
self.builder.warn('table with too many columns, ignoring')
raise nodes.SkipNode
def depart_tgroup(self, node): def depart_tgroup(self, node):
if self.tableSpec.columnCount == 2: pass
self.body.append('\n\\end{tableii}\n\n')
elif self.tableSpec.columnCount == 3:
self.body.append('\n\\end{tableiii}\n\n')
elif self.tableSpec.columnCount == 4:
self.body.append('\n\\end{tableiv}\n\n')
elif self.tableSpec.columnCount == 5:
self.body.append('\n\\end{tablev}\n\n')
def visit_thead(self, node): def visit_thead(self, node):
pass if self.next_table_colspec:
self.body.append('{%s}\n' % self.next_table_colspec)
else:
self.body.append('{|' + ('L|' * self.table.colcount) + '}\n')
self.next_table_colspec = None
self.body.append('\\hline\n')
self.table.had_head = True
def depart_thead(self, node): def depart_thead(self, node):
pass self.body.append('\\hline\n')
def visit_tbody(self, node): def visit_tbody(self, node):
pass if not self.table.had_head:
self.visit_thead(node)
def depart_tbody(self, node): def depart_tbody(self, node):
pass self.body.append('\\hline\n')
def visit_row(self, node): def visit_row(self, node):
if not self.tableSpec.firstRow: self.table.col = 0
if self.tableSpec.columnCount == 2:
self.body.append('\n\\lineii')
elif self.tableSpec.columnCount == 3:
self.body.append('\n\\lineiii')
elif self.tableSpec.columnCount == 4:
self.body.append('\n\\lineiv')
elif self.tableSpec.columnCount == 5:
self.body.append('\n\\linev')
def depart_row(self, node): def depart_row(self, node):
if self.tableSpec.firstRow: self.body.append('\\\\\n')
self.tableSpec.firstRow = 0
def visit_entry(self, node): def visit_entry(self, node):
if self.tableSpec.firstRow: if node.has_key('morerows') or node.has_key('morecols'):
self.body.append('{%s}' % self.encode(node.astext().strip(' '))) raise NotImplementedError('Column or row spanning cells are not implemented.')
raise nodes.SkipNode if self.table.col > 0:
self.body.append(' & ')
self.table.col += 1
if isinstance(node.parent.parent, nodes.thead):
self.body.append('\\textbf{')
self.context.append('}')
else: else:
self.body.append('{') self.context.append('')
def depart_entry(self, node): def depart_entry(self, node):
if self.tableSpec.firstRow: self.body.append(self.context.pop()) # header
pass
else:
self.body.append('}')
def visit_acks(self, node): def visit_acks(self, node):
# this is a list in the source, but should be rendered as a # this is a list in the source, but should be rendered as a
@@ -591,25 +602,21 @@ class LaTeXTranslator(nodes.NodeVisitor):
# indexing uses standard LaTeX index markup, so the targets # indexing uses standard LaTeX index markup, so the targets
# will be generated differently # will be generated differently
if not id.startswith('index-'): if not id.startswith('index-'):
self.body.append(r'\hypertarget{%s}{' % id) self.body.append(r'\hypertarget{%s}{}' % id)
return '}'
return ''
if not (node.has_key('refuri') or node.has_key('refid') if node.has_key('refid') and node['refid'] not in self.written_ids:
or node.has_key('refname')): parindex = node.parent.index(node)
ctx = '' try:
for id in node['ids']: next = node.parent[parindex+1]
if id not in self.written_ids: if isinstance(next, nodes.section):
self.written_ids.add(id) self.next_section_target = node['refid']
ctx += add_target(id) return
self.context.append(ctx) except IndexError:
elif node.has_key('refid') and node['refid'] not in self.written_ids: pass
self.context.append(add_target(node['refid'])) add_target(node['refid'])
self.written_ids.add(node['refid']) self.written_ids.add(node['refid'])
else:
self.context.append('')
def depart_target(self, node): def depart_target(self, node):
self.body.append(self.context.pop()) pass
indextype_map = { indextype_map = {
'module': 'refmodindex', 'module': 'refmodindex',

View File

@@ -161,6 +161,10 @@ latex_documents = [
# the title page. # the title page.
#latex_logo = None #latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# Additional stuff for the LaTeX preamble. # Additional stuff for the LaTeX preamble.
#latex_preamble = '' #latex_preamble = ''

View File

@@ -50,7 +50,7 @@ bz2: tar-$(FMT)
clean: clean:
rm -f *.pdf *.dvi *.ps rm -f *.pdf *.dvi *.ps
rm -f *.log *.ind *.aux *.toc *.syn *.idx *.out *.ilg rm -f *.log *.ind *.aux *.toc *.syn *.idx *.out *.ilg *.pla
.PHONY: all all-pdf all-dvi all-ps clean .PHONY: all all-pdf all-dvi all-ps clean

View File

@@ -3,7 +3,7 @@
% %
\NeedsTeXFormat{LaTeX2e}[1995/12/01] \NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{howto}[1998/02/25 Document class (Python HOWTO)] \ProvidesClass{howto}[2008/05/01 Document class (Sphinx HOWTO)]
\RequirePackage{fancybox} \RequirePackage{fancybox}
@@ -12,44 +12,34 @@
\ProcessOptions\relax \ProcessOptions\relax
\LoadClass[twoside]{article} \LoadClass[twoside]{article}
\setcounter{secnumdepth}{1}
% Optional packages: % Set some sane defaults for section numbering depth and TOC depth. You can
% reset these counter in your preamble.
% %
% If processing of these documents fails at your TeX installation, \setcounter{secnumdepth}{2}
% these may be commented out (independently) to make things work.
% These are both supplied with the current version of the teTeX
% distribution. % The "fancyhdr" package makes nicer page footers reasonable to implement, and
% % is used to put the chapter and section information in the footers.
% The "fancyhdr" package makes nicer page footers reasonable to
% implement, and is used to put the chapter and section information in
% the footers.
% %
\RequirePackage{fancyhdr} \RequirePackage{fancyhdr}
% This gives us all the Python-specific markup that we really want. This should
% Required package: % come last. Do not change this.
%
% This gives us all the Python-specific markup that we really want.
% This should come last. Do not change this.
% %
\RequirePackage{sphinx} \RequirePackage{sphinx}
% This comes after python.sty because it otherwise defines its own % This comes after python.sty because it otherwise defines its own "seealso"
% "seealso" command. % command.
%
\RequirePackage{makeidx} \RequirePackage{makeidx}
% Support for module synopsis sections:
\newcommand{\py@ModSynopsisFilename}{\jobname.syn}
% Need to do one of these.... % Need to do one of these....
\newcommand{\py@doHorizontalRule}{\rule{\textwidth}{1pt}} \newcommand{\py@doHorizontalRule}{\rule{\textwidth}{1pt}}
% Change the title page to look a bit better, and fit in with the % Change the title page to look a bit better, and fit in with the fncychap
% fncychap ``Bjarne'' style a bit better. % ``Bjarne'' style a bit better.
% %
\renewcommand{\maketitle}{ \renewcommand{\maketitle}{
\py@doHorizontalRule \py@doHorizontalRule
@@ -90,16 +80,16 @@
\endgroup \endgroup
\py@doHorizontalRule \py@doHorizontalRule
\vspace{12pt} \vspace{12pt}
\py@doing@page@targetstrue
} }
% Fix the theindex environment to add an entry to the Table of % Fix the theindex environment to add an entry to the Table of Contents; this is
% Contents; this is much nicer than just having to jump to the end of % much nicer than just having to jump to the end of the book and flip around,
% the book and flip around, especially with multiple indexes. % especially with multiple indexes.
% %
\let\py@OldTheindex=\theindex \let\py@OldTheindex=\theindex
\renewcommand{\theindex}{ \renewcommand{\theindex}{
\clearpage \clearpage
\phantomsection
\py@OldTheindex \py@OldTheindex
\addcontentsline{toc}{section}{\indexname} \addcontentsline{toc}{section}{\indexname}
} }
@@ -108,6 +98,5 @@
\pagestyle{plain}}{ \pagestyle{plain}}{
\pagestyle{normal}} % start this way; change for \pagestyle{normal}} % start this way; change for
\pagenumbering{arabic} % ToC & chapters \pagenumbering{arabic} % ToC & chapters
\setcounter{secnumdepth}{2}
\thispagestyle{empty} \thispagestyle{empty}

View File

@@ -3,7 +3,7 @@
% %
\NeedsTeXFormat{LaTeX2e}[1995/12/01] \NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{manual}[1998/03/03 Document class (Python manual)] \ProvidesClass{manual}[2008/05/01 Document class (Sphinx manual)]
\RequirePackage{fancybox} \RequirePackage{fancybox}
@@ -12,54 +12,38 @@
\ProcessOptions\relax \ProcessOptions\relax
\LoadClass[twoside,openright]{report} \LoadClass[twoside,openright]{report}
\setcounter{secnumdepth}{2}
% Optional packages: % Set some sane defaults for section numbering depth and TOC depth. You can
% reset these counter in your preamble.
% %
% If processing of these documents fails at your TeX installation, \setcounter{secnumdepth}{2}
% these may be commented out (independently) to make things work. \setcounter{tocdepth}{1}
% These are both supplied with the current version of the teTeX
% distribution.
% % The "fancyhdr" package makes nicer page footers reasonable to implement, and
% The "fancyhdr" package makes nicer page footers reasonable to % is used to put the chapter and section information in the footers.
% implement, and is used to put the chapter and section information in
% the footers.
% %
\RequirePackage{fancyhdr} \RequirePackage{fancyhdr}
% Required packages: % The "fncychap" package is used to get the nice chapter headers.
%
% The "fncychap" package is used to get the nice chapter headers. The
% .sty file is distributed with Sphinx, so you should not need to disable
% it. You'd also end up with a mixed page style; uglier than stock LaTeX!
% %
\RequirePackage[Bjarne]{fncychap} \RequirePackage[Bjarne]{fncychap}
% Do horizontal rules it this way to match: % Do horizontal rules it this way to match:
\newcommand{\py@doHorizontalRule}{\mghrulefill{\RW}} \newcommand{\py@doHorizontalRule}{\mghrulefill{\RW}}
% This gives us all the Sphinx-specific markup that we really want. This should
% This gives us all the Sphinx-specific markup that we really want. % come last. Do not change this.
% This should come last. Do not change this.
% %
\RequirePackage{sphinx} \RequirePackage{sphinx}
% This comes after sphinx.sty because it otherwise defines its own % This comes after sphinx.sty because it otherwise defines its own "seealso"
% "seealso" command. % command.
%
\RequirePackage{makeidx} \RequirePackage{makeidx}
% Support for module synopsis sections: % Change the title page to look a bit better, and fit in with the fncychap
\newcommand{\py@ModSynopsisFilename}{\jobname\thechapter.syn} % ``Bjarne'' style a bit better.
\let\py@OldChapter=\chapter
\renewcommand{\chapter}{
\py@ProcessModSynopsis
\py@closeModSynopsisFile
\py@OldChapter
}
% Change the title page to look a bit better, and fit in with the
% fncychap ``Bjarne'' style a bit better.
% %
\renewcommand{\maketitle}{% \renewcommand{\maketitle}{%
\begin{titlepage}% \begin{titlepage}%
@@ -99,8 +83,8 @@
} }
% Catch the end of the {abstract} environment, but here make sure the % Catch the end of the {abstract} environment, but here make sure the abstract
% abstract is followed by a blank page if the 'openright' option is used. % is followed by a blank page if the 'openright' option is used.
% %
\let\py@OldEndAbstract=\endabstract \let\py@OldEndAbstract=\endabstract
\renewcommand{\endabstract}{ \renewcommand{\endabstract}{
@@ -113,10 +97,10 @@
\py@OldEndAbstract \py@OldEndAbstract
} }
% This wraps the \tableofcontents macro with all the magic to get the
% spacing right and have the right number of pages if the 'openright' % This wraps the \tableofcontents macro with all the magic to get the spacing
% option has been used. This eliminates a fair amount of crud in the % right and have the right number of pages if the 'openright' option has been
% individual document files. % used. This eliminates a fair amount of crud in the individual document files.
% %
\let\py@OldTableofcontents=\tableofcontents \let\py@OldTableofcontents=\tableofcontents
\renewcommand{\tableofcontents}{% \renewcommand{\tableofcontents}{%
@@ -136,23 +120,24 @@
}% }%
\pagenumbering{arabic}% \pagenumbering{arabic}%
\@ifundefined{fancyhf}{}{\pagestyle{normal}}% \@ifundefined{fancyhf}{}{\pagestyle{normal}}%
\py@doing@page@targetstrue%
} }
% This is needed to get the width of the section # area wide enough in the % This is needed to get the width of the section # area wide enough in the
% library reference. Doing it here keeps it the same for all the manuals. % library reference. Doing it here keeps it the same for all the manuals.
% %
\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.6em}} \renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.6em}}
\renewcommand*\l@subsection{\@dottedtocline{2}{4.1em}{3.5em}} \renewcommand*\l@subsection{\@dottedtocline{2}{4.1em}{3.5em}}
\setcounter{tocdepth}{1}
% Fix the theindex environment to add an entry to the Table of % Fix the theindex environment to add an entry to the Table of Contents; this is
% Contents; this is much nicer than just having to jump to the end of % much nicer than just having to jump to the end of the book and flip around,
% the book and flip around, especially with multiple indexes. % especially with multiple indexes.
% %
\let\py@OldTheindex=\theindex \let\py@OldTheindex=\theindex
\renewcommand{\theindex}{ \renewcommand{\theindex}{
\cleardoublepage \cleardoublepage
\phantomsection
\py@OldTheindex \py@OldTheindex
\addcontentsline{toc}{chapter}{\indexname} \addcontentsline{toc}{chapter}{\indexname}
} }

View File

@@ -6,20 +6,20 @@
% %
\NeedsTeXFormat{LaTeX2e}[1995/12/01] \NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{sphinx}[2007/12/30 LaTeX package (Sphinx markup)] \ProvidesPackage{sphinx}[2008/05/01 LaTeX package (Sphinx markup)]
\RequirePackage{textcomp} \RequirePackage{textcomp}
\RequirePackage{longtable}
\RequirePackage{times} \RequirePackage{times}
\RequirePackage{fancyvrb} \RequirePackage{fancyvrb}
\RequirePackage{titlesec} \RequirePackage{titlesec}
\RequirePackage{tabulary}
\RequirePackage{color} \RequirePackage{color}
% Define these colors to your liking in the preamble. % Redefine these colors to your liking in the preamble.
\definecolor{TitleColor}{rgb}{0.126,0.263,0.361} \definecolor{TitleColor}{rgb}{0.126,0.263,0.361}
\definecolor{InnerLinkColor}{rgb}{0.208,0.374,0.486} \definecolor{InnerLinkColor}{rgb}{0.208,0.374,0.486}
\definecolor{OuterLinkColor}{rgb}{0.216,0.439,0.388} \definecolor{OuterLinkColor}{rgb}{0.216,0.439,0.388}
% Define these colors to something not white if you want to have colored % Redefine these colors to something not white if you want to have colored
% background and border for code examples. % background and border for code examples.
\definecolor{VerbatimColor}{rgb}{1,1,1} \definecolor{VerbatimColor}{rgb}{1,1,1}
\definecolor{VerbatimBorderColor}{rgb}{1,1,1} \definecolor{VerbatimBorderColor}{rgb}{1,1,1}
@@ -47,17 +47,7 @@
%\renewcommand{\paperwidth}{8.5in} % typical squarish manual %\renewcommand{\paperwidth}{8.5in} % typical squarish manual
%\renewcommand{\paperwidth}{7in} % O'Reilly ``Programmming Python'' %\renewcommand{\paperwidth}{7in} % O'Reilly ``Programmming Python''
% If we ever want to indent paragraphs, this needs to be changed. % for PDF output, use maximal compression
% This is used inside the macros defined here instead of coding
% \noindent directly.
\let\py@parindent=\noindent
% for PDF output, use maximal compression & a lot of other stuff
% (test for PDF recommended by Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov>)
%
\newif\ifpy@doing@page@targets
\py@doing@page@targetsfalse
\newif\ifpdf\pdffalse \newif\ifpdf\pdffalse
\ifx\pdfoutput\undefined\else\ifcase\pdfoutput \ifx\pdfoutput\undefined\else\ifcase\pdfoutput
\let\py@NormalColor\relax \let\py@NormalColor\relax
@@ -65,85 +55,9 @@
\else \else
\pdftrue \pdftrue
\input{pdfcolor} \input{pdfcolor}
\let\py@LinkColor=\NavyBlue
\let\py@NormalColor=\Black \let\py@NormalColor=\Black
\def\py@TitleColor{\color{TitleColor}} \def\py@TitleColor{\color{TitleColor}}
\pdfcompresslevel=9 \pdfcompresslevel=9
\pdfpagewidth=\paperwidth % page width of PDF output
\pdfpageheight=\paperheight % page height of PDF output
%
% Pad the number with '0' to 3 digits wide so no page name is a prefix
% of any other.
%
\newcommand{\py@targetno}[1]{\ifnum#1<100 0\fi\ifnum#1<10 0\fi#1}
\newcommand{\py@pageno}{\py@targetno\thepage}
%
% This definition allows the entries in the page-view of the ToC to be
% active links. Some work, some don't.
%
\let\py@OldContentsline=\contentsline
%
% Backward compatibility hack: pdfTeX 0.13 defined \pdfannotlink,
% but it changed to \pdfstartlink in 0.14. This let's us use either
% version and still get useful behavior.
%
\@ifundefined{pdfstartlink}{
\let\pdfstartlink=\pdfannotlink
}{}
%
% The \py@parindent here is a hack -- we're forcing pdfTeX into
% horizontal mode since \pdfstartlink requires that.
\def\py@pdfstartlink{%
\ifvmode\py@parindent\fi%
\pdfstartlink%
}
%
% Macro that takes two args: the name to link to and the content of
% the link. This takes care of the PDF magic, getting the colors
% the same for each link, and avoids having lots of garbage all over
% this style file.
\newcommand{\py@linkToName}[2]{%
\py@pdfstartlink attr{/Border [0 0 0]} goto name{#1}%
\color{InnerLinkColor}#2\py@NormalColor%
\pdfendlink%
}
% Compute the padded page number separately since we end up with a pair of
% \relax tokens; this gets the right string computed and works.
\renewcommand{\contentsline}[3]{%
\def\my@pageno{\py@targetno{#3}}%
\py@OldContentsline{#1}{\py@linkToName{page\my@pageno}{#2}}{#3}%
}
\AtEndDocument{
\def\_{\string_}
\InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{}
}
\newcommand{\py@target}[1]{%
\ifpy@doing@page@targets%
{\pdfdest name{#1} xyz}%
\fi%
}
\let\py@OldLabel=\label
\renewcommand{\label}[1]{%
\py@OldLabel{#1}%
\py@target{label-#1}%
}
% This stuff adds a page# destination to every PDF page, where # is three
% digits wide, padded with leading zeros. This doesn't really help with
% the frontmatter, but does fine with the body.
%
% This is *heavily* based on the hyperref package.
%
\def\@begindvi{%
\unvbox \@begindvibox
\@hyperfixhead
}
\def\@hyperfixhead{%
\let\H@old@thehead\@thehead
\global\def\@foo{\py@target{page\py@pageno}}%
\expandafter\ifx\expandafter\@empty\H@old@thehead
\def\H@old@thehead{\hfil}\fi
\def\@thehead{\@foo\relax\H@old@thehead}%
}
\fi\fi \fi\fi
% Increase printable page size (copied from fullpage.sty) % Increase printable page size (copied from fullpage.sty)
@@ -341,36 +255,30 @@
% Add the defining entry for a module % Add the defining entry for a module
\newcommand{\py@modindex}[2]{% \newcommand{\py@modindex}[2]{%
\renewcommand{\py@thismodule}{#1} \renewcommand{\py@thismodule}{#1}
\index{#1@{\py@idxcode{#1}} (#2module)|textbf}% \index{#1@{\py@idxcode{#1}} (#2module)}%
\ifpy@UseModuleIndex% \ifpy@UseModuleIndex%
\@ifundefined{py@modplat@\py@thismodulekey}{ \@ifundefined{py@modplat@\py@thismodulekey}{
\write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}}{\thepage}}% \write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}|hyperpage}{\thepage}}%
}{\write\modindexfile{\protect\indexentry{#1@{\texttt{#1} % }{\write\modindexfile{\protect\indexentry{#1@{\texttt{#1 }%
\emph{(\py@platformof[\py@thismodulekey]{})}}}{\thepage}}% \emph{(\platformof{#1})}}|hyperpage}{\thepage}}%
} }
\fi% \fi%
} }
% "Current" keys
% Module synopsis processing -----------------------------------------------
%
\newcommand{\py@thisclass}{} \newcommand{\py@thisclass}{}
\newcommand{\py@thismodule}{} \newcommand{\py@thismodule}{}
\newcommand{\py@thismodulekey}{} \newcommand{\py@thismodulekey}{}
\newcommand{\py@thismoduletype}{} \newcommand{\py@thismoduletype}{}
% Module index types
\newcommand{\py@standardIndexModule}[1]{\py@modindex{#1}{standard }} \newcommand{\py@standardIndexModule}[1]{\py@modindex{#1}{standard }}
\newcommand{\py@builtinIndexModule}[1]{\py@modindex{#1}{built-in }} \newcommand{\py@builtinIndexModule}[1]{\py@modindex{#1}{built-in }}
\newcommand{\py@extensionIndexModule}[1]{\py@modindex{#1}{extension }} \newcommand{\py@extensionIndexModule}[1]{\py@modindex{#1}{extension }}
\newcommand{\py@IndexModule}[1]{\py@modindex{#1}{}} \newcommand{\py@IndexModule}[1]{\py@modindex{#1}{}}
\newif\ifpy@HaveModSynopsis \py@HaveModSynopsisfalse
\newif\ifpy@ModSynopsisFileIsOpen \py@ModSynopsisFileIsOpenfalse
\newif\ifpy@HaveModPlatform \py@HaveModPlatformfalse
% \declaremodule[key]{type}{name} % \declaremodule[key]{type}{name}
\newcommand{\declaremodule}[3][\py@modulebadkey]{ \newcommand{\declaremodule}[3][\py@modulebadkey]{
\py@openModSynopsisFile
\renewcommand{\py@thismoduletype}{#2} \renewcommand{\py@thismoduletype}{#2}
\ifx\py@modulebadkey#1 \ifx\py@modulebadkey#1
\renewcommand{\py@thismodulekey}{#3} \renewcommand{\py@thismodulekey}{#3}
@@ -383,9 +291,16 @@
}{% }{%
\csname py@#2IndexModule\endcsname{#3}% \csname py@#2IndexModule\endcsname{#3}%
} }
\label{module-\py@thismodulekey} %\label{module-\py@thismodulekey}
} }
% Record module platforms for the Module Index
\newif\ifpy@ModPlatformFileIsOpen \py@ModPlatformFileIsOpenfalse \newif\ifpy@ModPlatformFileIsOpen \py@ModPlatformFileIsOpenfalse
\long\def\py@writeModPlatformFile#1{%
\protected@write\py@ModPlatformFile%
{\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
{\string#1}%
}
\newcommand{\py@ModPlatformFilename}{\jobname.pla} \newcommand{\py@ModPlatformFilename}{\jobname.pla}
\newcommand{\platform}[1]{ \newcommand{\platform}[1]{
\ifpy@ModPlatformFileIsOpen\else \ifpy@ModPlatformFileIsOpen\else
@@ -393,15 +308,12 @@
\openout\py@ModPlatformFile=\py@ModPlatformFilename \openout\py@ModPlatformFile=\py@ModPlatformFilename
\py@ModPlatformFileIsOpentrue \py@ModPlatformFileIsOpentrue
\fi \fi
\py@writeModPlatformFile{\py@defplatform{\py@thismodulekey}{#1}}
} }
\newcommand{\py@defplatform}[2]{\expandafter\def\csname py@modplat@#1\endcsname{#2}}
\newcommand{\platformof}[1]{\csname py@modplat@#1\endcsname}
\InputIfFileExists{\jobname.pla}{}{} \InputIfFileExists{\jobname.pla}{}{}
\newcommand{\py@platformof}[2][\py@modulebadkey]{%
\ifx\py@modulebadkey#1 \def\py@key{#2}%
\else \def\py@key{#1}%
\fi%
\csname py@modplat@\py@key\endcsname%
}
\newcommand{\ignorePlatformAnnotation}[1]{}
% \moduleauthor{name}{email} % \moduleauthor{name}{email}
\newcommand{\moduleauthor}[2]{} \newcommand{\moduleauthor}[2]{}
@@ -409,83 +321,11 @@
% \sectionauthor{name}{email} % \sectionauthor{name}{email}
\newcommand{\sectionauthor}[2]{} \newcommand{\sectionauthor}[2]{}
% Ignore module synopsis.
\newcommand{\modulesynopsis}[1]{}
\newcommand{\py@defsynopsis}{Module has no synopsis.} % Reset "current" objects.
\newcommand{\py@modulesynopsis}{\py@defsynopsis} \newcommand{\resetcurrentobjects}{
\newcommand{\modulesynopsis}[1]{
\py@HaveModSynopsistrue
\renewcommand{\py@modulesynopsis}{#1}
}
% define the file
\newwrite\py@ModSynopsisFile
% hacked from \addtocontents from latex.ltx:
\long\def\py@writeModSynopsisFile#1{%
\protected@write\py@ModSynopsisFile%
{\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
{\string#1}%
}
\newcommand{\py@closeModSynopsisFile}{
\ifpy@ModSynopsisFileIsOpen
\closeout\py@ModSynopsisFile
\py@ModSynopsisFileIsOpenfalse
\fi
}
\newcommand{\py@openModSynopsisFile}{
\ifpy@ModSynopsisFileIsOpen\else
\openout\py@ModSynopsisFile=\py@ModSynopsisFilename
\py@ModSynopsisFileIsOpentrue
\fi
}
\newcommand{\py@ProcessModSynopsis}{
\ifpy@HaveModSynopsis
\py@writeModSynopsisFile{\modulesynopsis%
{\py@thismodulekey}{\py@thismodule}%
{\py@thismoduletype}{\py@modulesynopsis}}%
\py@HaveModSynopsisfalse
\fi
\renewcommand{\py@modulesynopsis}{\py@defsynopsis}
}
\AtEndDocument{\py@ProcessModSynopsis\py@closeModSynopsisFile}
\long\def\py@writeModPlatformFile#1{%
\protected@write\py@ModPlatformFile%
{\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
{\string#1}%
}
\newcommand{\localmoduletable}{
\IfFileExists{\py@ModSynopsisFilename}{
\begin{synopsistable}
\input{\py@ModSynopsisFilename}
\end{synopsistable}
}{}
}
\ifpdf
\newcommand{\py@ModSynopsisSummary}[4]{%
\py@linkToName{label-module-#1}{\bfcode{#2}} & #4\\
}
\else
\newcommand{\py@ModSynopsisSummary}[4]{\bfcode{#2} & #4\\}
\fi
\newenvironment{synopsistable}{
% key, name, type, synopsis
\let\modulesynopsis=\py@ModSynopsisSummary
\begin{tabular}{ll}
}{
\end{tabular}
}
%
% --------------------------------------------------------------------------
\newcommand{\py@reset}{
\py@ProcessModSynopsis
\renewcommand{\py@thisclass}{} \renewcommand{\py@thisclass}{}
\renewcommand{\py@thismodule}{} \renewcommand{\py@thismodule}{}
\renewcommand{\py@thismodulekey}{} \renewcommand{\py@thismodulekey}{}
@@ -495,7 +335,7 @@
% Augment the sectioning commands used to get our own font family in place, % Augment the sectioning commands used to get our own font family in place,
% and reset some internal data items: % and reset some internal data items:
\titleformat{\section}{\Large\py@HeaderFamily\py@TitleColor}% \titleformat{\section}{\Large\py@HeaderFamily\py@TitleColor}%
{\thesection}{-1em}{\py@reset}{\py@NormalColor} {\thesection}{0.5em}{}{\py@NormalColor}
\titleformat{\subsection}{\large\py@HeaderFamily\py@TitleColor}% \titleformat{\subsection}{\large\py@HeaderFamily\py@TitleColor}%
{\thesubsection}{0.5em}{}{\py@NormalColor} {\thesubsection}{0.5em}{}{\py@NormalColor}
\titleformat{\subsubsection}{\py@HeaderFamily\py@TitleColor}% \titleformat{\subsubsection}{\py@HeaderFamily\py@TitleColor}%
@@ -881,88 +721,6 @@
} }
% Tables.
%
\newenvironment{tableii}[4]{%
\begin{center}%
\def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
\begin{tabular}{#1}\strong{#3}&\strong{#4} \\* \hline%
}{%
\end{tabular}%
\end{center}%
}
\newenvironment{longtableii}[4]{%
\begin{center}%
\def\lineii##1##2{\csname#2\endcsname{##1}&##2\\}%
\begin{longtable}[c]{#1}\strong{#3}&\strong{#4} \\* \hline\endhead%
}{%
\end{longtable}%
\end{center}%
}
\newenvironment{tableiii}[5]{%
\begin{center}%
\def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
\begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5} \\%
\hline%
}{%
\end{tabular}%
\end{center}%
}
\newenvironment{longtableiii}[5]{%
\begin{center}%
\def\lineiii##1##2##3{\csname#2\endcsname{##1}&##2&##3\\}%
\begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5} \\%
\hline\endhead%
}{%
\end{longtable}%
\end{center}%
}
\newenvironment{tableiv}[6]{%
\begin{center}%
\def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}%
\begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6} \\%
\hline%
}{%
\end{tabular}%
\end{center}%
}
\newenvironment{longtableiv}[6]{%
\begin{center}%
\def\lineiv##1##2##3##4{\csname#2\endcsname{##1}&##2&##3&##4\\}%
\begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}%
\\%
\hline\endhead%
}{%
\end{longtable}%
\end{center}%
}
\newenvironment{tablev}[7]{%
\begin{center}%
\def\linev##1##2##3##4##5{\csname#2\endcsname{##1}&##2&##3&##4&##5\\}%
\begin{tabular}{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}&\strong{#7} \\%
\hline%
}{%
\end{tabular}%
\end{center}%
}
\newenvironment{longtablev}[7]{%
\begin{center}%
\def\linev##1##2##3##4##5{\csname#2\endcsname{##1}&##2&##3&##4&##5\\}%
\begin{longtable}[c]{#1}\strong{#3}&\strong{#4}&\strong{#5}&\strong{#6}&\strong{#7}%
\\%
\hline\endhead%
}{%
\end{longtable}%
\end{center}%
}
% See-also environment % See-also environment
\newenvironment{seealso}{ \newenvironment{seealso}{
\par \par

View File

@@ -0,0 +1,449 @@
%%
%% This is file `tabulary.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tabulary.dtx (with options: `package')
%% DRAFT VERSION
%%
%% File `tabulary.dtx'.
%% Copyright (C) 1995 1996 2003 David Carlisle
%% This file may be distributed under the terms of the LPPL.
%% See 00readme.txt for details.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tabulary}
[2007/10/02 v0.9 tabulary package (DPC)]
\RequirePackage{array}
\catcode`\Z=14
\DeclareOption{debugshow}{\catcode`\Z=9\relax}
\ProcessOptions
\def\arraybackslash{\let\\=\@arraycr}
\def\@finalstrut#1{%
\unskip\ifhmode\nobreak\fi\vrule\@width\z@\@height\z@\@depth\dp#1}
\newcount\TY@count
\def\tabulary{%
\let\TY@final\tabular
\let\endTY@final\endtabular
\TY@tabular}
\def\TY@tabular#1{%
\edef\TY@{\@currenvir}%
{\ifnum0=`}\fi
\@ovxx\TY@linewidth
\@ovyy\TY@tablewidth
\count@\z@
\@tempswatrue
\@whilesw\if@tempswa\fi{%
\advance\count@\@ne
\expandafter\ifx\csname TY@F\the\count@\endcsname\relax
\@tempswafalse
\else
\expandafter\let\csname TY@SF\the\count@\expandafter\endcsname
\csname TY@F\the\count@\endcsname
\global\expandafter\let\csname TY@F\the\count@\endcsname\relax
\expandafter\let\csname TY@S\the\count@\expandafter\endcsname
\csname TY@\the\count@\endcsname
\fi}%
\global\TY@count\@ne
\TY@width\xdef{0pt}%
\global\TY@tablewidth\z@
\global\TY@linewidth#1\relax
Z\message{^^J^^JTable^^J%
Z Target Width: \the\TY@linewidth^^J%
Z \string\tabcolsep: \the\tabcolsep\space
Z \string\arrayrulewidth: \the\arrayrulewidth\space
Z \string\doublerulesep: \the\doublerulesep^^J%
Z \string\tymin: \the\tymin\space
Z \string\tymax: \the\tymax^^J}%
\let\@classz\TY@classz
\let\verb\TX@verb
\toks@{}\TY@get@body}
\let\TY@@mkpream\@mkpream
\def\TY@mkpream{%
\def\@addamp{%
\if@firstamp \@firstampfalse \else
\global\advance\TY@count\@ne
\edef\@preamble{\@preamble &}\fi
\TY@width\xdef{0pt}}%
\def\@acol{%
\TY@subwidth\col@sep
\@addtopreamble{\hskip\col@sep}}%
\let\@arrayrule\TY@arrayrule
\let\@classvi\TY@classvi
\def\@classv{\save@decl
\expandafter\NC@ecs\@nextchar\extracolsep{}\extracolsep\@@@
\sbox\z@{\d@llarbegin\@nextchar\d@llarend}%
\TY@subwidth{\wd\z@}%
\@addtopreamble{\d@llarbegin\the@toks\the\count@\relax\d@llarend}%
\prepnext@tok}%
\global\let\@mkpream\TY@@mkpream
\TY@@mkpream}
\def\TY@arrayrule{%
\TY@subwidth\arrayrulewidth
\@addtopreamble \vline}
\def\TY@classvi{\ifcase \@lastchclass
\@acol \or
\TY@subwidth\doublerulesep
\@addtopreamble{\hskip \doublerulesep}\or
\@acol \or
\@classvii
\fi}
\def\TY@tab{%
\setbox\z@\hbox\bgroup
\let\[$\let\]$%
\let\equation$\let\endequation$%
\col@sep\tabcolsep
\let\d@llarbegin\begingroup\let\d@llarend\endgroup
\let\@mkpream\TY@mkpream
\def\multicolumn##1##2##3{\multispan##1\relax}%
\CT@start\TY@tabarray}
\def\TY@tabarray{\@ifnextchar[{\TY@array}{\@array[t]}}
\def\TY@array[#1]{\@array[t]}
\def\TY@width#1{%
\expandafter#1\csname TY@\the\TY@count\endcsname}
\def\TY@subwidth#1{%
\TY@width\dimen@
\advance\dimen@-#1\relax
\TY@width\xdef{\the\dimen@}%
\global\advance\TY@linewidth-#1\relax}
\def\endtabulary{%
\gdef\@halignto{}%
\expandafter\TY@tab\the\toks@
\crcr\omit
{\xdef\TY@save@row{}%
\loop
\advance\TY@count\m@ne
\ifnum\TY@count>\z@
\xdef\TY@save@row{\TY@save@row&\omit}%
\repeat}\TY@save@row
\endarray\global\setbox1=\lastbox\setbox0=\vbox{\unvbox1
\unskip\global\setbox1=\lastbox}\egroup
\dimen@\TY@linewidth
\divide\dimen@\TY@count
\ifdim\dimen@<\tymin
\TY@warn{tymin too large (\the\tymin), resetting to \the\dimen@}%
\tymin\dimen@
\fi
\setbox\tw@=\hbox{\unhbox\@ne
\loop
\@tempdima=\lastskip
\ifdim\@tempdima>\z@
Z \message{ecs=\the\@tempdima^^J}%
\global\advance\TY@linewidth-\@tempdima
\fi
\unskip
\setbox\tw@=\lastbox
\ifhbox\tw@
Z \message{Col \the\TY@count: Initial=\the\wd\tw@\space}%
\ifdim\wd\tw@>\tymax
\wd\tw@\tymax
Z \message{> max\space}%
Z \else
Z \message{ \@spaces\space}%
\fi
\TY@width\dimen@
Z \message{\the\dimen@\space}%
\advance\dimen@\wd\tw@
Z \message{Final=\the\dimen@\space}%
\TY@width\xdef{\the\dimen@}%
\ifdim\dimen@<\tymin
Z \message{< tymin}%
\global\advance\TY@linewidth-\dimen@
\expandafter\xdef\csname TY@F\the\TY@count\endcsname
{\the\dimen@}%
\else
\expandafter\ifx\csname TY@F\the\TY@count\endcsname\z@
Z \message{***}%
\global\advance\TY@linewidth-\dimen@
\expandafter\xdef\csname TY@F\the\TY@count\endcsname
{\the\dimen@}%
\else
Z \message{> tymin}%
\global\advance\TY@tablewidth\dimen@
\global\expandafter\let\csname TY@F\the\TY@count\endcsname
\maxdimen
\fi\fi
\advance\TY@count\m@ne
\repeat}%
\TY@checkmin
\TY@checkmin
\TY@checkmin
\TY@checkmin
\TY@count\z@
\let\TY@box\TY@box@v
{\expandafter\TY@final\the\toks@\endTY@final}%
\count@\z@
\@tempswatrue
\@whilesw\if@tempswa\fi{%
\advance\count@\@ne
\expandafter\ifx\csname TY@SF\the\count@\endcsname\relax
\@tempswafalse
\else
\global\expandafter\let\csname TY@F\the\count@\expandafter\endcsname
\csname TY@SF\the\count@\endcsname
\global\expandafter\let\csname TY@\the\count@\expandafter\endcsname
\csname TY@S\the\count@\endcsname
\fi}%
\TY@linewidth\@ovxx
\TY@tablewidth\@ovyy
\ifnum0=`{\fi}}
\def\TY@checkmin{%
\let\TY@checkmin\relax
\ifdim\TY@tablewidth>\z@
\Gscale@div\TY@ratio\TY@linewidth\TY@tablewidth
\ifdim\TY@tablewidth <\linewidth
\def\TY@ratio{1}%
\fi
\else
\TY@warn{No suitable columns!}%
\def\TY@ratio{1}%
\fi
\count@\z@
Z \message{^^JLine Width: \the\TY@linewidth,
Z Natural Width: \the\TY@tablewidth,
Z Ratio: \TY@ratio^^J}%
\@tempdima\z@
\loop
\ifnum\count@<\TY@count
\advance\count@\@ne
\ifdim\csname TY@F\the\count@\endcsname>\tymin
\dimen@\csname TY@\the\count@\endcsname
\dimen@\TY@ratio\dimen@
\ifdim\dimen@<\tymin
Z \message{Column \the\count@\space ->}%
\global\expandafter\let\csname TY@F\the\count@\endcsname\tymin
\global\advance\TY@linewidth-\tymin
\global\advance\TY@tablewidth-\csname TY@\the\count@\endcsname
\let\TY@checkmin\TY@@checkmin
\else
\expandafter\xdef\csname TY@F\the\count@\endcsname{\the\dimen@}%
\advance\@tempdima\csname TY@F\the\count@\endcsname
\fi
\fi
Z \dimen@\csname TY@F\the\count@\endcsname\message{\the\dimen@, }%
\repeat
Z \message{^^JTotal:\the\@tempdima^^J}%
}
\let\TY@@checkmin\TY@checkmin
\newdimen\TY@linewidth
\def\tyformat{\everypar{{\nobreak\hskip\z@skip}}}
\newdimen\tymin
\tymin=10pt
\newdimen\tymax
\tymax=2\textwidth
\def\@testpach{\@chclass
\ifnum \@lastchclass=6 \@ne \@chnum \@ne \else
\ifnum \@lastchclass=7 5 \else
\ifnum \@lastchclass=8 \tw@ \else
\ifnum \@lastchclass=9 \thr@@
\else \z@
\ifnum \@lastchclass = 10 \else
\edef\@nextchar{\expandafter\string\@nextchar}%
\@chnum
\if \@nextchar c\z@ \else
\if \@nextchar l\@ne \else
\if \@nextchar r\tw@ \else
\if \@nextchar C7 \else
\if \@nextchar L8 \else
\if \@nextchar R9 \else
\if \@nextchar J10 \else
\z@ \@chclass
\if\@nextchar |\@ne \else
\if \@nextchar !6 \else
\if \@nextchar @7 \else
\if \@nextchar <8 \else
\if \@nextchar >9 \else
10
\@chnum
\if \@nextchar m\thr@@\else
\if \@nextchar p4 \else
\if \@nextchar b5 \else
\z@ \@chclass \z@ \@preamerr \z@ \fi \fi \fi \fi\fi \fi \fi\fi \fi
\fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi}
\def\TY@classz{%
\@classx
\@tempcnta\count@
\ifx\TY@box\TY@box@v
\global\advance\TY@count\@ne
\fi
\let\centering c%
\let\raggedright\noindent
\let\raggedleft\indent
\let\arraybackslash\relax
\prepnext@tok
\ifnum\@chnum<4
\global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@
\fi
\ifnum\@chnum=6
\global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@
\fi
\@addtopreamble{%
\ifcase\@chnum
\hfil \d@llarbegin\insert@column\d@llarend \hfil \or
\kern\z@
\d@llarbegin \insert@column \d@llarend \hfil \or
\hfil\kern\z@ \d@llarbegin \insert@column \d@llarend \or
$\vcenter\@startpbox{\@nextchar}\insert@column \@endpbox $\or
\vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or
\vbox \@startpbox{\@nextchar}\insert@column \@endpbox \or
\d@llarbegin \insert@column \d@llarend \or% dubious "s" case
\TY@box\centering\or
\TY@box\raggedright\or
\TY@box\raggedleft\or
\TY@box\relax
\fi}\prepnext@tok}
\def\TY@box#1{%
\ifx\centering#1%
\hfil \d@llarbegin\insert@column\d@llarend \hfil \else
\ifx\raggedright#1%
\kern\z@%<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
\d@llarbegin \insert@column \d@llarend \hfil \else
\ifx\raggedleft#1%
\hfil\kern\z@ \d@llarbegin \insert@column \d@llarend \else
\ifx\relax#1%
\d@llarbegin \insert@column \d@llarend
\fi \fi \fi \fi}
\def\TY@box@v#1{%
\vtop \@startpbox{\csname TY@F\the\TY@count\endcsname}%
#1\arraybackslash\tyformat
\insert@column\@endpbox}
\newdimen\TY@tablewidth
\def\Gscale@div#1#2#3{%
\setlength\dimen@{#3}%
\ifdim\dimen@=\z@
\PackageError{graphics}{Division by 0}\@eha
\dimen@#2%
\fi
\edef\@tempd{\the\dimen@}%
\setlength\dimen@{#2}%
\count@65536\relax
\ifdim\dimen@<\z@
\dimen@-\dimen@
\count@-\count@
\fi
\loop
\ifdim\dimen@<8192\p@
\dimen@\tw@\dimen@
\divide\count@\tw@
\repeat
\dimen@ii=\@tempd\relax
\divide\dimen@ii\count@
\divide\dimen@\dimen@ii
\edef#1{\strip@pt\dimen@}}
\long\def\TY@get@body#1\end
{\toks@\expandafter{\the\toks@#1}\TY@find@end}
\def\TY@find@end#1{%
\def\@tempa{#1}%
\ifx\@tempa\TY@\def\@tempa{\end{#1}}\expandafter\@tempa
\else\toks@\expandafter
{\the\toks@\end{#1}}\expandafter\TY@get@body\fi}
\def\TY@warn{%
\PackageWarning{tabulary}}
\catcode`\Z=11
\AtBeginDocument{
\@ifpackageloaded{colortbl}{%
\expandafter\def\expandafter\@mkpream\expandafter#\expandafter1%
\expandafter{%
\expandafter\let\expandafter\CT@setup\expandafter\relax
\expandafter\let\expandafter\CT@color\expandafter\relax
\expandafter\let\expandafter\CT@do@color\expandafter\relax
\expandafter\let\expandafter\color\expandafter\relax
\expandafter\let\expandafter\CT@column@color\expandafter\relax
\expandafter\let\expandafter\CT@row@color\expandafter\relax
\@mkpream{#1}}
\let\TY@@mkpream\@mkpream
\def\TY@classz{%
\@classx
\@tempcnta\count@
\ifx\TY@box\TY@box@v
\global\advance\TY@count\@ne
\fi
\let\centering c%
\let\raggedright\noindent
\let\raggedleft\indent
\let\arraybackslash\relax
\prepnext@tok
\expandafter\CT@extract\the\toks\@tempcnta\columncolor!\@nil
\ifnum\@chnum<4
\global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@
\fi
\ifnum\@chnum=6
\global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@
\fi
\@addtopreamble{%
\setbox\z@\hbox\bgroup\bgroup
\ifcase\@chnum
\hskip\stretch{.5}\kern\z@
\d@llarbegin\insert@column\d@llarend\hskip\stretch{.5}\or
\kern\z@%<<<<<<<<<<<<<<<<<<<<<<<<<<<
\d@llarbegin \insert@column \d@llarend \hfill \or
\hfill\kern\z@ \d@llarbegin \insert@column \d@llarend \or
$\vcenter\@startpbox{\@nextchar}\insert@column \@endpbox $\or
\vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or
\vbox \@startpbox{\@nextchar}\insert@column \@endpbox \or
\d@llarbegin \insert@column \d@llarend \or% dubious s case
\TY@box\centering\or
\TY@box\raggedright\or
\TY@box\raggedleft\or
\TY@box\relax
\fi
\egroup\egroup
\begingroup
\CT@setup
\CT@column@color
\CT@row@color
\CT@do@color
\endgroup
\@tempdima\ht\z@
\advance\@tempdima\minrowclearance
\vrule\@height\@tempdima\@width\z@
\unhbox\z@
}\prepnext@tok}%
\def\TY@arrayrule{%
\TY@subwidth\arrayrulewidth
\@addtopreamble{{\CT@arc@\vline}}}%
\def\TY@classvi{\ifcase \@lastchclass
\@acol \or
\TY@subwidth\doublerulesep
\ifx\CT@drsc@\relax
\@addtopreamble{\hskip\doublerulesep}%
\else
\@addtopreamble{{\CT@drsc@\vrule\@width\doublerulesep}}%
\fi\or
\@acol \or
\@classvii
\fi}%
}{%
\let\CT@start\relax
}
}
{\uccode`\*=`\ %
\uppercase{\gdef\TX@verb{%
\leavevmode\null\TX@vwarn
{\ifnum0=`}\fi\ttfamily\let\\\ignorespaces
\@ifstar{\let~*\TX@vb}{\TX@vb}}}}
\def\TX@vb#1{\def\@tempa##1#1{\toks@{##1}\edef\@tempa{\the\toks@}%
\expandafter\TX@v\meaning\@tempa\\ \\\ifnum0=`{\fi}}\@tempa!}
\def\TX@v#1!{\afterassignment\TX@vfirst\let\@tempa= }
\begingroup
\catcode`\*=\catcode`\#
\catcode`\#=12
\gdef\TX@vfirst{%
\if\@tempa#%
\def\@tempb{\TX@v@#}%
\else
\let\@tempb\TX@v@
\if\@tempa\space~\else\@tempa\fi
\fi
\@tempb}
\gdef\TX@v@*1 *2{%
\TX@v@hash*1##\relax\if*2\\\else~\expandafter\TX@v@\fi*2}
\gdef\TX@v@hash*1##*2{*1\ifx*2\relax\else#\expandafter\TX@v@hash\fi*2}
\endgroup
\def\TX@vwarn{%
\@warning{\noexpand\verb may be unreliable inside tabularx/y}%
\global\let\TX@vwarn\@empty}
\endinput
%%
%% End of file `tabulary.sty'.