++ed by:

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' ] ]);

  +------+-------+
| 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:

## 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.

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>

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