--- loncom/xml/londefdef.pm 2006/09/05 21:57:57 1.336
+++ loncom/xml/londefdef.pm 2006/09/25 10:41:15 1.339
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Tags Default Definition Module
#
-# $Id: londefdef.pm,v 1.336 2006/09/05 21:57:57 foxr Exp $
+# $Id: londefdef.pm,v 1.339 2006/09/25 10:41:15 foxr Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -561,8 +561,12 @@ sub end_body {
}
# \begin{center} causes a new paragprah spacing that looks odd inside
-# of a table cell
-sub center_correction { return '\vspace*{-6 mm}'; }
+# of a table cell. Same at the end of a \center but with a slightly
+# larger space .. hence center_correction and center_end_correction.
+#
+sub center_correction { return '\vspace*{-6 mm}'; }
+sub center_end_correction { return '\vspace*{-7 mm}'; }
+
#--
tag (end tag required)
sub start_center {
my ($target,$token,$tagstack) = @_;
@@ -585,6 +589,9 @@ sub end_center {
$currentstring = $token->[2];
} elsif ($target eq 'tex') {
$currentstring = '\end{center}';
+ if (&is_inside_of($tagstack, "table")) {
+ $currentstring .= ¢er_end_correction();
+ }
}
return $currentstring;
}
@@ -1221,6 +1228,8 @@ sub start_br {
$currentstring .= ' \vskip 0 mm ';
} elsif ($$tagstack[-2] ne 'sub' && $$tagstack[-2] ne 'sup') {
$currentstring .= '\strut \\\\ \strut ';
+ } else { # Honor break in simple
+ $currentstring .= '}} \strut \\\\ \strut \ensuremath{^{';
}
}
return $currentstring;
@@ -2206,33 +2215,75 @@ sub end_table {
}
$output .= '\multicolumn{'.
$colspan
- ."}{|p{$spanwidth mm}|}{";
+ ."}";
+ if ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'c') {
+ $output .= '{|c|}{';
+ } elsif ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'r') {
+ $output .= '{|r|}{';
+ }
+ else {
+ $output .= "{|p{$spanwidth mm}|}{";
+ }
+
}
+ # Rowspan... if colspan is 1, and there's an alignment we'll need
+ # to kick in a multicolumn in order to get the alignment spec.
+ # this must precede the multirow or LaTex gets quite upset.
+ # Naturally if colspan > 1 we've already done that above ^
+ #
+ my $multirow_aligned = 0;
if ($rowspan > 1) {
+ if ($colspan == 1) {
+ if ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'c') {
+ $output .= '\multicolumn{1}{|c|}{';
+ $multirow_aligned = 1;
+ } elsif ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'r') {
+ $output .= '\multicolumn{1}{|r|}{';
+ $multirow_aligned = 1;
+ }
+ }
$have_rowspan++;
- $output .= '\multirow{'.$rowspan.'}[0]{'.$fwidth[$jn].'mm}{';
+ $output .= '\multirow{'.$rowspan.'}[0]{*}{';
+ #
+ # If we did not throw in a multicolumn to align, then add
+ # an extra {
+ # so we close correctly without having to keep additional state
+ # around
+ #
+ if (!$multirow_aligned) {
+ $output .= '{';
+ }
}
if (($rowspan eq '^') || ($rowspan eq '_')) {
$have_rowspan++;
}
#--------------------------------------------------------------
- if ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'c') {
- $output.=¢er_correction().'\begin{center}';
- } elsif ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'r') {
- $output.=' \hfill \llap{'
+
+ # For right and center alignment of single cells.
+ # we are going to use a multicolumn with a span of 1 to specify alignment.
+ #
+ if ($colspan == 1 && $rowspan == 1) {
+ if ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'c') {
+ $output .= '\multicolumn{1}{|c|}{';
+ } elsif ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'r') {
+ $output .= '\multicolumn{1}{|r|}{';
+ }
}
+
$output.=$Apache::londefdef::table[-1]{'content'}[$in][$jn];
- if ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'c') {
- $output.='\end{center}';
- } elsif ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'r') {
- $output.='} ';
+
+ if (($colspan == 1 && $rowspan == 1) &&
+ (($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'c') ||
+ ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'r'))) {
+ $output .= '}';
}
+
# Close off any open multirow:
if ($rowspan > 1) {
- $output .= '}';
+ $output .= '}}';
}
# Close off the colspan...
#
@@ -3363,6 +3414,9 @@ sub start_blockquote {
if ($target eq 'web' || $target eq 'webgrade') {
$currentstring .= $token->[4];
}
+ if ($target eq 'tex') {
+ $currentstring .= '\begin{quote}';
+ }
return $currentstring;
}
@@ -3372,6 +3426,9 @@ sub end_blockquote {
if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[2];
}
+ if ($target eq 'tex') {
+ $currentstring = '\end{quote}';
+ }
return $currentstring;
}