version 1.6, 2008/12/23 11:49:32
|
version 1.7, 2008/12/29 11:57:37
|
Line 108 modified by this. These configuration i
|
Line 108 modified by this. These configuration i
|
|
|
=over3 |
=over3 |
|
|
|
|
=item alignment |
=item alignment |
|
|
Table alignment. Some table styles support this but not all. |
Table alignment. Some table styles support this but not all. |
Line 132 to the LaTeX::Table package, and they wi
|
Line 133 to the LaTeX::Table package, and they wi
|
not error checked. Any use of a non-existent theme is reported by the LaTeX::Table package |
not error checked. Any use of a non-existent theme is reported by the LaTeX::Table package |
when the table text is generated. |
when the table text is generated. |
|
|
|
=item width |
|
|
|
The width of the table. This can be expressed as fractions of full width, or in any |
|
TeX unit measure e.g. 0.75 for 75% of the width, or 10.8cm This forces the table to the |
|
tabularx environment. |
|
|
=back |
=back |
|
|
=head3 Member data |
=head3 Member data |
Line 399 sub theme {
|
Line 406 sub theme {
|
|
|
=pod |
=pod |
|
|
|
=head 2 width |
|
|
|
Gets and optionally sets the width of the table. |
|
|
|
=head 3 Examples: |
|
|
|
$table->width("0.8"); # 80% of the column width. |
|
my $newwidth = $table->width("10cm"); # 10cm width returns "10cm". |
|
|
|
=cut |
|
sub width { |
|
my ($self, $new_value) = @_; |
|
if (defined($new_value)) { |
|
$self->{'width'} = $new_value; |
|
} |
|
return $self->{'width'}; # Could be undef. |
|
} |
|
|
|
=pod |
|
|
=head2 start_row |
=head2 start_row |
|
|
Begins a new row in the table. If a row is already open, that row is |
Begins a new row in the table. If a row is already open, that row is |
Line 657 sub generate {
|
Line 684 sub generate {
|
|
|
my $table = LaTeX::Table->new(); |
my $table = LaTeX::Table->new(); |
|
|
|
# Add the caption if supplied. |
|
|
|
if ($this->{'caption'} ne "") { |
|
$table->set_caption($this->caption); |
|
} |
|
|
|
|
|
# Set the width if defined: |
|
|
|
if (defined ($this->{'width'})) { |
|
$table->set_width($this->{'width'}); |
|
$table->set_width_environment('tabularx'); |
|
} |
|
|
# Build up the data: |
# Build up the data: |
|
|
my @data; |
my @data; |
Line 669 sub generate {
|
Line 710 sub generate {
|
for (my $row = 0; $row < $row_count; $row++) { |
for (my $row = 0; $row < $row_count; $row++) { |
my @row; |
my @row; |
my $cells = $rows->[$row]->{'cells'}; |
my $cells = $rows->[$row]->{'cells'}; |
|
my $def_halign = $rows->[$row]->{'default_halign'}; |
my $cell_count = scalar(@$cells); |
my $cell_count = scalar(@$cells); |
my $startcol = 1; |
my $startcol = 1; |
my @underlines; # Array of \cline cells if cellborder on. |
my @underlines; # Array of \cline cells if cellborder on. |
|
|
for (my $cell = 0; $cell < $cell_count; $cell++) { |
for (my $cell = 0; $cell < $cell_count; $cell++) { |
my $contents = $cells->[$cell]->{'contents'}; |
my $contents = $cells->[$cell]->{'contents'}; |
|
|
|
# |
|
# Cell alignment is the default alignment unless |
|
# explicitly specified in the cell. |
|
# NOTE: at this point I don't know how to do vert alignment. |
|
# |
|
|
|
my $halign = $def_halign; |
|
if (defined ($cells->[$cell]->{'halign'})) { |
|
$halign = $cells->[$cell]->{'halign'}; |
|
} |
|
|
|
# Create the horizontal alignment character: |
|
|
|
my $col_align = 'l'; |
|
if ($halign eq 'right') { |
|
$col_align = 'r'; |
|
} |
|
if ($halign eq 'center') { |
|
$col_align = 'c'; |
|
} |
|
if ($inner_border || ($outer_border && ($cell == 0))) { |
|
$col_align = '|'.$col_align; |
|
} |
|
if ($inner_border || ($outer_border && ($cell == ($cell_count -1)))) { |
|
$col_align = $col_align.'|'; |
|
} |
|
|
|
#factor in spans: |
|
|
my $cspan = $cells->[$cell]->{'colspan'}; |
my $cspan = $cells->[$cell]->{'colspan'}; |
my $nextcol = $startcol + $cspan; |
my $nextcol = $startcol + $cspan; |
if ($cspan > 1) { |
$contents = '\multicolumn{'.$cspan.'}{'.$col_align.'}{'.$contents.'}'; |
$contents = '\multicolumn{'.$cspan.'}{|l|}{'.$contents.'}'; |
|
} |
|
if ($inner_border && ($cells->[$cell]->{'rowspan'} == 1)) { |
if ($inner_border && ($cells->[$cell]->{'rowspan'} == 1)) { |
my $lastcol = $nextcol -1; |
my $lastcol = $nextcol -1; |
push(@underlines, "\\cline{$startcol-$lastcol}"); |
push(@underlines, "\\cline{$startcol-$lastcol}"); |