* 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
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
----------
@ -22,6 +28,8 @@ Bugs fixed
master document. Also encode non-ASCII characters as entities in TOC
and index file.
* Lots of little fixes to the LaTeX output and style.
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_use_parts = True
# Additional stuff for the 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
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
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:
.. tabularcolumns:: |l|L|L|
====================== =================================== =========
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
:confval:`show_authors` to True to make them produce a paragraph in the
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
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
nodes._add_node_class_names("""index desc desc_content desc_signature desc_type
desc_classname desc_name desc_parameterlist desc_parameter desc_optional
centered versionmodified seealso productionlist production toctree
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' %
(docname, includefile))
else:
newnodes.append(addnodes.start_of_file())
newnodes.extend(subtree.children)
toctreenode.parent.replace(toctreenode, newnodes)
return tree
@ -813,7 +814,6 @@ class LaTeXBuilder(Builder):
# the logo is handled differently
if 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),
path.join(self.outdir, logobase))

View File

@ -69,6 +69,7 @@ class Config(object):
latex_logo = (None, False),
latex_preamble = ('', False),
latex_appendices = ([], False),
latex_use_parts = (False, 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.arguments = (0, 0, 0)
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):
raise nodes.SkipNode
def visit_tabular_col_spec(self, node):
raise nodes.SkipNode
def visit_glossary(self, node):
pass
def depart_glossary(self, node):

View File

@ -72,12 +72,14 @@ class LaTeXWriter(writers.Writer):
# Helper classes
class TableSpec:
class Table(object):
def __init__(self):
self.columnCount = 0
self.firstRow = 1
self.col = 0
self.colcount = 0
self.had_head = False
class Desc:
class Desc(object):
def __init__(self, node):
self.env = LaTeXTranslator.desc_map.get(node['desctype'], 'describe')
self.ni = node['noindex']
@ -86,7 +88,7 @@ class Desc:
class LaTeXTranslator(nodes.NodeVisitor):
sectionnames = ["chapter", "chapter", "section", "subsection",
sectionnames = ["part", "chapter", "section", "subsection",
"subsubsection", "paragraph", "subparagraph"]
def __init__(self, document, builder):
@ -118,13 +120,19 @@ class LaTeXTranslator(nodes.NodeVisitor):
'latex', builder.config.pygments_style)
self.context = []
self.descstack = []
self.table = None
self.next_table_colspec = None
self.highlightlang = 'python'
self.highlightlinenothreshold = sys.maxint
self.written_ids = set()
if docclass == 'manual':
self.top_sectionlevel = 0
if builder.config.latex_use_parts:
self.top_sectionlevel = -1
else:
self.top_sectionlevel = 0
else:
self.top_sectionlevel = 1
self.next_section_target = None
# flags
self.verbatim = None
self.in_title = 0
@ -141,20 +149,31 @@ class LaTeXTranslator(nodes.NodeVisitor):
(self.need_graphicx and GRAPHICX or '') + \
'\n\n' + \
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)
def visit_document(self, node):
if self.first_document == 1:
# the first document is all the regular content ...
self.body.append('\\begin{document}\n\\maketitle\n\\tableofcontents\n')
self.first_document = 0
elif self.first_document == 0:
# ... and all others are the appendices
self.body.append('\n\\appendix\n')
self.first_document = -1
self.sectionlevel = self.top_sectionlevel
def depart_document(self, node):
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):
self.highlightlang = node['lang']
self.highlightlinenothreshold = node['linenothreshold']
@ -167,11 +186,14 @@ class LaTeXTranslator(nodes.NodeVisitor):
if not self.this_is_the_title:
self.sectionlevel += 1
self.body.append('\n\n')
if node.get('ids'):
for id in node['ids']:
if id not in self.written_ids:
self.body.append(r'\hypertarget{%s}{}' % id)
self.written_ids.add(id)
if self.next_section_target:
self.body.append(r'\hypertarget{%s}{}' % self.next_section_target)
self.next_section_target = None
#if node.get('ids'):
# 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):
self.sectionlevel -= 1
@ -355,75 +377,64 @@ class LaTeXTranslator(nodes.NodeVisitor):
def visit_label(self, node):
raise nodes.SkipNode
def visit_tabular_col_spec(self, node):
self.next_table_colspec = node['spec']
raise nodes.SkipNode
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):
self.tableSpec = None
self.body.append('\\end{tabulary}\n\n')
self.table = None
def visit_colspec(self, node):
pass
self.table.colcount += 1
def depart_colspec(self, node):
pass
def visit_tgroup(self, node):
columnCount = int(node.get('cols', 0))
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
pass
def depart_tgroup(self, node):
if self.tableSpec.columnCount == 2:
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')
pass
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):
pass
self.body.append('\\hline\n')
def visit_tbody(self, node):
pass
if not self.table.had_head:
self.visit_thead(node)
def depart_tbody(self, node):
pass
self.body.append('\\hline\n')
def visit_row(self, node):
if not self.tableSpec.firstRow:
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')
self.table.col = 0
def depart_row(self, node):
if self.tableSpec.firstRow:
self.tableSpec.firstRow = 0
self.body.append('\\\\\n')
def visit_entry(self, node):
if self.tableSpec.firstRow:
self.body.append('{%s}' % self.encode(node.astext().strip(' ')))
raise nodes.SkipNode
if node.has_key('morerows') or node.has_key('morecols'):
raise NotImplementedError('Column or row spanning cells are not implemented.')
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:
self.body.append('{')
self.context.append('')
def depart_entry(self, node):
if self.tableSpec.firstRow:
pass
else:
self.body.append('}')
self.body.append(self.context.pop()) # header
def visit_acks(self, node):
# 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
# will be generated differently
if not id.startswith('index-'):
self.body.append(r'\hypertarget{%s}{' % id)
return '}'
return ''
self.body.append(r'\hypertarget{%s}{}' % id)
if not (node.has_key('refuri') or node.has_key('refid')
or node.has_key('refname')):
ctx = ''
for id in node['ids']:
if id not in self.written_ids:
self.written_ids.add(id)
ctx += add_target(id)
self.context.append(ctx)
elif node.has_key('refid') and node['refid'] not in self.written_ids:
self.context.append(add_target(node['refid']))
if node.has_key('refid') and node['refid'] not in self.written_ids:
parindex = node.parent.index(node)
try:
next = node.parent[parindex+1]
if isinstance(next, nodes.section):
self.next_section_target = node['refid']
return
except IndexError:
pass
add_target(node['refid'])
self.written_ids.add(node['refid'])
else:
self.context.append('')
def depart_target(self, node):
self.body.append(self.context.pop())
pass
indextype_map = {
'module': 'refmodindex',

View File

@ -161,6 +161,10 @@ latex_documents = [
# the title page.
#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.
#latex_preamble = ''

View File

@ -50,7 +50,7 @@ bz2: tar-$(FMT)
clean:
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

View File

@ -3,7 +3,7 @@
%
\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}
@ -12,44 +12,34 @@
\ProcessOptions\relax
\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,
% 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.
\setcounter{secnumdepth}{2}
% 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}
% Required package:
%
% This gives us all the Python-specific markup that we really want.
% This should 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}
% This comes after python.sty because it otherwise defines its own
% "seealso" command.
% This comes after python.sty because it otherwise defines its own "seealso"
% command.
%
\RequirePackage{makeidx}
% Support for module synopsis sections:
\newcommand{\py@ModSynopsisFilename}{\jobname.syn}
% Need to do one of these....
\newcommand{\py@doHorizontalRule}{\rule{\textwidth}{1pt}}
% Change the title page to look a bit better, and fit in with the
% fncychap ``Bjarne'' style a bit better.
% Change the title page to look a bit better, and fit in with the fncychap
% ``Bjarne'' style a bit better.
%
\renewcommand{\maketitle}{
\py@doHorizontalRule
@ -90,16 +80,16 @@
\endgroup
\py@doHorizontalRule
\vspace{12pt}
\py@doing@page@targetstrue
}
% Fix the theindex environment to add an entry to the Table of
% Contents; this is much nicer than just having to jump to the end of
% the book and flip around, especially with multiple indexes.
% Fix the theindex environment to add an entry to the Table of Contents; this is
% much nicer than just having to jump to the end of the book and flip around,
% especially with multiple indexes.
%
\let\py@OldTheindex=\theindex
\renewcommand{\theindex}{
\clearpage
\phantomsection
\py@OldTheindex
\addcontentsline{toc}{section}{\indexname}
}
@ -108,6 +98,5 @@
\pagestyle{plain}}{
\pagestyle{normal}} % start this way; change for
\pagenumbering{arabic} % ToC & chapters
\setcounter{secnumdepth}{2}
\thispagestyle{empty}

View File

@ -3,7 +3,7 @@
%
\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}
@ -12,54 +12,38 @@
\ProcessOptions\relax
\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,
% 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.
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{1}
% 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}
% Required packages:
%
% 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!
% The "fncychap" package is used to get the nice chapter headers.
%
\RequirePackage[Bjarne]{fncychap}
% Do horizontal rules it this way to match:
\newcommand{\py@doHorizontalRule}{\mghrulefill{\RW}}
% This gives us all the Sphinx-specific markup that we really want.
% This should come last. Do not change this.
% This gives us all the Sphinx-specific markup that we really want. This should
% come last. Do not change this.
%
\RequirePackage{sphinx}
% This comes after sphinx.sty because it otherwise defines its own
% "seealso" command.
% This comes after sphinx.sty because it otherwise defines its own "seealso"
% command.
%
\RequirePackage{makeidx}
% Support for module synopsis sections:
\newcommand{\py@ModSynopsisFilename}{\jobname\thechapter.syn}
\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.
% Change the title page to look a bit better, and fit in with the fncychap
% ``Bjarne'' style a bit better.
%
\renewcommand{\maketitle}{%
\begin{titlepage}%
@ -99,8 +83,8 @@
}
% Catch the end of the {abstract} environment, but here make sure the
% abstract is followed by a blank page if the 'openright' option is used.
% Catch the end of the {abstract} environment, but here make sure the abstract
% is followed by a blank page if the 'openright' option is used.
%
\let\py@OldEndAbstract=\endabstract
\renewcommand{\endabstract}{
@ -113,10 +97,10 @@
\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'
% option has been used. This eliminates a fair amount of crud in the
% individual document files.
% This wraps the \tableofcontents macro with all the magic to get the spacing
% right and have the right number of pages if the 'openright' option has been
% used. This eliminates a fair amount of crud in the individual document files.
%
\let\py@OldTableofcontents=\tableofcontents
\renewcommand{\tableofcontents}{%
@ -136,23 +120,24 @@
}%
\pagenumbering{arabic}%
\@ifundefined{fancyhf}{}{\pagestyle{normal}}%
\py@doing@page@targetstrue%
}
% 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.
%
\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.6em}}
\renewcommand*\l@subsection{\@dottedtocline{2}{4.1em}{3.5em}}
\setcounter{tocdepth}{1}
% Fix the theindex environment to add an entry to the Table of
% Contents; this is much nicer than just having to jump to the end of
% the book and flip around, especially with multiple indexes.
% Fix the theindex environment to add an entry to the Table of Contents; this is
% much nicer than just having to jump to the end of the book and flip around,
% especially with multiple indexes.
%
\let\py@OldTheindex=\theindex
\renewcommand{\theindex}{
\cleardoublepage
\phantomsection
\py@OldTheindex
\addcontentsline{toc}{chapter}{\indexname}
}

View File

@ -6,20 +6,20 @@
%
\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{longtable}
\RequirePackage{times}
\RequirePackage{fancyvrb}
\RequirePackage{titlesec}
\RequirePackage{tabulary}
\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{InnerLinkColor}{rgb}{0.208,0.374,0.486}
\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.
\definecolor{VerbatimColor}{rgb}{1,1,1}
\definecolor{VerbatimBorderColor}{rgb}{1,1,1}
@ -47,17 +47,7 @@
%\renewcommand{\paperwidth}{8.5in} % typical squarish manual
%\renewcommand{\paperwidth}{7in} % O'Reilly ``Programmming Python''
% If we ever want to indent paragraphs, this needs to be changed.
% 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
% for PDF output, use maximal compression
\newif\ifpdf\pdffalse
\ifx\pdfoutput\undefined\else\ifcase\pdfoutput
\let\py@NormalColor\relax
@ -65,85 +55,9 @@
\else
\pdftrue
\input{pdfcolor}
\let\py@LinkColor=\NavyBlue
\let\py@NormalColor=\Black
\def\py@TitleColor{\color{TitleColor}}
\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
% Increase printable page size (copied from fullpage.sty)
@ -341,36 +255,30 @@
% Add the defining entry for a module
\newcommand{\py@modindex}[2]{%
\renewcommand{\py@thismodule}{#1}
\index{#1@{\py@idxcode{#1}} (#2module)|textbf}%
\index{#1@{\py@idxcode{#1}} (#2module)}%
\ifpy@UseModuleIndex%
\@ifundefined{py@modplat@\py@thismodulekey}{
\write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}}{\thepage}}%
}{\write\modindexfile{\protect\indexentry{#1@{\texttt{#1} %
\emph{(\py@platformof[\py@thismodulekey]{})}}}{\thepage}}%
\write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}|hyperpage}{\thepage}}%
}{\write\modindexfile{\protect\indexentry{#1@{\texttt{#1 }%
\emph{(\platformof{#1})}}|hyperpage}{\thepage}}%
}
\fi%
}
% Module synopsis processing -----------------------------------------------
%
% "Current" keys
\newcommand{\py@thisclass}{}
\newcommand{\py@thismodule}{}
\newcommand{\py@thismodulekey}{}
\newcommand{\py@thismoduletype}{}
% Module index types
\newcommand{\py@standardIndexModule}[1]{\py@modindex{#1}{standard }}
\newcommand{\py@builtinIndexModule}[1]{\py@modindex{#1}{built-in }}
\newcommand{\py@extensionIndexModule}[1]{\py@modindex{#1}{extension }}
\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}
\newcommand{\declaremodule}[3][\py@modulebadkey]{
\py@openModSynopsisFile
\renewcommand{\py@thismoduletype}{#2}
\ifx\py@modulebadkey#1
\renewcommand{\py@thismodulekey}{#3}
@ -383,9 +291,16 @@
}{%
\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
\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{\platform}[1]{
\ifpy@ModPlatformFileIsOpen\else
@ -393,15 +308,12 @@
\openout\py@ModPlatformFile=\py@ModPlatformFilename
\py@ModPlatformFileIsOpentrue
\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}{}{}
\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}
\newcommand{\moduleauthor}[2]{}
@ -409,83 +321,11 @@
% \sectionauthor{name}{email}
\newcommand{\sectionauthor}[2]{}
% Ignore module synopsis.
\newcommand{\modulesynopsis}[1]{}
\newcommand{\py@defsynopsis}{Module has no synopsis.}
\newcommand{\py@modulesynopsis}{\py@defsynopsis}
\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
% Reset "current" objects.
\newcommand{\resetcurrentobjects}{
\renewcommand{\py@thisclass}{}
\renewcommand{\py@thismodule}{}
\renewcommand{\py@thismodulekey}{}
@ -495,7 +335,7 @@
% Augment the sectioning commands used to get our own font family in place,
% and reset some internal data items:
\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}%
{\thesubsection}{0.5em}{}{\py@NormalColor}
\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
\newenvironment{seealso}{
\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'.