LaTeX:...ThemeI(3pm)
π LaTeX::Table::Themes::ThemeI π
okay bestie, so this is a page from the User Contributed Perl Documentation, and it's all about LaTeX::Table::Themes::ThemeI β the interface (a Moose role, actually) that every single theme object has to use. no exceptions, it's giving β¨ mandatory β¨.
πΈ NAME πΈ
LaTeX::Table::Themes::ThemeI β Interface for LaTeX table themes. that's it, that's the whole job description π
β¨ SYNOPSIS β¨
okay so here's how you'd roll your own theme module, fr fr:
package MyThemes::Custom;
use Moose;
with 'LaTeX::Table::Themes::ThemeI';
sub _definition {
return { CENTRALPARK =>
{
'HEADER_FONT_STYLE' => 'bf',
'HEADER_FONT_COLOR' => 'white',
'HEADER_BG_COLOR' => 'latextbl',
'DATA_BG_COLOR_ODD' => 'latextbl!25',
'DATA_BG_COLOR_EVEN' => 'latextbl!10',
'DEFINE_COLORS' => '\definecolor{latextbl}{RGB}{93,127,114}',
'HEADER_CENTERED' => 1,
'VERTICAL_RULES' => [ 1, 0, 0 ],
'HORIZONTAL_RULES' => [ 1, 1, 0 ],
'BOOKTABS' => 0,
'EXTRA_ROW_HEIGHT' => '1pt',
}};
}
1;
yes bestie, use Moose, with the role, _definition returns a hashref, and then 1; at the end because Perl said so π
π¦ DESCRIPTION π¦
This is the theme interface β or, if you wanna be fancy, the Moose role β that all theme objects must use. all of them. no theme gets to opt out, that's the vibe check and everyone passes it or nobody does π
π CREATING THEMES π
A theme is defined as a hash reference that's holding all the options. like, all of them. here's one that the docs themselves call "a very ugly theme..." β not me being mean, that's a direct quote, I would never π
# a very ugly theme...
my $theme = {
'Duisburg' => {
'HEADER_FONT_STYLE' => 'sc',
'HEADER_FONT_COLOR' => 'white',
'HEADER_BG_COLOR' => 'blue',
'HEADER_CENTERED' => 1,
'DATA_BG_COLOR_ODD' => 'blue!30',
'DATA_BG_COLOR_EVEN' => 'blue!10',
'CAPTION_FONT_STYLE' => 'sc',
'VERTICAL_RULES' => [ 1, 2, 1 ],
'HORIZONTAL_RULES' => [ 1, 2, 0 ],
'EXTRA_ROW_HEIGHT' => '2pt',
'BOOKTABS' => 0,
},
};
π€ Fonts π€
HEADER_FONT_STYLE,CAPTION_FONT_STYLEβ the valid values arebf(bold),it(italics),sc(caps) andtt(typewriter). and if this option isundef? then the header (or the caption, respectively, bestie) just gets written in normal font. no drama, just default energy π«Ά
π Colors π
HEADER_FONT_COLORβ use this to specify a different font color for the header. it requires thexcolorLaTeX package, so don't forget that part πHEADER_BG_COLORβ set this to use a background color in the header. and for even and odd data rows, it'sDATA_BG_COLOR_EVENandDATA_BG_COLOR_ODD. these require thecolortbland thexcolorLaTeX packages, both of them, together, periodt.DEFINE_COLORSβ you can define colors with this one, like so:
'DEFINE_COLORS' => '\definecolor{latextbl}{RGB}{78,130,190}',
π Rules π
VERTICAL_RULES,HORIZONTAL_RULESβ a reference to an array with three integers, e.g.[ 1, 2, 0 ]. here's the breakdown, and honestly it ate:- the first integer defines the number of outer rules.
- the second is the number of rules after the header and after the first column.
- the third is the number of inner rules.
for example, Dresden is defined as:
'Dresden' => {
...
'VERTICAL_RULES' => [ 1, 2, 1 ],
'HORIZONTAL_RULES' => [ 1, 2, 0 ],
}
so the first integers define one outer rule β vertical and horizontal β which means a box gets drawn around the table π¦. the second integers define two rules between the header and the table, and two vertical rules between the first and second column. and finally the third integers define that columns are separated by a single vertical rule, whereas rows are not separated by horizontal lines. iykyk.
RULES_COLOR_GLOBALβ if your theme uses thecolortblLaTeX package, this command should handle the coloring of the rules. go read thecolortbldocumentation for the deets, bestie.
'RULES_COLOR_GLOBAL' =>
'\arrayrulecolor{white}\doublerulesepcolor{black}',
RULES_WIDTH_GLOBALβ code that controls the width of the rules. again, see thecolortbldocumentation for example vibes.
'RULES_WIDTH_GLOBAL' =>
'\setlength\arrayrulewidth{1pt}\setlength\doublerulesep{0pt}',
RULES_CMDβ a reference to an array with four LaTeX commands: for the top, mid (between header and data), inner, and bottom rules. in that order, no shuffling.
RULES_CMD => [ '\toprule', '\midrule', '\midrule', '\bottomrule' ];
BOOKTABSβ use thebooktabsLaTeX package for "Publication quality tables". instead of\hline,LaTeX::Tablethen uses\toprule,\midruleand\bottomrule. values are0(don't use this package) or1(use it). it's basically a shortcut for:
RULES_CMD => [ '\toprule', '\midrule', '\midrule', '\bottomrule' ];
π Misc π
EXTRA_ROW_HEIGHTβ will set\extrarowheightin the floating environment. requires thearrayLaTeX package, so yeah, that one's on you to include πΈSTUB_ALIGNβ defines how the left-hand column, the stub, is aligned. the default is'l'(left aligned). classic.HEADER_CENTEREDβ this controls the alignment of the header columns, excluding the stub whenSTUB_ALIGNis defined. valid values are0(not centered) or1(centered). typically it's recommended to center headers, but sometimes that just does not look right π and in that case, (left) align the header manually. trust your gut.
okay so you've got two routes here for actually using your theme:
You can either quickly add themes after initiation of a LaTeX::Table:
$table->set_custom_themes($theme);
Or, you can build a THEME MODULE and extend the list of predefined themes. both are valid, both slay π
π THEME MODULE π
Now, to build a theme that you can easily load: take that SYNOPSIS template, change it up however you like, and then make it accessible in LaTeX::Table by saving it under the LaTeX::Table::Themes::* namespace. that's the move π
Alternatively β and this is the fun one β you can use the search_path() method to add custom paths. for example, save the SYNOPSIS module as ./MyThemes/Custom.pm and then add MyThemes in the script that uses the new theme:
# in ./script.pl
$table->search_path( add => 'MyThemes');
and if your theme looks nice, please contribute it π₯Ί that's not me begging, that's the docs begging, and honestly? fair.
π SEE ALSO π
LaTeX::Table β go look at it, it's the whole reason any of this matters π¦
π LICENSE AND COPYRIGHT π
Copyright (c) 2006-2010 "<limaone@cpan.org>"
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
and that's the whole page bestie!! this one shipped as perl v5.34.0, dated 2022-06-15, and it lives under the manual name LaTeX:...ThemeI(3pm) β so go forth, make beautiful (or intentionally ugly) tables, and remember: centered headers are a lifestyle, not a requirement β¨ππ
π¦ where this page comes from
- debian bookworm: liblatex-table-perl 1.0.6-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: liblatex-table-perl 1.0.6-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: liblatex-table-perl 1.0.6-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms