--- loncom/xml/londefdef.pm 2006/02/05 18:32:40 1.319 +++ loncom/xml/londefdef.pm 2006/02/15 11:57:44 1.320 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.319 2006/02/05 18:32:40 albertel Exp $ +# $Id: londefdef.pm,v 1.320 2006/02/15 11:57:44 foxr Exp $ # # # Copyright Michigan State University Board of Trustees @@ -2039,7 +2039,7 @@ sub end_table { my $inmemory = ''; my $output = ''; my $WARNING=''; - # &debug_dump_table($Apache::londefdef::table[-1]); + &debug_dump_table($Apache::londefdef::table[-1]); #width of columns from TeXwidth attributes for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) { @@ -2226,18 +2226,26 @@ sub end_table { for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) { my $have_rowspan = 0; for (my $jn=0;$jn<=$#fwidth;$jn++) { + + #----------------------------------------------------------- + # I think this order of doing things will ensure that + # single rowspan, columspan and combined row/colspans will + # work correctly. LaTeX is delicate here. + # RF. + + # Start a rowspan if necessary: + + my $rowspan = $Apache::londefdef::table[-1]{'rowspan'}[$in][$jn]; + my $colspan = $Apache::londefdef::table[-1]{'colspan'}[$in][$jn]; # # Do the appropriate magic if this has a colspan # - my $colspan = $Apache::londefdef::table[-1]{'colspan'}[$in][$jn]; + if ($colspan > 1) { $output .= '\multicolumn{'. $colspan .'}{|l|}{'; } - my $rowspan = $Apache::londefdef::table[-1]{'rowspan'}[$in][$jn]; - - # Start a rowspan if necessary: if ($rowspan > 1) { $have_rowspan++; @@ -2246,6 +2254,7 @@ sub end_table { if (($rowspan eq '^') || ($rowspan eq '_')) { $have_rowspan++; } + #-------------------------------------------------------------- if ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'c') { $output.=¢er_correction().'\begin{center}'; @@ -2280,9 +2289,11 @@ sub end_table { $output .= ' \\\\ '; for (my $jn=0; $jn<=$#fwidth;$jn++) { my $rowspan = $Apache::londefdef::table[-1]{'rowspan'}[$in][$jn]; - if (($rowspan <= 1) || ($rowspan eq '_')) { - my $column = $jn+1; - $output .= '\cline{'.$column.'-'.$column.'} '; + if ($rowspan ne "^") { + if (($rowspan <= 1) || ($rowspan eq '_')) { + my $column = $jn+1; + $output .= '\cline{'.$column.'-'.$column.'} '; + } } } @@ -2452,6 +2463,13 @@ sub end_td_tex { $Apache::londefdef::table[-1]{'counter_columns'} = $current_column; + # Get the column and row spans. + # Colspan can be done via \multicolumn if I can figure out the data structs. + + my $colspan = &Apache::lonxml::get_param('colspan', $parstack, $safeeval, undef, 0); + if (!$colspan) { + $colspan = 1; + } my $rowspan = &Apache::lonxml::get_param('rowspan', $parstack, $safeeval, undef, 0); if (!$rowspan) { @@ -2460,11 +2478,13 @@ sub end_td_tex { - $Apache::londefdef::table[-1]{'rowspan'}[$current_row][$current_column] = $rowspan; - for (my $i = 1; $i < $rowspan; $i++) { - $Apache::londefdef::table[-1]{'rowspan'}[$current_row+$i][$current_column] = '^'; - if ($i == ($rowspan-1)) { - $Apache::londefdef::table[-1]{'rowspan'}[$current_row+$i][$current_column] = '_'; + for (my $c = 0; $c < $colspan; $c++) { + $Apache::londefdef::table[-1]{'rowspan'}[$current_row][$current_column+$c] = $rowspan; + for (my $i = 1; $i < $rowspan; $i++) { + $Apache::londefdef::table[-1]{'rowspan'}[$current_row+$i][$current_column+$c] = '^'; + if ($i == ($rowspan-1)) { + $Apache::londefdef::table[-1]{'rowspan'}[$current_row+$i][$current_column+$c] = '_'; + } } } @@ -2559,13 +2579,7 @@ sub end_td_tex { push @ {$Apache::londefdef::table[-1]{'content'}[-1] },$data; - # Get the column and row spans. - # Colspan can be done via \multicolumn if I can figure out the data structs. - my $colspan = &Apache::lonxml::get_param('colspan', $parstack, $safeeval, undef, 0); - if (!$colspan) { - $colspan = 1; - } # the colspan array will indicate how many columns will be spanned by this @@ -2574,14 +2588,16 @@ sub end_td_tex { # counter_columns is incremented in the start_td_tex, we adjust by colspan-1. # - $Apache::londefdef::table[-1]{'colspan'}[$current_row][$current_column] = $colspan; $Apache::londefdef::table[-1]{'counter_columns'} += $colspan -1; - - # Put empty text in spanned cols. - for (my $i = 0; $i < ($colspan -1); $i++) { push @ {$Apache::londefdef::table[-1]{'content'}[-1] },''; } + for (my $r = 0; $r < $rowspan; $r++) { + $Apache::londefdef::table[-1]{'colspan'}[$current_row+$r][$current_column] = $colspan; + # Put empty text in spanned cols. + + } + return '';