[LON-CAPA-cvs] cvs: loncom /xml londefdef.pm
sakharuk
lon-capa-cvs@mail.lon-capa.org
Tue, 21 Oct 2003 13:36:32 -0000
sakharuk Tue Oct 21 09:36:32 2003 EDT
Modified files:
/loncom/xml londefdef.pm
Log:
Added sub to calculate width of table cell more accurately.
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.183 loncom/xml/londefdef.pm:1.184
--- loncom/xml/londefdef.pm:1.183 Mon Oct 20 15:47:23 2003
+++ loncom/xml/londefdef.pm Tue Oct 21 09:36:32 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Tags Default Definition Module
#
-# $Id: londefdef.pm,v 1.183 2003/10/20 19:47:23 sakharuk Exp $
+# $Id: londefdef.pm,v 1.184 2003/10/21 13:36:32 sakharuk Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -1994,18 +1994,11 @@
$newdata=~s/\\vskip \d*\.?\d*\s*mm/THISISJUSTTEMPORARYSEPARATOR/g;
my @newdata=split(/THISISJUSTTEMPORARYSEPARATOR/,$newdata);
foreach my $elementdata (@newdata) {
- $elementdata=~s/^\s+(\S.*)/$1/;
- $elementdata=~s/(.*\S)\s+$/$1/;
- $elementdata=~s/(\s)+/$1/;
-
- my $lengthnewdata=1.8*length($elementdata);
+ my $lengthnewdata=1.8*LATEX_length($elementdata);
if ($lengthnewdata>$current_length) {$current_length=$lengthnewdata;}
}
} else {
- my $working_data=$data;
- $working_data=~s/(\$\_\{|\$\_|\$\^{|\$\^|\}\$|\$)//g;
- $working_data=~s/\\cdot/ /;
- $current_length=1.8*length($working_data);
+ $current_length=1.8*LATEX_length($data);
}
$Apache::londefdef::table[-1]{'length'} .= $current_length.',';
$Apache::londefdef::table[-1]{'TeXlength'} .= '0,';
@@ -3334,6 +3327,27 @@
}
return $value.' mm';
}
+
+sub LATEX_length {
+ my $garbage=shift;
+ $garbage=~s/^\s+(\S.*)/$1/;
+ $garbage=~s/(.*\S)\s+$/$1/;
+ $garbage=~s/(\s)+/$1/;
+ $garbage=~s/(\\begin{([^\}]+)}|\\end{([^\}]+)})//g;
+ $garbage=~s/(\$\_\{|\$\_|\$\^{|\$\^|\}\$|\$)//g;
+ $garbage=~s/(\\alpha|\\beta|\\gamma|\\delta|\\epsilon|\\verepsilon|\\zeta|\\eta|\\theta|\\vartheta|\\iota|\\kappa|\\lambda|\\mu|\\nu|\\xi|\\pi|\\varpi|\\rho|\\varrho|\\sigma|\\varsigma|\\tau|\\upsilon|\\phi|\\varphi|\\chi|\\psi|\\omega|\\Gamma|\\Delta|\\Theta|\\Lambda|\\Xi|\\Pi|\\Sigma|\\Upsilon|\\Phi|\\Psi|\\Omega)/1/g;
+ $garbage=~s/(\\pm|\\mp|\\times|\\div|\\cdot|\\ast|\\star|\\dagger|\\ddagger|\\amalg|\\cap|\\cup|\\uplus|\\sqcap|\\sqcup|\\vee|\\wedge|\\oplus|\\ominus|\\otimes|\\circ|\\bullet|\\diamond|\\lhd|\\rhd|\\unlhd|\\unrhd|\\oslash|\\odot|\\bigcirc|\\Box|\\Diamond|\\bigtriangleup|\\bigtriangledown|\\triangleleft|\\triangleright|\\setminus|\\wr)/1/g;
+ $garbage=~s/(\\le|\\ll|\\leq|\\ge|\\geq|\\gg|\\neq|\\doreq|\\sim|\\simeq|\\subset|\\subseteq|\\sqsubset|\\sqsubseteq|\\in|\\vdash|\\models|\\supset|\\supseteq|\\sqsupset|\\sqsupseteq|\\ni|\\dash|\\perp|\\approx|\\cong|\\equiv|\\propto|\\prec|\\preceq|\\parallel|\\asymp|\\smile|\\frown|\\bowtie|\\succ|\\succeq|\\mid)/1/g;
+ $garbage=~s/(\\not<|\\\\not\\le|\\not\\prec|\\not\\preceq|\\not\\subset|\\not\\subseteq|\\not\\sqsubseteq|\\not\\in|\\not>|\\not\\ge|\\not\\succ|\\notsucceq|\\not\\supset|\\notsupseteq|\\not\\sqsupseteq|\\notin|\\not=|\\not\\equiv|\\not\\sim|\\not\\simeq|\\not\\approx|\\not\\cong|\\not\\asymp)/1/g;
+ $garbage=~s/(\\leftarrow|\\gets|\\Leftarrow|\\rightarrow|\\to|\\Rightarrow|\\leftrightarrow|\\Leftrightarrow|\\mapsto|\\hookleftarrow|\\leftharpoonup|\\leftkarpoondown|\\rightleftharpoons|\\longleftarrow|\\Longleftarrow|\\longrightarrow|\\Longrightarrow|\\longleftrightarrow|\\Longleftrightarrow|\\longmapsto|\\hookrightarrow|\\rightharpoonup|\\rightharpoondown|\\uparrow|\\Uparrow|\\downarrow|\\Downarrow|\\updownarrow|\\Updownarrow|\\nearrow|\\searrow|\\swarrow|\\nwarrow)/1/g;
+ $garbage=~s/(\\aleph|\\hbar|\\imath|\\jmath|\\ell|\\wp|\\Re|\\Im|\\mho|\\prime|\\emptyset|\\nabla|\\surd|\\partial|\\top|\\bot|\\vdash|\\dashv|\\forall|\\exists|\\neg|\\flat|\\natural|\\sharp|\\\||\\angle|\\backslash|\\Box|\\Diamond|\\triangle|\\clubsuit|\\diamondsuit|\\heartsuit|\\spadesuit|\\Join|\\infty)/ /g;
+ $garbage=~s/(\\hat{([^}]+)}|\\check{([^}]+)}|\\dot{([^}]+)}|\\breve{([^}]+)}|\\acute{([^}]+)}|\\ddot{([^}]+)}|\\grave{([^}]+)}|\\tilde{([^}]+)}|\\mathring{([^}]+)}|\\bar{([^}]+)}|\\vec{([^}]+)})/$1/g;
+ my $value=length($garbage);
+ return $value;
+}
+
+
+
1;
__END__