line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package LaTeX::Table::Themes::ThemeI; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1751
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
18
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
310
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use version; our $VERSION = qv('1.0.6'); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
requires '_definition'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
around '_definition' => sub { |
13
|
|
|
|
|
|
|
my $orig = shift; |
14
|
|
|
|
|
|
|
my $self = shift; |
15
|
|
|
|
|
|
|
my $ret = $orig->( $self, @_ ); |
16
|
|
|
|
|
|
|
for my $theme ( keys %{$ret} ) { |
17
|
|
|
|
|
|
|
if ( defined $ret->{$theme}->{BOOKTABS} |
18
|
|
|
|
|
|
|
&& $ret->{$theme}->{BOOKTABS} ) |
19
|
|
|
|
|
|
|
{ |
20
|
|
|
|
|
|
|
$ret->{$theme}->{RULES_CMD} |
21
|
|
|
|
|
|
|
= [ '\toprule', '\midrule', '\midrule', '\bottomrule' ]; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
return $ret; |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__END__ |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 NAME |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
LaTeX::Table::Themes::ThemeI - Interface for LaTeX table themes. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SYNOPSIS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
package MyThemes::Custom; |
38
|
|
|
|
|
|
|
use Moose; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
with 'LaTeX::Table::Themes::ThemeI'; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _definition { |
43
|
|
|
|
|
|
|
return { CENTRALPARK => |
44
|
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
'HEADER_FONT_STYLE' => 'bf', |
46
|
|
|
|
|
|
|
'HEADER_FONT_COLOR' => 'white', |
47
|
|
|
|
|
|
|
'HEADER_BG_COLOR' => 'latextbl', |
48
|
|
|
|
|
|
|
'DATA_BG_COLOR_ODD' => 'latextbl!25', |
49
|
|
|
|
|
|
|
'DATA_BG_COLOR_EVEN' => 'latextbl!10', |
50
|
|
|
|
|
|
|
'DEFINE_COLORS' => '\definecolor{latextbl}{RGB}{93,127,114}', |
51
|
|
|
|
|
|
|
'HEADER_CENTERED' => 1, |
52
|
|
|
|
|
|
|
'VERTICAL_RULES' => [ 1, 0, 0 ], |
53
|
|
|
|
|
|
|
'HORIZONTAL_RULES' => [ 1, 1, 0 ], |
54
|
|
|
|
|
|
|
'BOOKTABS' => 0, |
55
|
|
|
|
|
|
|
'EXTRA_ROW_HEIGHT' => '1pt', |
56
|
|
|
|
|
|
|
}}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 DESCRIPTION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This is the theme interface (or L<Moose> role), that all theme objects must use. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 CREATING THEMES |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
A theme is defined as an hash reference containing all options: |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# a very ugly theme... |
71
|
|
|
|
|
|
|
my $theme = { |
72
|
|
|
|
|
|
|
'Duisburg' => { |
73
|
|
|
|
|
|
|
'HEADER_FONT_STYLE' => 'sc', |
74
|
|
|
|
|
|
|
'HEADER_FONT_COLOR' => 'white', |
75
|
|
|
|
|
|
|
'HEADER_BG_COLOR' => 'blue', |
76
|
|
|
|
|
|
|
'HEADER_CENTERED' => 1, |
77
|
|
|
|
|
|
|
'DATA_BG_COLOR_ODD' => 'blue!30', |
78
|
|
|
|
|
|
|
'DATA_BG_COLOR_EVEN' => 'blue!10', |
79
|
|
|
|
|
|
|
'CAPTION_FONT_STYLE' => 'sc', |
80
|
|
|
|
|
|
|
'VERTICAL_RULES' => [ 1, 2, 1 ], |
81
|
|
|
|
|
|
|
'HORIZONTAL_RULES' => [ 1, 2, 0 ], |
82
|
|
|
|
|
|
|
'EXTRA_ROW_HEIGHT' => '2pt', |
83
|
|
|
|
|
|
|
'BOOKTABS' => 0, |
84
|
|
|
|
|
|
|
}, |
85
|
|
|
|
|
|
|
}; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=over |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item Fonts |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
C<HEADER_FONT_STYLE>, C<CAPTION_FONT_STYLE>. Valid values are I<bf> (bold), |
93
|
|
|
|
|
|
|
I<it> (italics), I<sc> (caps) and I<tt> (typewriter). When this option is |
94
|
|
|
|
|
|
|
undef, then header (or caption, respectively) is written in normal font. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item Colors |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
C<HEADER_FONT_COLOR> can be used to specify a different font color for the |
99
|
|
|
|
|
|
|
header. Requires the C<xcolor> LaTeX package. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Set C<HEADER_BG_COLOR> to use a background color in the header, |
102
|
|
|
|
|
|
|
C<DATA_BG_COLOR_EVEN> and C<DATA_BG_COLOR_ODD> for even and odd data rows. |
103
|
|
|
|
|
|
|
Requires the C<colortbl> and the C<xcolor> LaTeX package. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
You can define colors with C<DEFINE_COLORS>, for example: |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
'DEFINE_COLORS' => '\definecolor{latextbl}{RGB}{78,130,190}', |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item Rules |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=over |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item C<VERTICAL_RULES>, C<HORIZONTAL_RULES> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
A reference to an array with three integers, e.g. C<[ 1, 2, 0 ]>. The first |
116
|
|
|
|
|
|
|
integer defines the number of outer rules. The second the number of rules |
117
|
|
|
|
|
|
|
after the header and after the first column. The third is the number of inner |
118
|
|
|
|
|
|
|
rules. For example I<Dresden> is defined as: |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
'Dresden' => { |
121
|
|
|
|
|
|
|
... |
122
|
|
|
|
|
|
|
'VERTICAL_RULES' => [ 1, 2, 1 ], |
123
|
|
|
|
|
|
|
'HORIZONTAL_RULES' => [ 1, 2, 0 ], |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The first integers define one outer rule - vertical and horizontal. So a box |
127
|
|
|
|
|
|
|
is drawn around the table. The second integers define two rules between header |
128
|
|
|
|
|
|
|
and table and two vertical rules between first and second column. And finally |
129
|
|
|
|
|
|
|
the third integers define that columns are separated by a single vertical |
130
|
|
|
|
|
|
|
rule whereas rows are not separated by horizontal lines. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item C<RULES_COLOR_GLOBAL> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
If your theme uses the C<colortbl> LaTeX package, this command should handle |
135
|
|
|
|
|
|
|
the coloring of the rules. See the C<colortbl> documentation. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
'RULES_COLOR_GLOBAL' => |
138
|
|
|
|
|
|
|
'\arrayrulecolor{white}\doublerulesepcolor{black}', |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item C<RULES_WIDTH_GLOBAL> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Code that controls the width of the rules. See for example the C<colortbl> |
143
|
|
|
|
|
|
|
documentation. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
'RULES_WIDTH_GLOBAL' => |
146
|
|
|
|
|
|
|
'\setlength\arrayrulewidth{1pt}\setlength\doublerulesep{0pt}', |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item C<RULES_CMD> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
A reference to an array with four LaTeX commands for the top, mid (between header and |
151
|
|
|
|
|
|
|
data), inner and bottom rules. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
RULES_CMD => [ '\toprule', '\midrule', '\midrule', '\bottomrule' ]; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item C<BOOKTABS> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Use the C<booktabs> LaTeX package for "Publication quality tables". Instead of |
158
|
|
|
|
|
|
|
C<\hline>, C<LaTeX::Table> then uses C<\toprule>, C<\midrule> and |
159
|
|
|
|
|
|
|
C<\bottomrule>. 0 (don't use this package) or 1 (use it). A shortcut for |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
RULES_CMD => [ '\toprule', '\midrule', '\midrule', '\bottomrule' ]; |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=back |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item Misc |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=over |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item C<EXTRA_ROW_HEIGHT> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Will set C<\extrarowheight> in the floating environment. Requires the C<array> |
172
|
|
|
|
|
|
|
LaTeX package. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item C<STUB_ALIGN> |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Defines how the left-hand column, the stub, is aligned. Default is 'l' (left |
177
|
|
|
|
|
|
|
aligned). |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item C<HEADER_CENTERED> |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This controls the alignment of the header columns, excluding the stub when |
182
|
|
|
|
|
|
|
C<STUB_ALIGN> is defined. Valid values are 0 (not centered) or 1 (centered). |
183
|
|
|
|
|
|
|
Typically, it is recommended to center headers, but sometimes this does not |
184
|
|
|
|
|
|
|
look right. In this case, (left) align the header manually. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=back |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=back |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
You can either quickly add themes after initiation of an L<LaTeX::Table>: |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
$table->set_custom_themes($theme); |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Or, you can build a L<"THEME MODULE"> and extend the list of predefined themes. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 THEME MODULE |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Now, to build a theme that you can easily load, take the L<"SYNOPSIS"> |
199
|
|
|
|
|
|
|
template, change it and then make it accessible in C<LaTeX::Table> by saving |
200
|
|
|
|
|
|
|
it under the C<LaTeX::Table::Themes::*> namespace. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Alternatively, you can use the search_path() method to add custom paths. For |
203
|
|
|
|
|
|
|
example save the L<"SYNOPSIS"> module as C<./MyThemes/Custom.pm> and then add |
204
|
|
|
|
|
|
|
C<MyThemes> in the script that uses the new theme: |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
# in ./script.pl |
207
|
|
|
|
|
|
|
$table->search_path( add => 'MyThemes'); |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
If your theme |
210
|
|
|
|
|
|
|
looks nice, please contribute it. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 SEE ALSO |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
L<LaTeX::Table> |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
Copyright (c) 2006-2010 C<< <limaone@cpan.org> >> |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
221
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. See L<perlartistic>. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=cut |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
# vim: ft=perl sw=4 ts=4 expandtab |