.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "LaTeX::Table 3pm" .TH LaTeX::Table 3pm "2015-06-05" "perl v5.20.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" LaTeX::Table \- Perl extension for the automatic generation of LaTeX tables. .SH "VERSION" .IX Header "VERSION" This document describes LaTeX::Table version 1.0.6 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use LaTeX::Table; \& use Number::Format qw(:subs); # use mighty CPAN to format values \& \& my $header = [ \& [ \*(AqItem:2c\*(Aq, \*(Aq\*(Aq ], \& [ \*(Aq\ecmidrule(r){1\-2}\*(Aq ], \& [ \*(AqAnimal\*(Aq, \*(AqDescription\*(Aq, \*(AqPrice\*(Aq ], \& ]; \& \& my $data = [ \& [ \*(AqGnat\*(Aq, \*(Aqper gram\*(Aq, \*(Aq13.65\*(Aq ], \& [ \*(Aq\*(Aq, \*(Aqeach\*(Aq, \*(Aq0.0173\*(Aq ], \& [ \*(AqGnu\*(Aq, \*(Aqstuffed\*(Aq, \*(Aq92.59\*(Aq ], \& [ \*(AqEmu\*(Aq, \*(Aqstuffed\*(Aq, \*(Aq33.33\*(Aq ], \& [ \*(AqArmadillo\*(Aq, \*(Aqfrozen\*(Aq, \*(Aq8.99\*(Aq ], \& ]; \& \& my $table = LaTeX::Table\->new( \& { \& filename => \*(Aqprices.tex\*(Aq, \& maincaption => \*(AqPrice List\*(Aq, \& caption => \*(AqTry our special offer today!\*(Aq, \& label => \*(Aqtable:prices\*(Aq, \& position => \*(Aqtbp\*(Aq, \& header => $header, \& data => $data, \& } \& ); \& \& # write LaTeX code in prices.tex \& $table\->generate(); \& \& # callback functions help you to format values easily (as \& # a great alternative to LaTeX packages like rccol) \& # \& # Here, the first colum and the header is printed in upper \& # case and the third colum is formatted with format_price() \& $table\->set_callback(sub { \& my ($row, $col, $value, $is_header ) = @_; \& if ($col == 0 || $is_header) { \& $value = uc $value; \& } \& elsif ($col == 2 && !$is_header) { \& $value = format_price($value, 2, \*(Aq\*(Aq); \& } \& return $value; \& }); \& \& print $table\->generate_string(); .Ve .PP Now in your LaTeX document: .PP .Vb 1 \& \edocumentclass{article} \& \& % for multi\-page tables (xtab or longtable) \& \eusepackage{xtab} \& %\eusepackage{longtable} \& \& % for publication quality tables (Meyrin theme, the default) \& \eusepackage{booktabs} \& % for the NYC theme \& \eusepackage{array} \& \eusepackage{colortbl} \& \eusepackage{xcolor} \& \& \ebegin{document} \& \einput{prices} \& \eend{document} .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" LaTeX makes professional typesetting easy. Unfortunately, this is not entirely true for tables and the standard LaTeX table macros have a rather limited functionality. This module supports many \s-1CTAN\s0 packages and hides the complexity of using them behind an easy and intuitive \s-1API.\s0 .SH "FEATURES" .IX Header "FEATURES" This module supports multi-page tables via the \f(CW\*(C`xtab\*(C'\fR or the \f(CW\*(C`longtable\*(C'\fR package. For publication quality tables, it uses the \f(CW\*(C`booktabs\*(C'\fR package. It also supports the \f(CW\*(C`tabularx\*(C'\fR and \f(CW\*(C`tabulary\*(C'\fR packages for nicer fixed-width tables. Furthermore, it supports the \f(CW\*(C`colortbl\*(C'\fR package for colored tables optimized for presentations. The powerful new \f(CW\*(C`ctable\*(C'\fR package is supported and especially recommended when footnotes are needed. \f(CW\*(C`LaTeX::Table\*(C'\fR ships with some predefined, good looking \*(L"\s-1THEMES\*(R"\s0. The program \fIltpretty\fR makes it possible to use this module from within a text editor. .SH "INTERFACE" .IX Header "INTERFACE" .ie n .IP """my $table = LaTeX::Table\->new($arg_ref)""" 4 .el .IP "\f(CWmy $table = LaTeX::Table\->new($arg_ref)\fR" 4 .IX Item "my $table = LaTeX::Table->new($arg_ref)" Constructs a \f(CW\*(C`LaTeX::Table\*(C'\fR object. The parameter is an hash reference with options (see below). .ie n .IP """$table\->generate()""" 4 .el .IP "\f(CW$table\->generate()\fR" 4 .IX Item "$table->generate()" Generates the LaTeX table code. The generated LaTeX table can be included in a LaTeX document with the \f(CW\*(C`\einput\*(C'\fR command: .Sp .Vb 2 \& % include prices.tex, generated by LaTeX::Table \& \einput{prices} .Ve .ie n .IP """$table\->generate_string()""" 4 .el .IP "\f(CW$table\->generate_string()\fR" 4 .IX Item "$table->generate_string()" Same as \fIgenerate()\fR but instead of creating a LaTeX file, this returns the LaTeX code as string. .Sp .Vb 1 \& my $latexcode = $table\->generate_string(); .Ve .ie n .IP """$table\->get_available_themes()""" 4 .el .IP "\f(CW$table\->get_available_themes()\fR" 4 .IX Item "$table->get_available_themes()" Returns an hash reference to all available themes. See \*(L"\s-1THEMES\*(R"\s0 for details. .Sp .Vb 3 \& for my $theme ( keys %{ $table\->get_available_themes } ) { \& ... \& } .Ve .ie n .IP """$table\->search_path( add => ""MyThemes"" );""" 4 .el .IP "\f(CW$table\->search_path( add => ``MyThemes'' );\fR" 4 .IX Item "$table->search_path( add => ""MyThemes"" );" \&\f(CW\*(C`LaTeX::Table\*(C'\fR will search under the \f(CW\*(C`LaTeX::Table::Themes::\*(C'\fR namespace for themes. You can add here an additional search path. Inherited from Module::Pluggable. .SH "OPTIONS" .IX Header "OPTIONS" Options can be defined in the constructor hash reference or with the setter \&\f(CW\*(C`set_optionname\*(C'\fR. Additionally, getters of the form \f(CW\*(C`get_optionname\*(C'\fR are created. .SS "\s-1BASIC OPTIONS\s0" .IX Subsection "BASIC OPTIONS" .ie n .IP """filename""" 4 .el .IP "\f(CWfilename\fR" 4 .IX Item "filename" The name of the LaTeX output file. Default is 'latextable.tex'. .ie n .IP """type""" 4 .el .IP "\f(CWtype\fR" 4 .IX Item "type" Can be 'std' (default) for standard LaTeX tables, 'ctable' for tables using the \f(CW\*(C`ctable\*(C'\fR package or 'xtab' and 'longtable' for multi-page tables (requires the \f(CW\*(C`xtab\*(C'\fR and \f(CW\*(C`longtable\*(C'\fR LaTeX packages, respectively). .ie n .IP """header""" 4 .el .IP "\f(CWheader\fR" 4 .IX Item "header" The header. It is a reference to an array (the rows) of array references (the columns). .Sp .Vb 1 \& $table\->set_header([ [ \*(AqAnimal\*(Aq, \*(AqPrice\*(Aq ] ]); .Ve .Sp will produce following header: .Sp .Vb 3 \& +\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-+ \& | Animal | Price | \& +\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-+ .Ve .Sp Here an example for a multirow header: .Sp .Vb 1 \& $table\->set_header([ [ \*(AqAnimal\*(Aq, \*(AqPrice\*(Aq ], [\*(Aq\*(Aq, \*(Aq(roughly)\*(Aq ] ]); .Ve .Sp This code will produce this header: .Sp .Vb 4 \& +\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+ \& | Animal | Price | \& | | (roughly) | \& +\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+ .Ve .Sp Single column rows that start with a backslash are treated as LaTeX commands and are not further formatted. So, .Sp .Vb 5 \& my $header = [ \& [ \*(AqItem:2c\*(Aq, \*(Aq\*(Aq ], \& [\*(Aq\ecmidrule{1\-2}\*(Aq], \& [ \*(AqAnimal\*(Aq, \*(AqDescription\*(Aq, \*(AqPrice\*(Aq ] \& ]; .Ve .Sp will produce following LaTeX code in the Zurich theme: .Sp .Vb 3 \& \emulticolumn{2}{c}{\etextbf{Item}} & \e\e \& \ecmidrule{1\-2} \& \etextbf{Animal} & \emulticolumn{1}{c}{\etextbf{Description}} & \emulticolumn{1}{c}{\etextbf{Price}}\e\e .Ve .Sp Note that there is no \f(CW\*(C`\emulticolumn\*(C'\fR, \f(CW\*(C`\etextbf\*(C'\fR or \f(CW\*(C`\e\e\*(C'\fR added to the second row. .ie n .IP """data""" 4 .el .IP "\f(CWdata\fR" 4 .IX Item "data" The data. Once again a reference to an array (rows) of array references (columns). .Sp .Vb 1 \& $table\->set_data([ [ \*(AqGnu\*(Aq, \*(Aq92.59\*(Aq ], [ \*(AqEmu\*(Aq, \*(Aq33.33\*(Aq ] ]); .Ve .Sp And you will get a table like this: .Sp .Vb 4 \& +\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+ \& | Gnu | 92.59 | \& | Emu | 33.33 | \& +\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+ .Ve .Sp An empty column array will produce a horizontal rule (line): .Sp .Vb 1 \& $table\->set_data([ [ \*(AqGnu\*(Aq, \*(Aq92.59\*(Aq ], [], [ \*(AqEmu\*(Aq, \*(Aq33.33\*(Aq ] ]); .Ve .Sp Now you will get such a table: .Sp .Vb 5 \& +\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+ \& | Gnu | 92.59 | \& +\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+ \& | Emu | 33.33 | \& +\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+ .Ve .Sp This works also in \f(CW\*(C`header\*(C'\fR. .Sp Single column rows starting with a backslash are again printed without any formatting. So, .Sp .Vb 1 \& $table\->set_data([ [ \*(AqGnu\*(Aq, \*(Aq92.59\*(Aq ], [\*(Aq\ehline\*(Aq], [ \*(AqEmu\*(Aq, \*(Aq33.33\*(Aq ] ]); .Ve .Sp is equivalent to the example above (except that there always the correct rule command is used, i.e. \f(CW\*(C`\emidrule\*(C'\fR vs. \f(CW\*(C`\ehline\*(C'\fR). .ie n .IP """custom_template""" 4 .el .IP "\f(CWcustom_template\fR" 4 .IX Item "custom_template" The table types listed above use the Template toolkit internally. These type templates are very flexible and powerful, but you can also provide a custom template: .Sp .Vb 2 \& # Returns the header and data formatted in LaTeX code. Nothing else. \& $table\->set_custom_template(\*(Aq[% HEADER_CODE %][% DATA_CODE %]\*(Aq); .Ve .Sp See LaTeX::Table::Types::TypeI. .SS "\s-1FLOATING TABLES\s0" .IX Subsection "FLOATING TABLES" .ie n .IP """environment""" 4 .el .IP "\f(CWenvironment\fR" 4 .IX Item "environment" If \fIget_environment()\fR returns a true value, then a floating environment will be generated. For \fIstd\fR tables, the default environment is 'table'. A true value different from '1' will be used as environment name. Default is 1 (use a 'table' environment). .Sp The non-floating \fIxtab\fR and \fIlongtable\fR environments are mandatory (\fIget_environment()\fR must return a true value here) and support all options in this section except for \f(CW\*(C`position\*(C'\fR. .Sp The \fIctable\fR type automatically adds an environment when any of the following options are set. .ie n .IP """caption""" 4 .el .IP "\f(CWcaption\fR" 4 .IX Item "caption" The caption of the table. Only generated if \fIget_caption()\fR returns a true value. Default is 0. Requires \f(CW\*(C`environment\*(C'\fR. .ie n .IP """caption_top""" 4 .el .IP "\f(CWcaption_top\fR" 4 .IX Item "caption_top" If \fIget_caption_top()\fR returns a true value, then the caption is placed above the table. To use the standard caption command (\f(CW\*(C`\ecaption\*(C'\fR in \fIstd\fR and \&\fIlongtable\fR, \f(CW\*(C`\etopcaption\*(C'\fR in \fIxtab\fR) , use .Sp .Vb 3 \& ... \& caption_top => 1, \& ... .Ve .Sp You can specify an alternative command here: .Sp .Vb 2 \& ... \& caption_top => \*(Aqtopcaption\*(Aq, # would require the topcapt package .Ve .Sp Or even multiple commands: .Sp .Vb 3 \& caption_top => \& \*(Aq\esetlength{\eabovecaptionskip}{0pt}\esetlength{\ebelowcaptionskip}{10pt}\ecaption\*(Aq, \& ... .Ve .Sp Default 0 (caption below the table) because the spacing in the standard LaTeX macros is optimized for bottom captions. At least for multi-page tables, however, top captions are highly recommended. You can use the \f(CW\*(C`caption\*(C'\fR LaTeX package to fix the spacing: .Sp .Vb 1 \& \eusepackage[tableposition=top]{caption} .Ve .ie n .IP """maincaption""" 4 .el .IP "\f(CWmaincaption\fR" 4 .IX Item "maincaption" If \fIget_maincaption()\fR returns a true value, then this value will be displayed in the table listing (\f(CW\*(C`\elistoftables\*(C'\fR) and before the \f(CW\*(C`caption\*(C'\fR. For example, .Sp .Vb 2 \& maincaption => \*(AqPrice List\*(Aq, \& caption => \*(AqTry our special offer today!\*(Aq, .Ve .Sp will generate .Sp .Vb 1 \& \ecaption[Price List]{Price List. Try our special offer today!} .Ve .Sp Themes can set the font family of the maincaption. .Sp Default 0. Requires \f(CW\*(C`environment\*(C'\fR. .ie n .IP """shortcaption""" 4 .el .IP "\f(CWshortcaption\fR" 4 .IX Item "shortcaption" Same as \f(CW\*(C`maincaption\*(C'\fR, but does not appear in the caption, only in the table listing. Default 0. Requires \f(CW\*(C`environment\*(C'\fR. .ie n .IP """continued""" 4 .el .IP "\f(CWcontinued\fR" 4 .IX Item "continued" If true, then the table counter will be decremented by one and the \&\f(CW\*(C`continuedmsg\*(C'\fR is appended to the caption. Useful for splitting tables. Default 0. .Sp .Vb 1 \& $table\->set_continued(1); .Ve .ie n .IP """continuedmsg""" 4 .el .IP "\f(CWcontinuedmsg\fR" 4 .IX Item "continuedmsg" If \fIget_continued()\fR returns a true value, then this text is appended to the caption. Default '(continued)'. .ie n .IP """center"", ""right"", ""left""" 4 .el .IP "\f(CWcenter\fR, \f(CWright\fR, \f(CWleft\fR" 4 .IX Item "center, right, left" Defines how the table is aligned in the available textwidth. Default is centered. Requires \&\f(CW\*(C`environment\*(C'\fR. Only one of these options may return a true value. .Sp .Vb 5 \& # don\*(Aqt generate any aligning code \& $table\->set_center(0); \& ... \& # restore default \& $table\->clear_center(); .Ve .ie n .IP """label""" 4 .el .IP "\f(CWlabel\fR" 4 .IX Item "label" The label of the table. Only generated if \fIget_label()\fR returns a true value. Default is 0. Requires \f(CW\*(C`environment\*(C'\fR. .Sp .Vb 1 \& $table\->set_label(\*(Aqtbl:prices\*(Aq); .Ve .ie n .IP """position""" 4 .el .IP "\f(CWposition\fR" 4 .IX Item "position" The position of the environment, e.g. 'tbp'. Only generated if \fIget_position()\fR returns a true value. Default 0. Requires \f(CW\*(C`environment\*(C'\fR and tables of \f(CW\*(C`type\*(C'\fR \&\fIstd\fR or \fIctable\fR. .ie n .IP """sideways""" 4 .el .IP "\f(CWsideways\fR" 4 .IX Item "sideways" Rotates the environment by 90 degrees. Default 0. For tables of \f(CW\*(C`type\*(C'\fR \fIstd\fR and \fIctable\fR, this requires the \f(CW\*(C`rotating\*(C'\fR LaTeX package, for \fIxtab\fR or \&\fIlongtable\fR tables the \f(CW\*(C`lscape\*(C'\fR package. .Sp .Vb 1 \& $table\->set_sideways(1); .Ve .ie n .IP """star""" 4 .el .IP "\f(CWstar\fR" 4 .IX Item "star" Use the starred versions of the environments, which place the float over two columns when the \f(CW\*(C`twocolumn\*(C'\fR option or the \f(CW\*(C`\etwocolumn\*(C'\fR command is active. Default 0. .Sp .Vb 1 \& $table\->set_star(1); .Ve .ie n .IP """fontfamily""" 4 .el .IP "\f(CWfontfamily\fR" 4 .IX Item "fontfamily" Valid values are 'rm' (Roman, serif), 'sf' (Sans-serif), 'tt' (Monospace or typewriter) and 0. Default is 0 (does not define a font family). Requires \&\f(CW\*(C`environment\*(C'\fR. .ie n .IP """fontsize""" 4 .el .IP "\f(CWfontsize\fR" 4 .IX Item "fontsize" Valid values are 'tiny', 'scriptsize', 'footnotesize', 'small', 'normal', \&'large', 'Large', '\s-1LARGE\s0', 'huge', 'Huge' and 0. Default is 0 (does not define a font size). Requires \f(CW\*(C`environment\*(C'\fR. .SS "\s-1TABULAR ENVIRONMENT\s0" .IX Subsection "TABULAR ENVIRONMENT" .ie n .IP """custom_tabular_environment""" 4 .el .IP "\f(CWcustom_tabular_environment\fR" 4 .IX Item "custom_tabular_environment" If \fIget_custom_tabular_environment()\fR returns a true value, then this specified environment is used instead of the standard environments 'tabular' (\fIstd\fR) \&'longtable' (\fIlongtable\fR) or 'xtabular' (\fIxtab\fR). For \fIxtab\fR tables, you can also use the 'mpxtabular' environment here if you need footnotes. See the documentation of the \f(CW\*(C`xtab\*(C'\fR package. .Sp See also the documentation of \f(CW\*(C`width\*(C'\fR below for cases when a width is specified. .ie n .IP """coldef""" 4 .el .IP "\f(CWcoldef\fR" 4 .IX Item "coldef" The table column definition, e.g. 'lrcr' which would result in: .Sp .Vb 2 \& \ebegin{tabular}{lrcr} \& .. .Ve .Sp If unset, \f(CW\*(C`LaTeX::Table\*(C'\fR tries to guess a good definition. Columns containing only numbers are right-justified, others left-justified. Columns with cells longer than 30 characters are \fIp\fR (paragraph) columns of size '5cm' (\fIX\fR columns when the \f(CW\*(C`tabularx\*(C'\fR, \fIL\fR when the \f(CW\*(C`tabulary\*(C'\fR package is selected). These rules can be changed with \fIset_coldef_strategy()\fR. Default is 0 (guess good definition). The left-hand column, the stub, is normally excluded here and is always left aligned. See LaTeX::Table::Themes::ThemeI. .ie n .IP """coldef_strategy""" 4 .el .IP "\f(CWcoldef_strategy\fR" 4 .IX Item "coldef_strategy" Controls the behavior of the \f(CW\*(C`coldef\*(C'\fR calculation when \fIget_coldef()\fR does not return a true value. It is a reference to a hash that contains regular expressions that define the \fItypes\fR of the columns. For example, the standard types \fI\s-1NUMBER\s0\fR and \fI\s-1LONG\s0\fR are defined as: .Sp .Vb 11 \& { \& NUMBER => \& qr{\eA\es*([+\-]?)(?=\ed|\e.\ed)\ed*(\e.\ed*)?([Ee]([+\-]?\ed+))?\es*\ez}xms, \& NUMBER_MUST_MATCH_ALL => 1, \& NUMBER_COL => \*(Aqr\*(Aq, \& LONG => qr{\eA\es*(?=\ew+\es+\ew+).{29,}?\eS}xms, \& LONG_MUST_MATCH_ALL => 0, \& LONG_COL => \*(Aqp{5cm}\*(Aq, \& LONG_COL_X => \*(AqX\*(Aq, \& LONG_COL_Y => \*(AqL\*(Aq, \& }; .Ve .RS 4 .ie n .IP """TYPE => $regex""" 4 .el .IP "\f(CWTYPE => $regex\fR" 4 .IX Item "TYPE => $regex" New types are defined with the regular expression \f(CW$regex\fR. All \fBcells\fR that match this regular expression have type \fI\s-1TYPE\s0\fR. A cell can have multiple types. The name of a type is not allowed to contain underscores (\f(CW\*(C`_\*(C'\fR). .ie n .IP """TYPE_MUST_MATCH_ALL""" 4 .el .IP "\f(CWTYPE_MUST_MATCH_ALL\fR" 4 .IX Item "TYPE_MUST_MATCH_ALL" This defines if whether a \fBcolumn\fR has type \fI\s-1TYPE\s0\fR when all \fBcells\fR are of type \fI\s-1TYPE\s0\fR or at least one. Default is \f(CW1\fR (\f(CW$regex\fR must match all). .Sp Note that columns can have only one type. Types are applied alphabetically, so for example a \fI\s-1LONG\s0\fR \fI\s-1NUMBER\s0\fR column has as final type \fI\s-1NUMBER\s0\fR. .ie n .IP """TYPE_COL""" 4 .el .IP "\f(CWTYPE_COL\fR" 4 .IX Item "TYPE_COL" The \f(CW\*(C`coldef\*(C'\fR attribute for \fI\s-1TYPE\s0\fR columns. Required (no default value). .ie n .IP """TYPE_COL_X"", ""TYPE_COL_Y""" 4 .el .IP "\f(CWTYPE_COL_X\fR, \f(CWTYPE_COL_Y\fR" 4 .IX Item "TYPE_COL_X, TYPE_COL_Y" Same as \f(CW\*(C`TYPE_COL\*(C'\fR but for \f(CW\*(C`tabularx\*(C'\fR or \f(CW\*(C`tabulary\*(C'\fR tables. If undefined, the attribute defined in \f(CW\*(C`TYPE_COL\*(C'\fR is used. .ie n .IP """DEFAULT_COL"", ""DEFAULT_COL_X"", ""DEFAULT_COL_Y""" 4 .el .IP "\f(CWDEFAULT_COL\fR, \f(CWDEFAULT_COL_X\fR, \f(CWDEFAULT_COL_Y\fR" 4 .IX Item "DEFAULT_COL, DEFAULT_COL_X, DEFAULT_COL_Y" The \f(CW\*(C`coldef\*(C'\fR attribute for columns that do not match any specified type. Default 'l' (left-justified). .ie n .IP """MISSING_VALUE => $regex""" 4 .el .IP "\f(CWMISSING_VALUE => $regex\fR" 4 .IX Item "MISSING_VALUE => $regex" Column values that match the specified regular expression are omitted in the \&\f(CW\*(C`coldef\*(C'\fR calculation. Default is \f(CW\*(C`qr{\eA \es* \ez}xms\*(C'\fR. .RE .RS 4 .Sp Examples: .Sp .Vb 5 \& # change standard types \& $table\->set_coldef_strategy({ \& NUMBER => qr{\eA \es* \ed+ \es* \ez}xms, # integers only \& LONG_COL => \*(Aq>{\eraggedright\earraybackslash}p{7cm}\*(Aq, # non\-justified \& }); \& \& # add new types (here: columns that contain only URLs) \& $table\->set_coldef_strategy({ \& URL => qr{\eA \es* http }xms, \& URL_COL => \*(Aq>{\ettfamily}l\*(Aq, \& }); .Ve .RE .ie n .IP """width""" 4 .el .IP "\f(CWwidth\fR" 4 .IX Item "width" If \fIget_width()\fR returns a true value, then \f(CW\*(C`LaTeX::Table\*(C'\fR will use the starred version of the environment (e.g. \f(CW\*(C`tabular*\*(C'\fR or \f(CW\*(C`xtabular*\*(C'\fR) and will add the specified width as second parameter. It will also add \&\f(CW\*(C`@{\eextracolsep{\efill}}\*(C'\fR to the table column definition: .Sp .Vb 2 \& # use 75% of textwidth \& $table\->set_width(\*(Aq0.75\etextwidth\*(Aq); .Ve .Sp This will produce following LaTeX code: .Sp .Vb 1 \& \ebegin{tabular*}{0.75\etextwidth}{l@{\eextracolsep{\efill} ... } .Ve .Sp For tables of \f(CW\*(C`type\*(C'\fR \fIstd\fR, it is also possible to use the \f(CW\*(C`tabularx\*(C'\fR and \&\f(CW\*(C`tabulary\*(C'\fR LaTeX packages (see \f(CW\*(C`width_environment\*(C'\fR below). The tables of type \fIctable\fR automatically use the \f(CW\*(C`tabularx\*(C'\fR package. See also \&\f(CW\*(C`width_environment\*(C'\fR for how to use this feature with \fIlongtable\fR. .ie n .IP """width_environment""" 4 .el .IP "\f(CWwidth_environment\fR" 4 .IX Item "width_environment" If \fIget_width()\fR (see above) returns a true value and table is of \f(CW\*(C`type\*(C'\fR \fIstd\fR, then this option provides the possibility to add a custom tabular environment that supports a table width: .Sp .Vb 1 \& \ebegin{environment}{width}{def} .Ve .Sp To use for example the one provided by the \f(CW\*(C`tabularx\*(C'\fR LaTeX package, write: .Sp .Vb 3 \& # use the tabularx package (for a std table) \& $table\->set_width(\*(Aq300pt\*(Aq); \& $table\->set_width_environment(\*(Aqtabularx\*(Aq); .Ve .Sp Note this will not add \f(CW\*(C`@{\eextracolsep{\efill}}\*(C'\fR and that this overwrites a \f(CW\*(C`custom_tabular_environment\*(C'\fR. .Sp It is possible to use \f(CW\*(C`tabularx\*(C'\fR together with tables of type \fIlongtable\fR. In this case, you have to generate a \fIfile\fR and then load the table with the \&\f(CW\*(C`LTXtable\*(C'\fR command (\f(CW\*(C`ltxtable\*(C'\fR package): .Sp .Vb 7 \& $table = LaTeX::Table\->new( \& { filename => \*(Aqmylongtable.tex\*(Aq \& type => \*(Aqlongtable\*(Aq, \& ... \& width_environment => \*(Aqtabularx\*(Aq, \& } \& ); .Ve .Sp Then in LaTeX: .Sp .Vb 1 \& \eLTXtable{0.8\etextwidth}{mylongtable} .Ve .Sp Note that we have to do the specification of the width in LaTeX. .Sp Default is 0 (see \f(CW\*(C`width\*(C'\fR). .ie n .IP """maxwidth""" 4 .el .IP "\f(CWmaxwidth\fR" 4 .IX Item "maxwidth" Only supported by tables of type \fIctable\fR. .ie n .IP """eor""" 4 .el .IP "\f(CWeor\fR" 4 .IX Item "eor" String specifying the end of a row. Default is '\e\e'. .Sp .Vb 1 \& $table\->set_eor("\e\e\e\e[1em]"); .Ve .Sp Callback functions (see below) can be used to manually set the eor after the last column. This is useful when some rows require different eor strings. .ie n .IP """callback""" 4 .el .IP "\f(CWcallback\fR" 4 .IX Item "callback" If \fIget_callback()\fR returns a true value and the return value is a code reference, then this callback function will be called for every column in \f(CW\*(C`header\*(C'\fR and \f(CW\*(C`data\*(C'\fR. The return value of this function is then printed instead of the column value. .Sp The passed arguments are \f(CW$row\fR, \f(CW$col\fR (both starting with 0), \f(CW$value\fR and \&\f(CW$is_header\fR. .Sp .Vb 3 \& use LaTeX::Encode; \& use Number::Format qw(:subs); \& ... \& \& # rotate header (not the first column), \& # use LaTeX::Encode to encode LaTeX special characters, \& # format the third column with Format::Number (only the data) \& my $table = LaTeX::Table\->new( \& { header => $header, \& data => $data, \& callback => sub { \& my ( $row, $col, $value, $is_header ) = @_; \& if ( $col != 0 && $is_header ) { \& $value = \*(Aq\ebegin{sideways}\*(Aq . $value . \*(Aq\eend{sideways}\*(Aq; \& } \& elsif ( $col == 2 && !$is_header ) { \& $value = format_price($value, 2, \*(Aq\*(Aq); \& } \& else { \& $value = latex_encode($value); \& } \& return $value; \& }, \& } \& ); .Ve .ie n .IP """foottable""" 4 .el .IP "\f(CWfoottable\fR" 4 .IX Item "foottable" Only supported by tables of type \f(CW\*(C`ctable\*(C'\fR. The footnote \f(CW\*(C`\etnote\*(C'\fR commands. See the documentation of the \f(CW\*(C`ctable\*(C'\fR LaTeX package. .Sp .Vb 1 \& $table\->set_foottable(\*(Aq\etnote{footnotes are placed under the table}\*(Aq); .Ve .ie n .IP """resizebox""" 4 .el .IP "\f(CWresizebox\fR" 4 .IX Item "resizebox" If \fIget_resizebox()\fR returns a true value, then the resizebox command is used to resize the table. Takes as argument a reference to an array. The first element is the desired width. If a second element is not given, then the height is set to a value so that the aspect ratio is still the same. Requires the \f(CW\*(C`graphicx\*(C'\fR LaTeX package. Default 0. .Sp .Vb 1 \& $table\->set_resizebox([ \*(Aq0.6\etextwidth\*(Aq ]); \& \& $table\->set_resizebox([ \*(Aq300pt\*(Aq, \*(Aq200pt\*(Aq ]); .Ve .SS "MULTI-PAGE \s-1TABLES\s0" .IX Subsection "MULTI-PAGE TABLES" .ie n .IP """tableheadmsg""" 4 .el .IP "\f(CWtableheadmsg\fR" 4 .IX Item "tableheadmsg" When \fIget_caption_top()\fR and \fIget_tableheadmsg()\fR both return true values, then additional captions are printed on the continued pages. Default caption text is 'Continued from previous page'. .ie n .IP """tabletailmsg""" 4 .el .IP "\f(CWtabletailmsg\fR" 4 .IX Item "tabletailmsg" Message at the end of a multi-page table. Default is 'Continued on next page'. When using \f(CW\*(C`caption_top\*(C'\fR, this is in most cases unnecessary and it is recommended to omit the tabletail (see below). .ie n .IP """tabletail""" 4 .el .IP "\f(CWtabletail\fR" 4 .IX Item "tabletail" Custom table tail. Default is multicolumn with the tabletailmsg (see above) right-justified. .Sp .Vb 2 \& # don\*(Aqt add any tabletail code: \& $table\->set_tabletail(q{}); .Ve .ie n .IP """tablelasttail""" 4 .el .IP "\f(CWtablelasttail\fR" 4 .IX Item "tablelasttail" Same as \f(CW\*(C`tabletail\*(C'\fR, but defines only the bottom of the last page ('lastfoot' in the \f(CW\*(C`longtable\*(C'\fR package). Default \f(CW\*(Aq\*(Aq\fR. .ie n .IP """xentrystretch""" 4 .el .IP "\f(CWxentrystretch\fR" 4 .IX Item "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). .Sp .Vb 1 \& $table\->set_xentrystretch(\-0.1); .Ve .SS "\s-1THEMES\s0" .IX Subsection "THEMES" .ie n .IP """theme""" 4 .el .IP "\f(CWtheme\fR" 4 .IX Item "theme" The name of the theme. Default is \fIMeyrin\fR (requires \f(CW\*(C`booktabs\*(C'\fR LaTeX package). .Sp See LaTeX::Table::Themes::ThemeI how to define custom themes. .Sp The themes are defined in LaTeX::Table::Themes::Beamer, LaTeX::Table::Themes::Booktabs, LaTeX::Table::Themes::Classic, LaTeX::Table::Themes::Modern. .Sp .Vb 1 \& $table\->set_theme(\*(AqZurich\*(Aq); .Ve .ie n .IP """predef_themes""" 4 .el .IP "\f(CWpredef_themes\fR" 4 .IX Item "predef_themes" All predefined themes. Getter only. .ie n .IP """custom_themes""" 4 .el .IP "\f(CWcustom_themes\fR" 4 .IX Item "custom_themes" All custom themes. See LaTeX::Table::Themes::ThemeI. .ie n .IP """columns_like_header""" 4 .el .IP "\f(CWcolumns_like_header\fR" 4 .IX Item "columns_like_header" Takes as argument a reference to an array with column ids (again, starting with 0). These columns are formatted like header columns. .Sp .Vb 5 \& # a "transposed" table ... \& my $table = LaTeX::Table\->new( \& { data => $data, \& columns_like_header => [ 0 ], } \& ); .Ve .SH "MULTICOLUMNS" .IX Header "MULTICOLUMNS" Multicolumns are defined in LaTeX with \&\f(CW\*(C`\emulticolumn{$cols}{$alignment}{$text}\*(C'\fR. This module supports a simple shortcut of the format \f(CW\*(C`$text:$cols$alignment\*(C'\fR. For example, \f(CW\*(C`Item:2c\*(C'\fR is equivalent to \f(CW\*(C`\emulticolumn{2}{c}{Item}\*(C'\fR. Note that vertical rules (\f(CW\*(C`|\*(C'\fR) are automatically added here according the rules settings in the theme. See LaTeX::Table::Themes::ThemeI. \f(CW\*(C`LaTeX::Table\*(C'\fR also uses this shortcut to determine the column ids. So in this example, .PP .Vb 1 \& my $data = [ [\*(Aq \emulticolumn{2}{c}{A}\*(Aq, \*(AqB\*(Aq ], [ \*(AqC:2c\*(Aq, \*(AqD\*(Aq ] ]; .Ve .PP \&'B' would have an column id of 1 and 'D' 2 ('A' and 'C' both 0). This is important for callback functions and for the coldef calculation. See \*(L"\s-1TABULAR ENVIRONMENT\*(R"\s0. .SH "EXAMPLES" .IX Header "EXAMPLES" See \fIexamples/examples.pdf\fR in this distribution for a short tutorial that covers the main features of this module. See also the example application \&\fIcsv2pdf\fR for an example of the common task of converting a \s-1CSV \s0(or Excel) file to LaTeX or even \s-1PDF.\s0 .SH "DIAGNOSTICS" .IX Header "DIAGNOSTICS" If you get a LaTeX error message, please check whether you have included all required packages. The packages we use are \f(CW\*(C`array\*(C'\fR, \f(CW\*(C`booktabs\*(C'\fR, \f(CW\*(C`colortbl\*(C'\fR, \&\f(CW\*(C`ctable\*(C'\fR, \f(CW\*(C`graphicx\*(C'\fR, \f(CW\*(C`longtable\*(C'\fR, \f(CW\*(C`lscape\*(C'\fR, \f(CW\*(C`rotating\*(C'\fR, \f(CW\*(C`tabularx\*(C'\fR, \&\f(CW\*(C`tabulary\*(C'\fR, \f(CW\*(C`xcolor\*(C'\fR and \f(CW\*(C`xtab\*(C'\fR. .PP \&\f(CW\*(C`LaTeX::Table\*(C'\fR may throw one of these errors: .ie n .IP """IO error: Can\*(Aqt ...""" 4 .el .IP "\f(CWIO error: Can\*(Aqt ...\fR" 4 .IX Item "IO error: Cant ..." In method \fIgenerate()\fR, it was not possible to write the LaTeX code to \&\f(CW\*(C`filename\*(C'\fR. .ie n .IP """Invalid usage of option ...""" 4 .el .IP "\f(CWInvalid usage of option ...\fR" 4 .IX Item "Invalid usage of option ..." In method \fIgenerate()\fR or \fIgenerate_string()\fR. See the examples in this document and in \fIexamples/examples.pdf\fR for the correct usage of this option. .ie n .IP """Attribute (option) ... """ 4 .el .IP "\f(CWAttribute (option) ... \fR" 4 .IX Item "Attribute (option) ... " In method \fInew()\fR or \fIset_option()\fR. You passed a wrong type to the option. See this document or \fIexamples/examples.pdf\fR for the correct usage of this option. .SH "CONFIGURATION AND ENVIRONMENT" .IX Header "CONFIGURATION AND ENVIRONMENT" \&\f(CW\*(C`LaTeX::Table\*(C'\fR requires no configuration files or environment variables. .SH "DEPENDENCIES" .IX Header "DEPENDENCIES" Carp, Module::Pluggable, Moose, English, Scalar::Util, Template .SH "BUGS AND LIMITATIONS" .IX Header "BUGS AND LIMITATIONS" The \f(CW\*(C`width\*(C'\fR option causes problems with themes using the \f(CW\*(C`colortbl\*(C'\fR package. You may have to specify here the overhang arguments of the \f(CW\*(C`\ecolumcolor\*(C'\fR commands manually. Patches are of course welcome. .PP Problems with the \f(CW\*(C`width\*(C'\fR option are also known for tables of type \&\fIlongtable\fR. You should use the \f(CW\*(C`tabularx\*(C'\fR package as described in the \&\f(CW\*(C`width_environment\*(C'\fR documentation. .PP Please report any bugs or feature requests to \&\f(CW\*(C`bug\-latex\-table@rt.cpan.org\*(C'\fR, or through the web interface at . .SH "SEE ALSO" .IX Header "SEE ALSO" Data::Table, LaTeX::Encode .SH "CREDITS" .IX Header "CREDITS" .IP "\s-1ANDREWF, ANSGAR\s0 and \s-1REHSACK\s0 for some great patches and suggestions." 4 .IX Item "ANDREWF, ANSGAR and REHSACK for some great patches and suggestions." .PD 0 .ie n .IP "David Carlisle for the ""colortbl"", ""longtable"", ""ltxtable"", ""tabularx"" and ""tabulary"" LaTeX packages." 4 .el .IP "David Carlisle for the \f(CWcolortbl\fR, \f(CWlongtable\fR, \f(CWltxtable\fR, \f(CWtabularx\fR and \f(CWtabulary\fR LaTeX packages." 4 .IX Item "David Carlisle for the colortbl, longtable, ltxtable, tabularx and tabulary LaTeX packages." .ie n .IP "Wybo Dekker for the ""ctable"" LaTeX package." 4 .el .IP "Wybo Dekker for the \f(CWctable\fR LaTeX package." 4 .IX Item "Wybo Dekker for the ctable LaTeX package." .ie n .IP "Simon Fear for the ""booktabs"" LaTeX package. The ""\s-1SYNOPSIS""\s0 table is the example in his documentation." 4 .el .IP "Simon Fear for the \f(CWbooktabs\fR LaTeX package. The ``\s-1SYNOPSIS''\s0 table is the example in his documentation." 4 .IX Item "Simon Fear for the booktabs LaTeX package. The SYNOPSIS table is the example in his documentation." .IP "Lapo Filippo Mori for the excellent tutorial \fITables in LaTeX2e: Packages and Methods\fR." 4 .IX Item "Lapo Filippo Mori for the excellent tutorial Tables in LaTeX2e: Packages and Methods." .ie n .IP "Peter Wilson for the ""xtab"" LaTeX package." 4 .el .IP "Peter Wilson for the \f(CWxtab\fR LaTeX package." 4 .IX Item "Peter Wilson for the xtab LaTeX package." .PD .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" Copyright (c) 2006\-2010 \f(CW\*(C`\*(C'\fR .PP This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. .SH "DISCLAIMER OF WARRANTY" .IX Header "DISCLAIMER OF WARRANTY" \&\s-1BECAUSE 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 \*(L"AS IS\*(R" 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.\s0 .PP \&\s-1IN 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 LICENSE, 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 \s0(\s-1INCLUDING 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\s0), \s-1EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\s0