++ed by:
FSEITZ ZMUGHAL

2 PAUSE users
1 non-PAUSE user.

LIMAONE
and 1 contributors

NAME

LaTeX::Table - Perl extension for the automatic generation of LaTeX tables.

VERSION

This document describes LaTeX::Table version 0.1.0

SYNOPSIS

  use LaTeX::Table;
  
  my $header
        = [ [ 'Name', 'Beers:2|c|' ], [ '', 'before 4pm', 'after 4pm' ] ];
  
  my $data = [
        [ 'Lisa',   '0', '0' ],
        [ 'Marge',  '0', '1' ],
        [ 'Homer',  '2', '6' ],
        [],  # horizontal line
        [ 'Wiggum', '0', '5' ],
        [ 'Otto',   '1', '3' ],
        [ 'Barney', '8', '16' ],
  ];
  
  my $table = LaTeX::Table->new(
        {   
        filename    => 'counter.tex',
        caption     => 'Number of beers before and after 4pm.',
        maincaption => 'Beer Counter',
        label       => 'table_beercounter',
        theme       => 'Houston',
        tablepos    => 'htb',
        header      => $header,
        data        => $data,
        }
  );
  
  # write LaTeX code in counter.tex
  $table->generate();
  
  

DESCRIPTION

LaTeX::Table provides functionality for an intuitive and easy generation of LaTeX tables for reports or theses. It ships with some predefined good looking table styles. Supports multipage tables via the xtab package.

INTERFACE

my $table = LaTeX::Table->new($arg_ref)

Constructs a LaTeX::Table object. The parameter is an hash reference with options (see below).

$table->generate()

Generates the LaTeX table code. The generated LaTeX table can be included in a LaTeX document with the \input command:

  % include counter.tex, generated by LaTeX::Table 
  \input{counter}
$table->generate_string()

Same as generate() but does not create a LaTeX file but returns the LaTeX code as string.

  my $latexcode = $table->generate_string();
$table->get_available_themes()

Returns an hash reference to all available (predefined and customs) themes. See "THEMES" for details.

        foreach my $theme ( keys %{ $table->get_available_themes } ) {
                ...
        }

OPTIONS

Options can be defined in the constructor hash reference or with the setter set_<optionname>. Additionally, getters of the form get_<optionname> are created.

BASIC OPTIONS

filename

The name of the LaTeX output file. Default is 'latextable.tex'.

type

Can be either std for the standard LaTeX table or xtab for a xtabular table for multipage tables. The later requires the xtab latex-package (\usepackage{xtab} in your LaTeX document). Default is std.

The header. It is a reference to an array (the rows) of array references (the columns).

  $table->set_header([ [ 'Name', 'Beers' ] ]);

will produce following header:

  +------+-------+
  | Name | Beers |
  +------+-------+

Here an example for a multirow header:

  $table->set_header([ [ 'Name', 'Beers' ], ['', '(roughly)' ] ]);

This code will produce this header:

  +------+-----------+
  | Name |   Beers   |
  |      | (roughly) |
  +------+-----------+
data

The data. Once again an reference to an array (rows) of array references (columns).

  $table->set_data([ [ 'March', '1' ], [ 'Homer', '4' ] ]);

And you will get a table like this:

 +-------+---------+
 | March |       1 |
 | Homer |       4 |
 +-------+---------+

An empty column array will produce a horizontal line:

  $table->set_data([ [ 'March', '1' ], [], [ 'Homer', '4' ] ]);

And you will get a table like this:

 +-------+---------+
 | March |       1 |
 +-------+---------+
 | Homer |       4 |
 +-------+---------+

TABLE ENVIRONMENT

table_environment

If 1, then a table environment will be generated. Default 1. This option only affects tables of type std.

    \begin{table}[htb]
        \center
        \begin{tabular}{|l||r|r|}
        ...
        \end{tabular}
        \caption{Number of beers}
        \label{table_beercounter}
    \end{table} 
caption

The caption of the table. Only generated if get_caption() returns a true value. Default is 0. Requires table_environment.

center

Defines whether the table is centered. Default 1 (centered). Requires table_environment.

label

The label of the table. Only generated if get_label() returns a true value. In Latex you can create a reference to the table with \ref{label}. Default is 0. Requires table_environment.

maincaption

If get_maincaption() returns a true value, then this value will be displayed in the Table Listing (\listoftables) and before the caption. Default 0. Requires table_environment.

size

Font size. Valid values are 'tiny', 'scriptsize', 'footnotesize', 'small', 'normal', 'large', 'Large', 'LARGE', 'huge', 'Huge' and 0. Default is 0 (does not define a font size). Requires table_environment.

tablepos

The position of the table, e.g. htb. Only generated if get_tablepos() returns a true value. Requires table_environment.

TABULAR ENVIRONMENT

tabledef

The table definition, e.g. |l|r|c|r|. If unset, LaTeX::Table tries to guess a good definition. Columns containing only numbers are right-justified, others left-justified. Default unset (guess good definition).

