--- loncom/xml/londefdef.pm 2005/12/23 00:12:32 1.305 +++ loncom/xml/londefdef.pm 2005/12/26 19:01:25 1.306 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.305 2005/12/23 00:12:32 foxr Exp $ +# $Id: londefdef.pm,v 1.306 2005/12/26 19:01:25 foxr Exp $ # # # Copyright Michigan State University Board of Trustees @@ -178,6 +178,7 @@ sub start_html { (!$env{'request.role.adv'})) {$currentstring .='\batchmode';} $currentstring .= '\newcommand{\keephidden}[1]{}'. '\renewcommand{\deg}{$^{\circ}$}'. + '\usepackage{multirow}'. '\usepackage{longtable}'. '\usepackage{textcomp}'. '\usepackage{makeidx}'. @@ -2186,6 +2187,7 @@ sub end_table { $header_of_table .= '}'; #fill the table for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) { + my $have_rowspan = 0; for (my $jn=0;$jn<=$#fwidth;$jn++) { # # Do the appropriate magic if this has a colspan @@ -2196,6 +2198,18 @@ sub end_table { $colspan .'}{|l|}{'; } + my $rowspan = $Apache::londefdef::table[-1]{'rowspan'}[$in][$jn]; + + # Start a rowspan if necessary: + + if ($rowspan > 1) { + $have_rowspan++; + $output .= '\multirow{'.$rowspan.'}[0]{'.$fwidth[$jn].'mm}{'; + } + if (($rowspan eq '^') || ($rowspan eq '_')) { + $have_rowspan++; + } + if ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'c') { # $output.='\vspace*{-6 mm}\begin{center}'; $output.='\begin{center}'; @@ -2209,6 +2223,11 @@ sub end_table { } elsif ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'r') { $output.='} '; } + # Close off any open multirow: + + if ($rowspan > 1) { + $output .= '}'; + } # Close off the colspan... # if ($colspan > 1) { @@ -2217,7 +2236,24 @@ sub end_table { } if ($jn!=$#fwidth) {$output.=' '.$Apache::londefdef::table[-1]{'vinc'};} } - $output.=' \\\\ '.$Apache::londefdef::table[-1]{'hinc'}.' '; + # If have_rowspan > 0, and borders are on, then + # we need to do more than put an \hline at the bottom of row. + # we need to do the appropriate \cline to ensure that + # the spanned rows don't have \hlines through them. + + if (($Apache::londefdef::table[-1]{'hinc'} =~ /\\hline/) && $have_rowspan) { + $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.'} '; + } + } + + } else { + $output.=' \\\\ '.$Apache::londefdef::table[-1]{'hinc'}.' '; + } } # Note that \newline destroys alignment env's produced by e.g.
# $Apache::londefdef::table[-1]{'output'} .= $header_of_table.$Apache::londefdef::table[-1]{'hinc'}.$output.'\end{tabular}\strut\newline\strut '; @@ -2368,11 +2404,12 @@ sub end_td_tex { # The rowspan array of the table indicates which cells are part of a span. # n indicates the start of a span set of n rows. # ^ indicates a cell that continues a span set. + # _ indicates the cell is at the bottom of a span set. # If this and subsequent cells are part of a rowspan, we must # push along the row until we find one that is not. while ((defined $Apache::londefdef::table[-1]{'rowspan'}[$current_row] [$current_column]) - && $Apache::londefdef::table[-1]{'rowspan'}[$current_row][$current_column] eq '^') { + && ($Apache::londefdef::table[-1]{'rowspan'}[$current_row][$current_column] =~ /[\^\_]/)) { # Part of a span. push @ {$Apache::londefdef::table[-1]{'content'}[-1]}, ''; $current_column++; @@ -2391,6 +2428,9 @@ 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] = '_'; + } } my $TeXwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);