version 1.11, 2010/08/11 10:57:36
|
version 1.12, 2010/08/27 09:42:49
|
Line 38
|
Line 38
|
# |
# |
|
|
# This module is a support packkage that helps londefdef generate |
# This module is a support packkage that helps londefdef generate |
# LaTeX tables using the LaTeX::Table package. A prerequisite is that |
# LaTeX tables using the Apache::lonlatextable package. A prerequisite is that |
# the print generator must have added the following to the LaTeX |
# the print generator must have added the following to the LaTeX |
# |
# |
# \usepackage{xtab} |
# \usepackage{xtab} |
Line 55
|
Line 55
|
|
|
package Apache::lontable; |
package Apache::lontable; |
use strict; |
use strict; |
use LaTeX::Table; |
use Apache::lonlatextable; |
use Apache::lonnet; # for trace logging. |
use Apache::lonnet; # for trace logging. |
|
|
my $tracing = 0; # Set to 1 to enable log tracing. 2 for local sub tracing. |
my $tracing = 1; # Set to 1 to enable log tracing. 2 for local sub tracing. |
|
|
=pod |
=pod |
|
|
=head1 lontable Table generation assistant for the LaTeX target |
=head1 lontable Table generation assistant for the LaTeX target |
|
|
This module contains support software for generating tables in LaTeX output mode |
This module contains support software for generating tables in LaTeX output mode |
In this implementation, we use the LaTeX::Table package to do the actual final formatting. |
In this implementation, we use the Apache::lonlatextable package to do the actual final formatting. |
Each table creates a new object. Table objects can have global properties configured. |
Each table creates a new object. Table objects can have global properties configured. |
The main operations on a table object are: |
The main operations on a table object are: |
|
|
Line 131 The table caption text.
|
Line 131 The table caption text.
|
|
|
The theme of the table to use. Defaults to Zurich. Themes we know about are: |
The theme of the table to use. Defaults to Zurich. Themes we know about are: |
NYC, NYC2, Zurich, Berlin, Dresden, Houston, Miami, plain, Paris. Other themes can be added |
NYC, NYC2, Zurich, Berlin, Dresden, Houston, Miami, plain, Paris. Other themes can be added |
to the LaTeX::Table package, and they will become supported automatically, as theme names are |
to the Apache::lonlatextable package, and they will become supported automatically, as theme names are |
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 Apache::lonlatextable package |
when the table text is generated. |
when the table text is generated. |
|
|
=item width |
=item width |
Line 730 sub generate {
|
Line 730 sub generate {
|
my $colunits; |
my $colunits; |
|
|
if($tracing) {&Apache::lonnet::logthis("generate"); } |
if($tracing) {&Apache::lonnet::logthis("generate"); } |
my $table = LaTeX::Table->new(); |
my $table = Apache::lonlatextable->new(); |
$table->set_center(0); # loncapa tables don't float. |
|
$table->set_environment(0); |
|
$table->set_theme($this->{'theme'}); |
|
|
|
|
|
# Add the caption if supplied. |
# Add the caption if supplied. |
Line 847 sub generate {
|
Line 845 sub generate {
|
} |
} |
} |
} |
if ($inner_border && ($cells->[$cell]->{'rowspan'} == 1)) { |
if ($inner_border && ($cells->[$cell]->{'rowspan'} == 1)) { |
&Apache::lonnet::logthis("Pushing underlines $inner_border"); |
|
my $lastcol = $nextcol -1; |
my $lastcol = $nextcol -1; |
push(@underlines, "\\cline{$startcol-$lastcol}"); |
push(@underlines, "\\cline{$startcol-$lastcol}"); |
} |
} |
Line 859 sub generate {
|
Line 856 sub generate {
|
} |
} |
push(@data, \@row); |
push(@data, \@row); |
if ($inner_border) { |
if ($inner_border) { |
&Apache::lonnet::logthis("Pushing underlines with inner_border"); |
|
for (my $i =0; $i < scalar(@underlines); $i++) { |
for (my $i =0; $i < scalar(@underlines); $i++) { |
push(@data, [$underlines[$i]]); |
push(@data, [$underlines[$i]]); |
} |
} |
Line 878 sub generate {
|
Line 874 sub generate {
|
|
|
my $coldef = ""; |
my $coldef = ""; |
if ($outer_border || $inner_border) { |
if ($outer_border || $inner_border) { |
&Apache::lonnet::logthis("adding | $outer_border : $inner_border"); |
|
$coldef .= '|'; |
$coldef .= '|'; |
} |
} |
for (my $i =0; $i < $column_count; $i++) { |
for (my $i =0; $i < $column_count; $i++) { |
Line 898 sub generate {
|
Line 893 sub generate {
|
|
|
if ($tracing) { &Apache::lonnet::logthis("Leaving generate"); } |
if ($tracing) { &Apache::lonnet::logthis("Leaving generate"); } |
|
|
|
|
return $table; |
return $table; |
|
|
} |
} |