From: dpvc v. a. <we...@ma...> - 2008-11-14 04:15:51
|
Log Message: ----------- Updated ans_array and TeX methods so that Matrix arrays don't have an extra blank line at the bottom. (There was an extra \cr that shouldn't have been there.) Modified Files: -------------- pg/lib/Value: AnswerChecker.pm Matrix.pm Revision Data ------------- Index: AnswerChecker.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/AnswerChecker.pm,v retrieving revision 1.122 retrieving revision 1.123 diff -Llib/Value/AnswerChecker.pm -Llib/Value/AnswerChecker.pm -u -r1.122 -r1.123 --- lib/Value/AnswerChecker.pm +++ lib/Value/AnswerChecker.pm @@ -415,12 +415,13 @@ $self->{format_options} = [%options] unless $self->{format_options}; my ($open,$close,$sep) = ($options{open},$options{close},$options{sep}); my ($rows,$cols) = (scalar(@{$array}),scalar(@{$array->[0]})); - my $tex = ""; + my $tex = ""; my @rows = (); $open = '\\'.$open if $open =~ m/[{}]/; $close = '\\'.$close if $close =~ m/[{}]/; $tex .= '\(\left'.$open; $tex .= '\setlength{\arraycolsep}{2pt}', $sep = '\,'.$sep if $sep; $tex .= '\begin{array}{'.('c'x$cols).'}'; - foreach my $i (0..$rows-1) {$tex .= join($sep.'&',@{$array->[$i]}).'\cr'."\n"} + foreach my $i (0..$rows-1) {push(@rows,join($sep.'&',@{$array->[$i]}))} + $tex .= join('\cr'."\n",@rows); $tex .= '\end{array}\right'.$close.'\)'; return $tex; } Index: Matrix.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Matrix.pm,v retrieving revision 1.36 retrieving revision 1.37 diff -Llib/Value/Matrix.pm -Llib/Value/Matrix.pm -u -r1.36 -r1.37 --- lib/Value/Matrix.pm +++ lib/Value/Matrix.pm @@ -396,6 +396,7 @@ $d = scalar(@entries); @entries = (); } } + $TeX =~ s/\\cr\n$/\n/; return '\left'.$open.'\begin{array}{'.('c'x$d).'}'."\n".$TeX.'\end{array}\right'.$close; } |