There are three general-purpose table environments defined which should be used whenever possible. These environments are defined to provide tables of specific widths and some convenience for formatting. These environments are not meant to be general replacements for the standard LATEX table environments, but can be used for an advantage when the documents are processed using the tools for Python documentation processing. In particular, the generated HTML looks good! There is also an advantage for the eventual conversion of the documentation to XML (see section 8, ``Future Directions'').
Each environment is named \tablecols, where cols
is the number of columns in the table specified in lower-case
Roman numerals. Within each of these environments, an additional
macro, \linecols, is defined, where cols
matches the cols value of the corresponding table
environment. These are supported for cols values of
ii
, iii
, and iv
. These environments are all
built on top of the \tabular environment. Variants based on
the \longtable environment are also provided.
Note that all tables in the standard Python documentation use vertical lines between columns, and this must be specified in the markup for each table. A general border around the outside of the table is not used, but would be the responsibility of the processor; the document markup should not include an exterior border.
The \longtable-based variants of the table environments are formatted with extra space before and after, so should only be used on tables which are long enough that splitting over multiple pages is reasonable; tables with fewer than twenty rows should never by marked using the long flavors of the table environments. The header row is repeated across the top of each part of the table.
\col1font{column1}
. To avoid treating the first
column specially, col1font may be "textrm". The
column headings are taken from the values heading1 and
heading2.
An additional table-like environment is \synopsistable. The table generated by this environment contains two columns, and each row is defined by an alternate definition of \modulesynopsis. This environment is not normally used by authors, but is created by the \localmoduletable macro.
Here is a small example of a table given in the documentation for the warnings module; markup inside the table cells is minimal so the markup for the table itself is readily discernable. Here is the markup for the table:
\begin{tableii}{l|l}{exception}{Class}{Description} \lineii{Warning} {This is the base class of all warning category classes. It is a subclass of \exception{Exception}.} \lineii{UserWarning} {The default category for \function{warn()}.} \lineii{DeprecationWarning} {Base category for warnings about deprecated features.} \lineii{SyntaxWarning} {Base category for warnings about dubious syntactic features.} \lineii{RuntimeWarning} {Base category for warnings about dubious runtime features.} \lineii{FutureWarning} {Base category for warnings about constructs that will change semantically in the future.} \end{tableii}
Here is the resulting table:
Class | Description |
---|---|
Warning | This is the base class of all warning category classes. It is a subclass of Exception. |
UserWarning | The default category for warn(). |
DeprecationWarning | Base category for warnings about deprecated features. |
SyntaxWarning | Base category for warnings about dubious syntactic features. |
RuntimeWarning | Base category for warnings about dubious runtime features. |
Note that the class names are implicitly marked using the
\exception macro, since that is given as the col1font
value for the \tableii environment. To create a table using
different markup for the first column, use textrm
for the
col1font value and mark each entry individually.
To add a horizontal line between vertical sections of a table, use the standard \hline macro between the rows which should be separated:
\begin{tableii}{l|l}{constant}{Language}{Audience} \lineii{APL}{Masochists.} \lineii{BASIC}{First-time programmers on PC hardware.} \lineii{C}{\UNIX{} \&\ Linux kernel developers.} \hline \lineii{Python}{Everyone!} \end{tableii}
Note that not all presentation formats are capable of displaying a horizontal rule in this position. This is how the table looks in the format you're reading now:
Language | Audience |
---|---|
APL | Masochists. |
C | Unix & Linux kernel developers. |
JavaScript | Web developers. |
Python | Everyone! |
See About this document... for information on suggesting changes.