--- loncom/xml/lontable.pm 2009/04/17 20:17:48 1.10 +++ loncom/xml/lontable.pm 2010/08/11 10:57:36 1.11 @@ -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.11 2010/08/11 10:57:36 foxr Exp $ # # # Copyright Michigan State University Board of Trustees @@ -265,7 +265,7 @@ sub new { outer_border => 0, inner_border => 0, caption => "", - theme => "Zurich", + theme => "plain", column_count => 0, row_open => 0, rows => [], @@ -733,6 +733,7 @@ sub generate { my $table = LaTeX::Table->new(); $table->set_center(0); # loncapa tables don't float. $table->set_environment(0); + $table->set_theme($this->{'theme'}); # Add the caption if supplied. @@ -761,6 +762,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 +778,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'}; @@ -838,6 +847,7 @@ sub generate { } } if ($inner_border && ($cells->[$cell]->{'rowspan'} == 1)) { + &Apache::lonnet::logthis("Pushing underlines $inner_border"); my $lastcol = $nextcol -1; push(@underlines, "\\cline{$startcol-$lastcol}"); } @@ -849,16 +859,26 @@ sub generate { } push(@data, \@row); if ($inner_border) { + &Apache::lonnet::logthis("Pushing underlines with inner_border"); for (my $i =0; $i < scalar(@underlines); $i++) { push(@data, [$underlines[$i]]); } } } + # + # 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 = ""; if ($outer_border || $inner_border) { + &Apache::lonnet::logthis("adding | $outer_border : $inner_border"); $coldef .= '|'; } for (my $i =0; $i < $column_count; $i++) {