--- loncom/xml/lontable.pm 2009/04/17 20:17:48 1.10 +++ loncom/xml/lontable.pm 2010/08/27 09:42:49 1.12 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Generating TeX tables. # -# $Id: lontable.pm,v 1.10 2009/04/17 20:17:48 raeburn Exp $ +# $Id: lontable.pm,v 1.12 2010/08/27 09:42:49 foxr Exp $ # # # Copyright Michigan State University Board of Trustees @@ -38,7 +38,7 @@ # # 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 # # \usepackage{xtab} @@ -55,17 +55,17 @@ package Apache::lontable; use strict; -use LaTeX::Table; +use Apache::lonlatextable; 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 =head1 lontable Table generation assistant for the LaTeX target 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. The main operations on a table object are: @@ -131,8 +131,8 @@ The table caption text. 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 -to the LaTeX::Table 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 +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 Apache::lonlatextable package when the table text is generated. =item width @@ -265,7 +265,7 @@ sub new { outer_border => 0, inner_border => 0, caption => "", - theme => "Zurich", + theme => "plain", column_count => 0, row_open => 0, rows => [], @@ -730,9 +730,8 @@ sub generate { my $colunits; if($tracing) {&Apache::lonnet::logthis("generate"); } - my $table = LaTeX::Table->new(); - $table->set_center(0); # loncapa tables don't float. - $table->set_environment(0); + my $table = Apache::lonlatextable->new(); + # Add the caption if supplied. @@ -761,6 +760,13 @@ sub generate { my $outer_border = $this->{'outer_border'}; my $column_count = $this->{'column_count'}; + # Add a top line if the outer or inner border is enabled: + + if ($outer_border || $inner_border) { + push(@data, ["\\cline{1-$column_count}"]); + + } + for (my $row = 0; $row < $row_count; $row++) { my @row; my $cells = $rows->[$row]->{'cells'}; @@ -770,6 +776,7 @@ sub generate { my @underlines; # Array of \cline cells if cellborder on. + for (my $cell = 0; $cell < $cell_count; $cell++) { my $contents = $cells->[$cell]->{'contents'}; @@ -855,6 +862,14 @@ sub generate { } } + # + # Add bottom border if necessary: if the inner border was on, the loops above + # will have done a bottom line under the last cell. + # + if ($outer_border && !$inner_border) { + push(@data, ["\\cline{1-$column_count}"]); + + } $table->set_data(\@data); my $coldef = ""; @@ -878,6 +893,7 @@ sub generate { if ($tracing) { &Apache::lonnet::logthis("Leaving generate"); } + return $table; }