File Coverage

blib/lib/LaTeX/Table.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package LaTeX::Table;
2              
3 14     14   514547 use strict;
  14         36  
  14         514  
4 14     14   75 use warnings;
  14         92  
  14         591  
5              
6 14     14   26786 use Moose;
  0            
  0            
7             use Moose::Util::TypeConstraints;
8             use MooseX::FollowPBP;
9              
10             use version; our $VERSION = qv('1.0.6');
11              
12             use LaTeX::Table::Types::Std;
13             use LaTeX::Table::Types::Xtab;
14             use LaTeX::Table::Types::Ctable;
15             use LaTeX::Table::Types::Longtable;
16              
17             use Carp;
18             use Scalar::Util qw(reftype);
19             use English qw( -no_match_vars );
20              
21             use Module::Pluggable
22             search_path => 'LaTeX::Table::Themes',
23             sub_name => 'themes',
24             except => 'LaTeX::Table::Themes::ThemeI',
25             instantiate => 'new';
26              
27             # Scalar options:
28              
29             # Str
30             for my $attr (
31             qw(label maincaption shortcaption caption caption_top coldef
32             custom_template width maxwidth width_environment
33             custom_tabular_environment position tabletail star)
34             )
35             {
36             has $attr => ( is => 'rw', isa => 'Str', default => 0 );
37             }
38              
39             has 'filename' => ( is => 'rw', isa => 'Str', default => 'latextable.tex' );
40             has 'foottable' => ( is => 'rw', isa => 'Str', default => q{} );
41             has 'eor' => ( is => 'rw', isa => 'Str', default => q{\\\\} );
42             has 'environment' => ( is => 'rw', isa => 'Str', default => 1 );
43             has 'theme' => ( is => 'rw', isa => 'Str', default => 'Meyrin' );
44             has 'continuedmsg' => ( is => 'rw', isa => 'Str', default => '(continued)' );
45             has 'tabletailmsg' =>
46             ( is => 'rw', isa => 'Str', default => 'Continued on next page' );
47             has 'tableheadmsg' =>
48             ( is => 'rw', isa => 'Str', default => 'Continued from previous page' );
49             has 'tablelasttail' => ( is => 'rw', isa => 'Str', default => q{} );
50              
51             # Num
52             has 'xentrystretch' => ( is => 'rw', isa => 'Num', default => 0 );
53              
54             # Bool
55             for my $attr (qw(center left right _default_align continued sideways)) {
56             has $attr => (
57             is => 'rw',
58             isa => 'Bool',
59             predicate => "has_$attr",
60             clearer => "clear_$attr",
61             );
62             }
63              
64             # enum
65             has 'type' => (
66             is => 'rw',
67             isa => enum( [qw( std ctable xtab longtable )] ),
68             default => 'std',
69             );
70             has 'fontfamily' => (
71             is => 'rw',
72             isa => enum( [qw( 0 rm sf tt )] ),
73             default => 0,
74             );
75             has 'fontsize' => (
76             is => 'rw',
77             isa => enum(
78             [ qw(0 tiny scriptsize footnotesize
79             small normal large Large LARGE huge Huge)
80             ]
81             ),
82             default => 0,
83             );
84              
85             # Reference/Object options
86             has 'coldef_strategy' => ( is => 'rw', isa => 'HashRef' );
87             has 'callback' => ( is => 'rw', isa => 'CodeRef' );
88             has 'resizebox' => ( is => 'rw', isa => 'ArrayRef[Str]' );
89             has 'columns_like_header' => ( is => 'rw', isa => 'ArrayRef[Int]' );
90             has 'header' =>
91             ( is => 'rw', isa => 'ArrayRef[ArrayRef[Value]]', default => sub { [] } );
92             has 'data' =>
93             ( is => 'rw', isa => 'ArrayRef[ArrayRef[Value]]', default => sub { [] } );
94             has 'predef_themes' =>
95             ( is => 'rw', isa => 'HashRef[HashRef]', default => sub { {} } );
96             has 'custom_themes' =>
97             ( is => 'rw', isa => 'HashRef[HashRef]', default => sub { {} } );
98              
99             # private
100             has '_data_summary' => ( is => 'rw', isa => 'ArrayRef[Str]' );
101             has '_type_obj' => ( is => 'rw', isa => 'LaTeX::Table::Types::TypeI' );
102             has '_RULE_TOP_ID' => ( is => 'ro', default => 0 );
103             has '_RULE_MID_ID' => ( is => 'ro', default => 1 );
104             has '_RULE_INNER_ID' => ( is => 'ro', default => 2 );
105             has '_RULE_BOTTOM_ID' => ( is => 'ro', default => 3 );
106              
107             __PACKAGE__->meta->make_immutable;
108              
109             sub generate_string {
110             my ( $self, @args ) = @_;
111              
112             # analyze the data
113             $self->_calc_data_summary( $self->get_data );
114              
115             my $type_obj_name
116             = 'LaTeX::Table::Types::'
117             . uc( substr $self->get_type, 0, 1 )
118             . substr $self->get_type, 1;
119             $self->_set_type_obj( $type_obj_name->new( _table_obj => $self ) );
120              
121             return $self->_get_type_obj->generate_latex_code();
122             }
123              
124             sub generate {
125             my ( $self, $header, $data ) = @_;
126             open my $LATEX, '>', $self->get_filename
127             or $self->_ioerror( 'open', $OS_ERROR );
128             print {$LATEX} $self->generate_string( $header, $data )
129             or $self->_ioerror( 'write', $OS_ERROR );
130             close $LATEX
131             or $self->_ioerror( 'close', $OS_ERROR );
132             return 1;
133             }
134              
135             sub get_available_themes {
136             my ($self) = @_;
137             my %defs;
138              
139             for my $theme_obj ( $self->themes ) {
140             %defs = ( %defs, %{ $theme_obj->_definition } );
141             }
142             $self->set_predef_themes( \%defs );
143             return {
144             ( %{ $self->get_predef_themes }, %{ $self->get_custom_themes } ) };
145             }
146              
147             sub _invalid_option_usage {
148             my ( $self, $option, $msg ) = @_;
149             croak "Invalid usage of option $option: $msg.";
150             }
151              
152             sub _ioerror {
153             my ( $self, $function, $error ) = @_;
154             croak "IO error: Can't $function '" . $self->get_filename . "': $error";
155             }
156              
157             sub _default_coldef_strategy {
158             my ($self) = @_;
159             my $STRATEGY = {
160             MISSING_VALUE => qr{\A \s* \z}xms,
161             NUMBER =>
162             qr{\A\s*([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?\s*\z}xms,
163             NUMBER_MUST_MATCH_ALL => 1,
164             LONG => qr{\A \s* (?=\w+\s+\w+).{29,}? \S}xms,
165             LONG_MUST_MATCH_ALL => 0,
166             NUMBER_COL => 'r',
167             NUMBER_COL_X => 'r',
168             LONG_COL => 'p{5cm}',
169             LONG_COL_X => 'X',
170             LONG_COL_Y => 'L',
171             DEFAULT_COL => 'l',
172             DEFAULT_COL_X => 'l',
173             };
174             $self->set_coldef_strategy($STRATEGY);
175             return $STRATEGY;
176             }
177              
178             sub _get_coldef_types {
179             my ($self) = @_;
180              
181             # everything that does not contain an underscore is a coltype
182             my @coltypes = sort grep {m{ \A [^_]+ \z }xms}
183             keys %{ $self->get_coldef_strategy };
184              
185             return @coltypes;
186             }
187              
188             sub _check_coldef_strategy {
189             my ( $self, $strategy ) = @_;
190             my $default = $self->_default_coldef_strategy;
191             for my $key ( keys %{$default} ) {
192             if ( !defined $strategy->{$key} ) {
193             $strategy->{$key} = $default->{$key};
194             }
195             }
196              
197             $self->set_coldef_strategy($strategy);
198              
199             my @coltypes = $self->_get_coldef_types();
200             for my $type (@coltypes) {
201             if ( !defined $strategy->{"${type}_COL"} ) {
202             $self->_invalid_option_usage( 'coldef_strategy',
203             "Missing column attribute ${type}_COL for $type" );
204             }
205             if ( !defined $strategy->{"${type}_MUST_MATCH_ALL"} ) {
206             $strategy->{"${type}_MUST_MATCH_ALL"} = 1;
207             }
208             }
209             return;
210             }
211              
212             sub _extract_number_columns {
213             my ( $self, $col ) = @_;
214             my $def = $self->_get_mc_def($col);
215             return defined $def->{cols} ? $def->{cols} : 1;
216             }
217              
218             sub _row_is_latex_command {
219             my ( $self, $row ) = @_;
220             if ( scalar( @{$row} ) == 1 && $row->[0] =~ m{\A \s* \\ }xms ) {
221             return 1;
222             }
223             return 0;
224             }
225              
226             sub _calc_data_summary {
227             my ( $self, $data ) = @_;
228             my $max_col_number = 0;
229             my $strategy = $self->get_coldef_strategy;
230             if ( !$strategy ) {
231             $strategy = $self->_default_coldef_strategy;
232             }
233             else {
234             $self->_check_coldef_strategy($strategy);
235             }
236             my %matches;
237             my %cells;
238              
239             my @coltypes = $self->_get_coldef_types();
240              
241             ROW:
242             for my $row ( @{$data} ) {
243             if ( scalar @{$row} == 0 || $self->_row_is_latex_command($row) ) {
244             next ROW;
245             }
246             if ( scalar @{$row} > $max_col_number ) {
247             $max_col_number = scalar @{$row};
248             }
249             my $i = 0;
250             COL:
251             for my $col ( @{$row} ) {
252             next COL if $col =~ $strategy->{MISSING_VALUE};
253              
254             for my $coltype (@coltypes) {
255             if ( $col =~ $strategy->{$coltype} ) {
256             $matches{$i}{$coltype}++;
257             }
258             }
259             $cells{$i}++;
260             $i += $self->_extract_number_columns($col);
261             }
262             }
263             my @summary;
264             for my $i ( 0 .. $max_col_number - 1 ) {
265             my $type_of_this_col = 'DEFAULT';
266             for my $coltype (@coltypes) {
267             if (defined $matches{$i}{$coltype}
268             && ( !$strategy->{"${coltype}_MUST_MATCH_ALL"}
269             || $cells{$i} == $matches{$i}{$coltype} )
270             )
271             {
272             $type_of_this_col = $coltype;
273             }
274             }
275             push @summary, $type_of_this_col;
276             }
277             $self->_set_data_summary( \@summary );
278             return;
279             }
280              
281             sub _apply_callback_cell {
282             my ( $self, $i, $j, $value, $is_header ) = @_;
283             my $col_cb = $self->_get_mc_def($value);
284             $col_cb->{value}
285             = &{ $self->get_callback }( $i, $j, $col_cb->{value}, $is_header );
286             return $self->_get_mc_value($col_cb);
287             }
288              
289             # formats the data/header as latex code
290             sub _get_matrix_latex_code {
291             my ( $self, $data_ref, $is_header ) = @_;
292              
293             my $theme = $self->get_theme_settings;
294             my $i = 0;
295             my $row_id = 0;
296              
297             my @code
298             = $is_header
299             ? ( $self->_get_hline_code( $self->_get_RULE_TOP_ID ) )
300             : ();
301             ROW:
302             for my $row ( @{$data_ref} ) {
303             $i++;
304             my @cols = @{$row};
305              
306             # empty rows produce a horizontal line
307             if ( !@cols ) {
308             push @code,
309             $self->_get_hline_code( $self->_get_RULE_INNER_ID, 1 );
310             next ROW;
311             }
312              
313             # single column rows that start with a backslash are just
314             # printed out
315             if ( $self->_row_is_latex_command($row) ) {
316             push @code, $cols[0] . "\n";
317             next ROW;
318             }
319             if ( $self->get_callback ) {
320             my $k = 0;
321             for my $col (@cols) {
322             $col = $self->_apply_callback_cell( $row_id, $k, $col,
323             $is_header );
324             $k += $self->_extract_number_columns($col);
325             }
326             }
327             if ($is_header) {
328             my $j = 0;
329             for my $col (@cols) {
330             $col = $self->_apply_header_formatting( $col,
331             ( !defined $theme->{STUB_ALIGN} || $j > 0 ) );
332             $j += $self->_extract_number_columns($col);
333             }
334             }
335             $row_id++;
336              
337             # now print the row LaTeX code
338             my $bgcolor
339             = $is_header ? $theme->{'HEADER_BG_COLOR'}
340             : ( $row_id % 2 ) ? $theme->{'DATA_BG_COLOR_ODD'}
341             : $theme->{'DATA_BG_COLOR_EVEN'};
342             push @code, $self->_get_row_array( \@cols, $bgcolor, $is_header );
343              
344             next ROW if $is_header;
345              
346             # do we have to draw a horizontal line?
347             if ( $i == scalar @{$data_ref} ) {
348             push @code, $self->_get_hline_code( $self->_get_RULE_BOTTOM_ID );
349             }
350             else {
351             push @code, $self->_get_hline_code( $self->_get_RULE_INNER_ID );
352             }
353             }
354              
355             # without header, just draw the topline, not this midline
356             if ( $is_header && $i ) {
357             push @code, $self->_get_hline_code( $self->_get_RULE_MID_ID );
358             }
359              
360             return $self->_align_code( \@code );
361             }
362              
363             sub _align_code {
364             my ( $self, $code_ref ) = @_;
365             my %max;
366             for my $row ( @{$code_ref} ) {
367             next if ( !defined reftype $row);
368             for my $i ( 0 .. scalar( @{$row} ) - 1 ) {
369             $row->[$i] =~ s{^\s+|\s+$}{}gxms;
370             my $l = length $row->[$i];
371             if ( !defined $max{$i} || $max{$i} < $l ) {
372             $max{$i} = $l;
373             }
374             }
375             }
376              
377             my $code = q{};
378             ROW:
379             for my $row ( @{$code_ref} ) {
380             if ( !defined reftype $row) {
381             $code .= $row;
382             next ROW;
383             }
384             for my $i ( 0 .. scalar( @{$row} ) - 1 ) {
385             $row->[$i] = sprintf '%-*s', $max{$i}, $row->[$i];
386             }
387             $code .= join( ' & ', @{$row} ) . q{ } . $self->get_eor . "\n";
388             }
389             return $code;
390             }
391              
392             sub _get_hline_code {
393             my ( $self, $id, $single ) = @_;
394             my $theme = $self->get_theme_settings;
395             my $hlines = $theme->{'HORIZONTAL_RULES'};
396             my $line = '\hline';
397             if ( defined $theme->{RULES_CMD}
398             && reftype $theme->{RULES_CMD} eq 'ARRAY' )
399             {
400             $line = $theme->{RULES_CMD}->[$id];
401             }
402             if ( $id == $self->_get_RULE_BOTTOM_ID ) {
403             $id = 0;
404             }
405              
406             # just one line?
407             if ( defined $single && $single ) {
408             return "$line\n";
409             }
410             return "$line\n" x $hlines->[$id];
411             }
412              
413             sub _apply_header_formatting {
414             my ( $self, $col, $aligning ) = @_;
415             my $theme = $self->get_theme_settings;
416             if ( $aligning
417             && defined $theme->{'HEADER_CENTERED'}
418             && $theme->{'HEADER_CENTERED'} )
419             {
420             $col = $self->_add_mc_def(
421             { value => $col, align => 'c', cols => '1' } );
422             }
423             if ( length $col ) {
424             if ( defined $theme->{'HEADER_FONT_STYLE'} ) {
425             $col = $self->_add_font_family( $col,
426             $theme->{'HEADER_FONT_STYLE'} );
427             }
428             if ( defined $theme->{'HEADER_FONT_COLOR'} ) {
429             $col = $self->_add_font_color( $col,
430             $theme->{'HEADER_FONT_COLOR'} );
431             }
432             }
433             return $col;
434             }
435              
436             sub _get_cell_bg_color {
437             my ( $self, $row_bg_color, $col_id ) = @_;
438             my $cell_bg_color = $row_bg_color;
439             if ( $self->get_columns_like_header ) {
440             HEADER_COLUMN:
441             for my $i ( @{ $self->get_columns_like_header } ) {
442             if ( $i == $col_id ) {
443             $cell_bg_color
444             = $self->get_theme_settings->{'HEADER_BG_COLOR'};
445             last HEADER_COLUMN;
446             }
447             }
448             }
449             return $cell_bg_color;
450             }
451              
452             sub _get_row_array {
453             my ( $self, $cols_ref, $bgcolor, $is_header ) = @_;
454             my @cols;
455             my @cols_defs = map { $self->_get_mc_def($_) } @{$cols_ref};
456             my $vlines = $self->get_theme_settings->{'VERTICAL_RULES'};
457             my $v0 = q{|} x $vlines->[0];
458             my $v1 = q{|} x $vlines->[1];
459             my $v2 = q{|} x $vlines->[2];
460             my $j = 0;
461             my $col_id = 0;
462             for my $col_def (@cols_defs) {
463              
464             if ( !$is_header && $self->get_columns_like_header ) {
465             HEADER_COLUMN:
466             for my $i ( @{ $self->get_columns_like_header } ) {
467             next HEADER_COLUMN if $i != $col_id;
468             $col_def = $self->_get_mc_def(
469             $self->_apply_header_formatting(
470             $self->_get_mc_value($col_def), 0
471             )
472             );
473             if ( !defined $col_def->{cols} ) {
474             my @summary = @{ $self->_get_data_summary() };
475             $col_def->{cols} = 1;
476             $col_def->{align}
477             = $self->get_coldef_strategy->{ $summary[$col_id]
478             . $self->_get_coldef_type_col_suffix };
479             }
480             }
481             }
482             if ( defined $col_def->{cols} ) {
483             my $vl_pre = $j == 0 ? $v0 : q{};
484             my $vl_post = $j == $#cols_defs ? $v0 : $j == 0
485             && $col_def->{cols} == 1 ? $v1 : $v2;
486              
487             my $color_code = q{};
488              
489             my $cell_bg_color
490             = $self->_get_cell_bg_color( $bgcolor, $col_id );
491             if ( defined $cell_bg_color ) {
492             $color_code = '>{\columncolor{' . $cell_bg_color . '}}';
493             }
494              
495             push @cols,
496             '\\multicolumn{'
497             . $col_def->{cols} . '}{'
498             . $vl_pre
499             . $color_code
500             . $col_def->{align}
501             . $vl_post . '}{'
502             . $col_def->{value} . '}';
503              
504             $col_id += $col_def->{cols};
505             }
506             else {
507             push @cols, $col_def->{value};
508             $col_id++;
509             }
510             $j++;
511             }
512             if ( defined $bgcolor ) {
513              
514             # @cols has always at least one element, otherwise we draw a line
515             $cols[0] = "\\rowcolor{$bgcolor}" . $cols[0];
516             }
517             return \@cols;
518             }
519              
520             sub _add_mc_def {
521             my ( $self, $arg_ref ) = @_;
522             my $def = $self->_get_mc_def( $arg_ref->{value} );
523             return defined $def->{cols}
524             ? $arg_ref->{value}
525             : $self->_get_mc_value($arg_ref);
526             }
527              
528             sub _get_mc_value {
529             my ( $self, $def ) = @_;
530             return
531             defined $def->{cols}
532             ? $def->{value} . q{:} . $def->{cols} . $def->{align}
533             : $def->{value};
534             }
535              
536             sub _get_mc_def {
537             my ( $self, $value ) = @_;
538             return $value =~ m{ \A (.*)\:(\d+)([clr]) \s* \z }xms
539             ? {
540             value => $1,
541             cols => $2,
542             align => $3
543             }
544             : { value => $value };
545             }
546              
547             sub _add_font_family {
548             my ( $self, $col, $family ) = @_;
549             my %know_families = ( tt => 1, bf => 1, it => 1, sc => 1 );
550             if ( !defined $know_families{$family} ) {
551             $self->_invalid_option_usage(
552             'custom_themes',
553             "Family not known: $family. Valid families are: " . join ', ',
554             sort keys %know_families
555             );
556             }
557             my $col_def = $self->_get_mc_def($col);
558             $col_def->{value} = "\\text$family" . '{' . $col_def->{value} . '}';
559             return $self->_get_mc_value($col_def);
560             }
561              
562             sub _add_font_color {
563             my ( $self, $col, $color ) = @_;
564             my $col_def = $self->_get_mc_def($col);
565             $col_def->{value} = "\\color{$color}" . $col_def->{value};
566             return $self->_get_mc_value($col_def);
567             }
568              
569             sub _get_coldef_type_col_suffix {
570             my ($self) = @_;
571             if ( $self->get_width_environment eq 'tabularx' ) {
572             return '_COL_X';
573             }
574             elsif ( $self->get_width_environment eq 'tabulary' ) {
575             return '_COL_Y';
576             }
577             return '_COL';
578             }
579              
580             sub _get_coldef_code {
581             my ( $self, $data ) = @_;
582             my @cols = @{ $self->_get_data_summary() };
583             my $vlines = $self->get_theme_settings->{'VERTICAL_RULES'};
584              
585             my $v0 = q{|} x $vlines->[0];
586             my $v1 = q{|} x $vlines->[1];
587             my $v2 = q{|} x $vlines->[2];
588              
589             my $table_def = q{};
590             my $i = 0;
591             my $strategy = $self->get_coldef_strategy();
592             my $typesuffix = $self->_get_coldef_type_col_suffix();
593              
594             my @attributes = grep {m{ _COL }xms} keys %{$strategy};
595              
596             for my $col (@cols) {
597              
598             # align text right, numbers left, first col always left
599             my $align;
600              
601             for my $attribute ( sort @attributes ) {
602             if ( $attribute =~ m{ \A $col $typesuffix \z }xms ) {
603             $align = $strategy->{$attribute};
604              
605             # for _X and _Y, use default if no special defs are found
606             }
607             elsif ( ( $typesuffix eq '_COL_X' || $typesuffix eq '_COL_Y' )
608             && $attribute =~ m{ \A $col _COL \z }xms )
609             {
610             $align = $strategy->{$attribute};
611             }
612             }
613              
614             if ( $i == 0 ) {
615             if ( defined $self->get_theme_settings->{'STUB_ALIGN'} ) {
616             $align = $self->get_theme_settings->{'STUB_ALIGN'};
617             }
618             $table_def .= $v0 . $align . $v1;
619             }
620             elsif ( $i == ( scalar(@cols) - 1 ) ) {
621             $table_def .= $align . $v0;
622             }
623             else {
624             $table_def .= $align . $v2;
625             }
626             $i++;
627             if ( $i == 1
628             && $self->get_width
629             && !$self->get_width_environment )
630             {
631             $table_def .= '@{\extracolsep{\fill}}';
632             }
633             }
634             return $table_def;
635             }
636              
637             sub get_theme_settings {
638             my ($self) = @_;
639              
640             my $themes = $self->get_available_themes();
641             if ( defined $themes->{ $self->get_theme } ) {
642             return $themes->{ $self->get_theme };
643             }
644             $self->_invalid_option_usage( 'theme', 'Not known: ' . $self->get_theme );
645             return;
646             }
647              
648             no Moose::Util::TypeConstraints;
649             no Moose;
650             1; # Magic true value required at end of module
651             __END__
652              
653             =head1 NAME
654              
655             LaTeX::Table - Perl extension for the automatic generation of LaTeX tables.
656              
657             =head1 VERSION
658              
659             This document describes LaTeX::Table version 1.0.6
660              
661             =head1 SYNOPSIS
662              
663             use LaTeX::Table;
664             use Number::Format qw(:subs); # use mighty CPAN to format values
665              
666             my $header = [
667             [ 'Item:2c', '' ],
668             [ '\cmidrule(r){1-2}' ],
669             [ 'Animal', 'Description', 'Price' ],
670             ];
671            
672             my $data = [
673             [ 'Gnat', 'per gram', '13.65' ],
674             [ '', 'each', '0.0173' ],
675             [ 'Gnu', 'stuffed', '92.59' ],
676             [ 'Emu', 'stuffed', '33.33' ],
677             [ 'Armadillo', 'frozen', '8.99' ],
678             ];
679              
680             my $table = LaTeX::Table->new(
681             {
682             filename => 'prices.tex',
683             maincaption => 'Price List',
684             caption => 'Try our special offer today!',
685             label => 'table:prices',
686             position => 'tbp',
687             header => $header,
688             data => $data,
689             }
690             );
691            
692             # write LaTeX code in prices.tex
693             $table->generate();
694              
695             # callback functions help you to format values easily (as
696             # a great alternative to LaTeX packages like rccol)
697             #
698             # Here, the first colum and the header is printed in upper
699             # case and the third colum is formatted with format_price()
700             $table->set_callback(sub {
701             my ($row, $col, $value, $is_header ) = @_;
702             if ($col == 0 || $is_header) {
703             $value = uc $value;
704             }
705             elsif ($col == 2 && !$is_header) {
706             $value = format_price($value, 2, '');
707             }
708             return $value;
709             });
710            
711             print $table->generate_string();
712              
713             Now in your LaTeX document:
714              
715             \documentclass{article}
716              
717             % for multi-page tables (xtab or longtable)
718             \usepackage{xtab}
719             %\usepackage{longtable}
720              
721             % for publication quality tables (Meyrin theme, the default)
722             \usepackage{booktabs}
723             % for the NYC theme
724             \usepackage{array}
725             \usepackage{colortbl}
726             \usepackage{xcolor}
727            
728             \begin{document}
729             \input{prices}
730             \end{document}
731            
732             =head1 DESCRIPTION
733              
734             LaTeX makes professional typesetting easy. Unfortunately, this is not entirely
735             true for tables and the standard LaTeX table macros have a rather limited
736             functionality. This module supports many CTAN packages and hides the
737             complexity of using them behind an easy and intuitive API.
738              
739             =head1 FEATURES
740              
741             This module supports multi-page tables via the C<xtab> or the C<longtable>
742             package. For publication quality tables, it uses the C<booktabs> package. It
743             also supports the C<tabularx> and C<tabulary> packages for nicer fixed-width
744             tables. Furthermore, it supports the C<colortbl> package for colored tables
745             optimized for presentations. The powerful new C<ctable> package is supported
746             and especially recommended when footnotes are needed. C<LaTeX::Table> ships
747             with some predefined, good looking L<"THEMES">. The program I<ltpretty> makes
748             it possible to use this module from within a text editor.
749              
750             =head1 INTERFACE
751              
752             =over
753              
754             =item C<my $table = LaTeX::Table-E<gt>new($arg_ref)>
755              
756             Constructs a C<LaTeX::Table> object. The parameter is an hash reference with
757             options (see below).
758              
759             =item C<$table-E<gt>generate()>
760              
761             Generates the LaTeX table code. The generated LaTeX table can be included in
762             a LaTeX document with the C<\input> command:
763            
764             % include prices.tex, generated by LaTeX::Table
765             \input{prices}
766              
767             =item C<$table-E<gt>generate_string()>
768              
769             Same as generate() but instead of creating a LaTeX file, this returns the LaTeX code
770             as string.
771              
772             my $latexcode = $table->generate_string();
773              
774             =item C<$table-E<gt>get_available_themes()>
775              
776             Returns an hash reference to all available themes. See L<"THEMES"> for
777             details.
778              
779             for my $theme ( keys %{ $table->get_available_themes } ) {
780             ...
781             }
782              
783             =item C<$table-E<gt>search_path( add =E<gt> "MyThemes" );>
784              
785             C<LaTeX::Table> will search under the C<LaTeX::Table::Themes::> namespace for
786             themes. You can add here an additional search path. Inherited from
787             L<Module::Pluggable>.
788              
789             =back
790              
791             =head1 OPTIONS
792              
793             Options can be defined in the constructor hash reference or with the setter
794             C<set_optionname>. Additionally, getters of the form C<get_optionname> are
795             created.
796              
797             =head2 BASIC OPTIONS
798              
799             =over
800              
801             =item C<filename>
802              
803             The name of the LaTeX output file. Default is 'latextable.tex'.
804              
805             =item C<type>
806              
807             Can be 'std' (default) for standard LaTeX tables, 'ctable' for tables using
808             the C<ctable> package or 'xtab' and 'longtable' for multi-page tables (requires
809             the C<xtab> and C<longtable> LaTeX packages, respectively).
810              
811             =item C<header>
812              
813             The header. It is a reference to an array (the rows) of array references (the
814             columns).
815              
816             $table->set_header([ [ 'Animal', 'Price' ] ]);
817              
818             will produce following header:
819              
820             +--------+-------+
821             | Animal | Price |
822             +--------+-------+
823              
824             Here an example for a multirow header:
825              
826             $table->set_header([ [ 'Animal', 'Price' ], ['', '(roughly)' ] ]);
827              
828             This code will produce this header:
829              
830             +--------+-----------+
831             | Animal | Price |
832             | | (roughly) |
833             +--------+-----------+
834              
835             Single column rows that start with a backslash are treated as LaTeX commands
836             and are not further formatted. So,
837              
838             my $header = [
839             [ 'Item:2c', '' ],
840             ['\cmidrule{1-2}'],
841             [ 'Animal', 'Description', 'Price' ]
842             ];
843              
844             will produce following LaTeX code in the Zurich theme:
845              
846             \multicolumn{2}{c}{\textbf{Item}} & \\
847             \cmidrule{1-2}
848             \textbf{Animal} & \multicolumn{1}{c}{\textbf{Description}} & \multicolumn{1}{c}{\textbf{Price}}\\
849              
850             Note that there is no C<\multicolumn>, C<\textbf> or C<\\> added to the second row.
851              
852             =item C<data>
853              
854             The data. Once again a reference to an array (rows) of array references
855             (columns).
856              
857             $table->set_data([ [ 'Gnu', '92.59' ], [ 'Emu', '33.33' ] ]);
858              
859             And you will get a table like this:
860              
861             +-------+---------+
862             | Gnu | 92.59 |
863             | Emu | 33.33 |
864             +-------+---------+
865              
866             An empty column array will produce a horizontal rule (line):
867              
868             $table->set_data([ [ 'Gnu', '92.59' ], [], [ 'Emu', '33.33' ] ]);
869              
870             Now you will get such a table:
871              
872             +-------+---------+
873             | Gnu | 92.59 |
874             +-------+---------+
875             | Emu | 33.33 |
876             +-------+---------+
877              
878             This works also in C<header>.
879              
880             Single column rows starting with a backslash are again printed without any
881             formatting. So,
882              
883             $table->set_data([ [ 'Gnu', '92.59' ], ['\hline'], [ 'Emu', '33.33' ] ]);
884              
885             is equivalent to the example above (except that there always the correct rule
886             command is used, i.e. C<\midrule> vs. C<\hline>).
887              
888             =item C<custom_template>
889              
890             The table types listed above use the L<Template> toolkit internally. These
891             type templates are very flexible and powerful, but you can also provide a
892             custom template:
893              
894             # Returns the header and data formatted in LaTeX code. Nothing else.
895             $table->set_custom_template('[% HEADER_CODE %][% DATA_CODE %]');
896              
897             See L<LaTeX::Table::Types::TypeI>.
898              
899             =back
900              
901             =head2 FLOATING TABLES
902              
903             =over
904              
905             =item C<environment>
906              
907             If get_environment() returns a true value, then a floating environment will be
908             generated. For I<std> tables, the default environment is 'table'. A true value different
909             from '1' will be used as environment name. Default is 1 (use a 'table'
910             environment).
911              
912             The non-floating I<xtab> and I<longtable> environments are mandatory
913             (get_environment() must return a true value here) and support all options in
914             this section except for C<position>.
915              
916             The I<ctable> type automatically adds an environment when any of the
917             following options are set.
918              
919             =item C<caption>
920              
921             The caption of the table. Only generated if get_caption() returns a true value.
922             Default is 0. Requires C<environment>.
923              
924             =item C<caption_top>
925              
926             If get_caption_top() returns a true value, then the caption is placed above the
927             table. To use the standard caption command (C<\caption> in I<std> and
928             I<longtable>, C<\topcaption> in I<xtab>) , use
929              
930             ...
931             caption_top => 1,
932             ...
933              
934             You can specify an alternative command here:
935              
936             ...
937             caption_top => 'topcaption', # would require the topcapt package
938              
939             Or even multiple commands:
940              
941             caption_top =>
942             '\setlength{\abovecaptionskip}{0pt}\setlength{\belowcaptionskip}{10pt}\caption',
943             ...
944              
945             Default 0 (caption below the table) because the spacing in the standard LaTeX
946             macros is optimized for bottom captions. At least for multi-page tables,
947             however, top captions are highly recommended. You can use the C<caption>
948             LaTeX package to fix the spacing:
949              
950             \usepackage[tableposition=top]{caption}
951              
952             =item C<maincaption>
953              
954             If get_maincaption() returns a true value, then this value will be displayed
955             in the table listing (C<\listoftables>) and before the C<caption>. For example,
956              
957             maincaption => 'Price List',
958             caption => 'Try our special offer today!',
959              
960             will generate
961              
962             \caption[Price List]{Price List. Try our special offer today!}
963              
964             Themes can set the font family of the maincaption.
965              
966             Default 0. Requires C<environment>.
967              
968             =item C<shortcaption>
969              
970             Same as C<maincaption>, but does not appear in the caption, only in the table
971             listing. Default 0. Requires C<environment>.
972              
973             =item C<continued>
974              
975             If true, then the table counter will be decremented by one and the
976             C<continuedmsg> is appended to the caption. Useful for splitting tables. Default 0.
977              
978             $table->set_continued(1);
979              
980             =item C<continuedmsg>
981              
982             If get_continued() returns a true value, then this text is appended to the
983             caption. Default '(continued)'.
984              
985             =item C<center>, C<right>, C<left>
986              
987             Defines how the table is aligned in the available textwidth. Default is centered. Requires
988             C<environment>. Only one of these options may return a true value.
989            
990             # don't generate any aligning code
991             $table->set_center(0);
992             ...
993             # restore default
994             $table->clear_center();
995              
996             =item C<label>
997              
998             The label of the table. Only generated if get_label() returns a true value.
999             Default is 0. Requires C<environment>.
1000              
1001             $table->set_label('tbl:prices');
1002              
1003             =item C<position>
1004              
1005             The position of the environment, e.g. 'tbp'. Only generated if get_position()
1006             returns a true value. Default 0. Requires C<environment> and tables of C<type>
1007             I<std> or I<ctable>.
1008              
1009             =item C<sideways>
1010              
1011             Rotates the environment by 90 degrees. Default 0. For tables of C<type> I<std>
1012             and I<ctable>, this requires the C<rotating> LaTeX package, for I<xtab> or
1013             I<longtable> tables the C<lscape> package.
1014              
1015             $table->set_sideways(1);
1016              
1017             =item C<star>
1018              
1019             Use the starred versions of the environments, which place the float over two
1020             columns when the C<twocolumn> option or the C<\twocolumn> command is active.
1021             Default 0.
1022              
1023             $table->set_star(1);
1024              
1025             =item C<fontfamily>
1026              
1027             Valid values are 'rm' (Roman, serif), 'sf' (Sans-serif), 'tt' (Monospace or
1028             typewriter) and 0. Default is 0 (does not define a font family). Requires
1029             C<environment>.
1030              
1031             =item C<fontsize>
1032              
1033             Valid values are 'tiny', 'scriptsize', 'footnotesize', 'small', 'normal',
1034             'large', 'Large', 'LARGE', 'huge', 'Huge' and 0. Default is 0 (does not define
1035             a font size). Requires C<environment>.
1036              
1037             =back
1038              
1039             =head2 TABULAR ENVIRONMENT
1040              
1041             =over
1042              
1043             =item C<custom_tabular_environment>
1044              
1045             If get_custom_tabular_environment() returns a true value, then this specified
1046             environment is used instead of the standard environments 'tabular' (I<std>)
1047             'longtable' (I<longtable>) or 'xtabular' (I<xtab>). For I<xtab> tables, you
1048             can also use the 'mpxtabular' environment here if you need footnotes. See the
1049             documentation of the C<xtab> package.
1050              
1051             See also the documentation of C<width> below for cases when a width is
1052             specified.
1053              
1054             =item C<coldef>
1055              
1056             The table column definition, e.g. 'lrcr' which would result in:
1057              
1058             \begin{tabular}{lrcr}
1059             ..
1060              
1061             If unset, C<LaTeX::Table> tries to guess a good definition. Columns containing
1062             only numbers are right-justified, others left-justified. Columns with cells
1063             longer than 30 characters are I<p> (paragraph) columns of size '5cm' (I<X>
1064             columns when the C<tabularx>, I<L> when the C<tabulary> package is selected).
1065             These rules can be changed with set_coldef_strategy(). Default is 0 (guess
1066             good definition). The left-hand column, the stub, is normally excluded here
1067             and is always left aligned. See L<LaTeX::Table::Themes::ThemeI>.
1068              
1069             =item C<coldef_strategy>
1070              
1071             Controls the behavior of the C<coldef> calculation when get_coldef()
1072             does not return a true value. It is a reference to a hash that contains
1073             regular expressions that define the I<types> of the columns. For example,
1074             the standard types I<NUMBER> and I<LONG> are defined as:
1075              
1076             {
1077             NUMBER =>
1078             qr{\A\s*([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?\s*\z}xms,
1079             NUMBER_MUST_MATCH_ALL => 1,
1080             NUMBER_COL => 'r',
1081             LONG => qr{\A\s*(?=\w+\s+\w+).{29,}?\S}xms,
1082             LONG_MUST_MATCH_ALL => 0,
1083             LONG_COL => 'p{5cm}',
1084             LONG_COL_X => 'X',
1085             LONG_COL_Y => 'L',
1086             };
1087              
1088             =over
1089              
1090             =item C<TYPE =E<gt> $regex>
1091              
1092             New types are defined with the regular expression C<$regex>. All B<cells> that
1093             match this regular expression have type I<TYPE>. A cell can have multiple
1094             types. The name of a type is not allowed to contain underscores (C<_>).
1095              
1096             =item C<TYPE_MUST_MATCH_ALL>
1097              
1098             This defines if whether a B<column> has type I<TYPE> when all B<cells>
1099             are of type I<TYPE> or at least one. Default is C<1> (C<$regex> must match
1100             all).
1101              
1102             Note that columns can have only one type. Types are applied alphabetically,
1103             so for example a I<LONG> I<NUMBER> column has as final type I<NUMBER>.
1104              
1105             =item C<TYPE_COL>
1106              
1107             The C<coldef> attribute for I<TYPE> columns. Required (no default value).
1108              
1109             =item C<TYPE_COL_X>, C<TYPE_COL_Y>
1110              
1111             Same as C<TYPE_COL> but for C<tabularx> or C<tabulary> tables. If undefined,
1112             the attribute defined in C<TYPE_COL> is used.
1113              
1114             =item C<DEFAULT_COL>, C<DEFAULT_COL_X>, C<DEFAULT_COL_Y>
1115              
1116             The C<coldef> attribute for columns that do not match any specified type.
1117             Default 'l' (left-justified).
1118              
1119             =item C<MISSING_VALUE =E<gt> $regex>
1120              
1121             Column values that match the specified regular expression are omitted in the
1122             C<coldef> calculation. Default is C<qr{\A \s* \z}xms>.
1123              
1124             =back
1125              
1126             Examples:
1127              
1128             # change standard types
1129             $table->set_coldef_strategy({
1130             NUMBER => qr{\A \s* \d+ \s* \z}xms, # integers only
1131             LONG_COL => '>{\raggedright\arraybackslash}p{7cm}', # non-justified
1132             });
1133              
1134             # add new types (here: columns that contain only URLs)
1135             $table->set_coldef_strategy({
1136             URL => qr{\A \s* http }xms,
1137             URL_COL => '>{\ttfamily}l',
1138             });
1139              
1140            
1141              
1142             =item C<width>
1143              
1144             If get_width() returns a true value, then C<LaTeX::Table> will use the starred
1145             version of the environment (e.g. C<tabular*> or C<xtabular*>) and will add the
1146             specified width as second parameter. It will also add
1147             C<@{\extracolsep{\fill}}> to the table column definition:
1148              
1149             # use 75% of textwidth
1150             $table->set_width('0.75\textwidth');
1151              
1152             This will produce following LaTeX code:
1153              
1154             \begin{tabular*}{0.75\textwidth}{l@{\extracolsep{\fill} ... }
1155              
1156             For tables of C<type> I<std>, it is also possible to use the C<tabularx> and
1157             C<tabulary> LaTeX packages (see C<width_environment> below). The tables of
1158             type I<ctable> automatically use the C<tabularx> package. See also
1159             C<width_environment> for how to use this feature with I<longtable>.
1160              
1161             =item C<width_environment>
1162              
1163             If get_width() (see above) returns a true value and table is of C<type> I<std>,
1164             then this option provides the possibility to add a custom tabular environment
1165             that supports a table width:
1166              
1167             \begin{environment}{width}{def}
1168              
1169             To use for example the one provided by the C<tabularx> LaTeX package, write:
1170              
1171             # use the tabularx package (for a std table)
1172             $table->set_width('300pt');
1173             $table->set_width_environment('tabularx');
1174              
1175             Note this will not add C<@{\extracolsep{\fill}}> and that this overwrites
1176             a C<custom_tabular_environment>.
1177              
1178             It is possible to use C<tabularx> together with tables of type I<longtable>.
1179             In this case, you have to generate a I<file> and then load the table with the
1180             C<LTXtable> command (C<ltxtable> package):
1181              
1182             $table = LaTeX::Table->new(
1183             { filename => 'mylongtable.tex'
1184             type => 'longtable',
1185             ...
1186             width_environment => 'tabularx',
1187             }
1188             );
1189            
1190             Then in LaTeX:
1191            
1192             \LTXtable{0.8\textwidth}{mylongtable}
1193            
1194             Note that we have to do the specification of the width in LaTeX.
1195              
1196             Default is 0 (see C<width>).
1197              
1198             =item C<maxwidth>
1199              
1200             Only supported by tables of type I<ctable>.
1201              
1202             =item C<eor>
1203              
1204             String specifying the end of a row. Default is '\\'.
1205            
1206             $table->set_eor("\\\\[1em]");
1207              
1208             Callback functions (see below) can be used to manually set the eor after the last
1209             column. This is useful when some rows require different eor strings.
1210              
1211             =item C<callback>
1212              
1213             If get_callback() returns a true value and the return value is a code reference,
1214             then this callback function will be called for every column in C<header>
1215             and C<data>. The return value of this function is then printed instead of the
1216             column value.
1217              
1218             The passed arguments are C<$row>, C<$col> (both starting with 0), C<$value> and
1219             C<$is_header>.
1220              
1221             use LaTeX::Encode;
1222             use Number::Format qw(:subs);
1223             ...
1224            
1225             # rotate header (not the first column),
1226             # use LaTeX::Encode to encode LaTeX special characters,
1227             # format the third column with Format::Number (only the data)
1228             my $table = LaTeX::Table->new(
1229             { header => $header,
1230             data => $data,
1231             callback => sub {
1232             my ( $row, $col, $value, $is_header ) = @_;
1233             if ( $col != 0 && $is_header ) {
1234             $value = '\begin{sideways}' . $value . '\end{sideways}';
1235             }
1236             elsif ( $col == 2 && !$is_header ) {
1237             $value = format_price($value, 2, '');
1238             }
1239             else {
1240             $value = latex_encode($value);
1241             }
1242             return $value;
1243             },
1244             }
1245             );
1246              
1247             =item C<foottable>
1248              
1249             Only supported by tables of type C<ctable>. The footnote C<\tnote> commands.
1250             See the documentation of the C<ctable> LaTeX package.
1251              
1252             $table->set_foottable('\tnote{footnotes are placed under the table}');
1253              
1254             =item C<resizebox>
1255              
1256             If get_resizebox() returns a true value, then the resizebox command is used to
1257             resize the table. Takes as argument a reference to an array. The first element
1258             is the desired width. If a second element is not given, then the height is set to
1259             a value so that the aspect ratio is still the same. Requires the C<graphicx>
1260             LaTeX package. Default 0.
1261              
1262             $table->set_resizebox([ '0.6\textwidth' ]);
1263              
1264             $table->set_resizebox([ '300pt', '200pt' ]);
1265              
1266              
1267             =back
1268              
1269             =head2 MULTI-PAGE TABLES
1270              
1271             =over
1272              
1273             =item C<tableheadmsg>
1274              
1275             When get_caption_top() and get_tableheadmsg() both return true values, then
1276             additional captions are printed on the continued pages. Default caption text
1277             is 'Continued from previous page'.
1278              
1279             =item C<tabletailmsg>
1280              
1281             Message at the end of a multi-page table. Default is 'Continued on next page'.
1282             When using C<caption_top>, this is in most cases unnecessary and it is
1283             recommended to omit the tabletail (see below).
1284              
1285             =item C<tabletail>
1286              
1287             Custom table tail. Default is multicolumn with the tabletailmsg (see above)
1288             right-justified.
1289            
1290             # don't add any tabletail code:
1291             $table->set_tabletail(q{});
1292              
1293             =item C<tablelasttail>
1294              
1295             Same as C<tabletail>, but defines only the bottom of the last page ('lastfoot'
1296             in the C<longtable> package). Default C<''>.
1297              
1298             =item C<xentrystretch>
1299              
1300             Option for xtab. Play with this option if the number of rows per page is not
1301             optimal. Requires a number as parameter. Default is 0 (does not use this option).
1302              
1303             $table->set_xentrystretch(-0.1);
1304              
1305             =back
1306              
1307             =head2 THEMES
1308              
1309             =over
1310              
1311             =item C<theme>
1312              
1313             The name of the theme. Default is I<Meyrin> (requires C<booktabs> LaTeX
1314             package).
1315              
1316             See L<LaTeX::Table::Themes::ThemeI> how to define custom themes.
1317              
1318             The themes are defined in L<LaTeX::Table::Themes::Beamer>,
1319             L<LaTeX::Table::Themes::Booktabs>, L<LaTeX::Table::Themes::Classic>,
1320             L<LaTeX::Table::Themes::Modern>.
1321              
1322             $table->set_theme('Zurich');
1323              
1324             =item C<predef_themes>
1325              
1326             All predefined themes. Getter only.
1327              
1328             =item C<custom_themes>
1329              
1330             All custom themes. See L<LaTeX::Table::Themes::ThemeI>.
1331              
1332             =item C<columns_like_header>
1333              
1334             Takes as argument a reference to an array with column ids (again, starting
1335             with 0). These columns are formatted like header columns.
1336              
1337             # a "transposed" table ...
1338             my $table = LaTeX::Table->new(
1339             { data => $data,
1340             columns_like_header => [ 0 ], }
1341             );
1342              
1343             =back
1344              
1345             =head1 MULTICOLUMNS
1346              
1347             Multicolumns are defined in LaTeX with
1348             C<\multicolumn{$cols}{$alignment}{$text}>. This module supports a simple
1349             shortcut of the format C<$text:$cols$alignment>. For example, C<Item:2c> is
1350             equivalent to C<\multicolumn{2}{c}{Item}>. Note that vertical rules (C<|>) are
1351             automatically added here according the rules settings in the theme. See
1352             L<LaTeX::Table::Themes::ThemeI>. C<LaTeX::Table> also uses this shortcut to
1353             determine the column ids. So in this example,
1354              
1355             my $data = [ [' \multicolumn{2}{c}{A}', 'B' ], [ 'C:2c', 'D' ] ];
1356              
1357             'B' would have an column id of 1 and 'D' 2 ('A' and 'C' both 0). This is important
1358             for callback functions and for the coldef calculation.
1359             See L<"TABULAR ENVIRONMENT">.
1360              
1361             =head1 EXAMPLES
1362              
1363             See I<examples/examples.pdf> in this distribution for a short tutorial that
1364             covers the main features of this module. See also the example application
1365             I<csv2pdf> for an example of the common task of converting a CSV (or Excel)
1366             file to LaTeX or even PDF.
1367              
1368             =head1 DIAGNOSTICS
1369              
1370             If you get a LaTeX error message, please check whether you have included all
1371             required packages. The packages we use are C<array>, C<booktabs>, C<colortbl>,
1372             C<ctable>, C<graphicx>, C<longtable>, C<lscape>, C<rotating>, C<tabularx>,
1373             C<tabulary>, C<xcolor> and C<xtab>.
1374              
1375             C<LaTeX::Table> may throw one of these errors:
1376              
1377             =over
1378              
1379             =item C<IO error: Can't ...>
1380              
1381             In method generate(), it was not possible to write the LaTeX code to
1382             C<filename>.
1383              
1384             =item C<Invalid usage of option ...>
1385              
1386             In method generate() or generate_string(). See the examples in this document
1387             and in I<examples/examples.pdf> for the correct usage of this option.
1388              
1389             =item C<Attribute (option) ... >
1390              
1391             In method new() or set_option(). You passed a wrong type to the option. See
1392             this document or I<examples/examples.pdf> for the correct usage of this option.
1393              
1394             =back
1395              
1396             =head1 CONFIGURATION AND ENVIRONMENT
1397              
1398             C<LaTeX::Table> requires no configuration files or environment variables.
1399              
1400             =head1 DEPENDENCIES
1401              
1402             L<Carp>, L<Module::Pluggable>, L<Moose>, L<English>, L<Scalar::Util>,
1403             L<Template>
1404              
1405             =head1 BUGS AND LIMITATIONS
1406              
1407             The C<width> option causes problems with themes using the C<colortbl> package.
1408             You may have to specify here the overhang arguments of the C<\columcolor>
1409             commands manually. Patches are of course welcome.
1410              
1411             Problems with the C<width> option are also known for tables of type
1412             I<longtable>. You should use the C<tabularx> package as described in the
1413             C<width_environment> documentation.
1414              
1415             Please report any bugs or feature requests to
1416             C<bug-latex-table@rt.cpan.org>, or through the web interface at
1417             L<http://rt.cpan.org>.
1418              
1419             =head1 SEE ALSO
1420              
1421             L<Data::Table>, L<LaTeX::Encode>
1422              
1423             =head1 CREDITS
1424              
1425             =over
1426              
1427             =item ANDREWF, ANSGAR and REHSACK for some great patches and suggestions.
1428              
1429             =item David Carlisle for the C<colortbl>, C<longtable>, C<ltxtable>,
1430             C<tabularx> and C<tabulary> LaTeX packages.
1431              
1432             =item Wybo Dekker for the C<ctable> LaTeX package.
1433              
1434             =item Simon Fear for the C<booktabs> LaTeX package. The L<"SYNOPSIS"> table is
1435             the example in his documentation.
1436              
1437             =item Lapo Filippo Mori for the excellent tutorial I<Tables in LaTeX2e:
1438             Packages and Methods>.
1439              
1440             =item Peter Wilson for the C<xtab> LaTeX package.
1441              
1442             =back
1443              
1444             =head1 LICENSE AND COPYRIGHT
1445              
1446             Copyright (c) 2006-2010 C<< <limaone@cpan.org> >>
1447              
1448             This module is free software; you can redistribute it and/or
1449             modify it under the same terms as Perl itself. See L<perlartistic>.
1450              
1451             =head1 DISCLAIMER OF WARRANTY
1452              
1453             BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
1454             FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
1455             OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
1456             PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
1457             EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1458             WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
1459             ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
1460             YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
1461             NECESSARY SERVICING, REPAIR, OR CORRECTION.
1462              
1463             IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
1464             WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
1465             REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE
1466             LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
1467             OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
1468             THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
1469             RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
1470             FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
1471             SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
1472             SUCH DAMAGES.
1473              
1474             =cut
1475              
1476             # vim: ft=perl sw=4 ts=4 expandtab