MULTIPAGE TABLES

tabletailmsg

Message at the end of a multipage table. Default is Continued on next page.

tabletail

Custom table tail. Default is multicolumn with the tabletailmsg (see above) right-justified.

xentrystretch

Option for xtab. Play with this option if the number of rows per page is not optimal. Requires a number as parameter. Default is 0 (does not use this option).

    $table->set_xentrystretch(-0.1);

THEMES

theme

The name of the theme. Default is Dresden.

predef_themes

All predefined themes. Getter only.

custom_themes

All custom themes. See "CUSTOM THEMES".

MULTICOLUMNS

Multicolumns can be defined in LaTeX with \multicolumn{#cols}{definition}{text}. Because multicolumns are often needed and this is way too much code to type, a shortcut was implemented. Now, text:#colsdefinition is equivalent to original LaTeX code. For example, Beers:2|c| is equivalent to \multicolumn{2}{|c|}{Beers}. Note that |c| overrides the LINES settings in the theme (See "CUSTOM THEMES").

THEMES

The theme can be selected with $table->set_theme($themename). Currently, following predefined themes are available: Dresden, Miami and Houston. The script generate_examples.pl in the examples directory of this distributions generates some examples for all available themes.

DRESDEN

The default theme. Nice and clean, with a header written in bold text. Header and first column are seperated by a double line.

  +-------++-------+
  | Name  || Beers |
  +-------++-------+
  +-------++-------+
  | March ||     1 |
  | Homer ||     4 |
  +-------++-------+
 

HOUSTON

Very similar to Dresden, but columns are seperated (one inner line).

  +-------++-------+
  | Name  || Beers |
  +-------++-------+
  +-------++-------+
  | March ||     1 |
  +-------++-------+
  | Homer ||     4 |
  +-------++-------+

MIAMI

A very simple theme. Header once again written in bold text.

    Name  | Beers 
  --------+--------
    March |     1 
    Homer |     4 

CUSTOM THEMES

Custom themes can be defined with an array reference containing all options (explained later):

    my $themes = { 
                'Leipzig' => {
                    'HEADER_FONT_STYLE'  => 'sc',
                    'HEADER_CENTERED'     => 1,
                    'CAPTION_FONT_STYLE' => 'sc',
                    'VERTICAL_LINES'      => [ 1, 2, 1 ],
                    'HORIZONTAL_LINES'    => [ 1, 2, 0 ],
                },
            };

    $table->set_custom_themes($themes);
Fonts

HEADER_FONT_STYLE, CAPTION_FONT_STYLE. Valid values are bf (bold), it (italics), sc (caps) and tt (typewriter).

Lines

VERTICAL_LINES, HORIZONTAL_LINES. A reference to an array with three integers, e.g. [ 1, 2, 0 ]. The first integer defines the number of outer lines. The second the number of lines after the header and after the first column. The third is the number of inner lines. For example "DRESDEN" is defined as:

            'Dresden' => {
                ...  
                'VERTICAL_LINES'     => [ 1, 2, 1 ],
                'HORIZONTAL_LINES'   => [ 1, 2, 0 ],
            }

The first integers define one outer line - vertical and horizontal. So a box is drawn around the table. The second integers define two lines between header and table and two vertical lines between first and second column. And finally the third integers define that columns are seperated by a single vertical line whereas rows are not seperated by horizontal lines.

Misc

HEADER_CENTERED. Valid values are 0 (not centered) or 1 (centered).

DIAGNOSTICS

DEPRECATED. Use options header and data instead.

You have called either generate() or generate_string() with header and data as parameters. This is deprecated since LaTeX::Table 0.1.0.

Family not known: ... . Valid families are: ...

You have set a font family to an invalid value.

Size not known: ... . Valid sizes are: ...

You have set a font size to an invalid value.

Unknown theme: ...

You have set the option theme to an invalid value.

xentrystretch not a number

You have set the option xentrystretch to an invalid value. This option requires a number.

CONFIGURATION AND ENVIRONMENT

LaTeX::Table requires no configuration files or environment variables.

DEPENDENCIES

Carp, Fatal, Scalar::Util, English, Regexp::Common, Class::Std

INCOMPATIBILITIES

None reported.

BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests to bug-latex-table@rt.cpan.org, or through the web interface at http://rt.cpan.org.

SPECIAL NOTE FOR FEATURE REQUESTS

There are many limitations. This module does not want to provide thousands of useless options. However, if a particular - good looking - LaTeX table is not possible to generate with LaTeX::Table, it is considered as a bug. Please sent appropriate example LaTeX code to me. If you think your table theme looks better than the default ones, then please let me know your theme settings.

AUTHOR

Markus Riester <mriester@gmx.de>

LICENSE AND COPYRIGHT

Copyright (c) 2006-2007, Markus Riester <mriester@gmx.de>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.