[LON-CAPA-users] math formatting

Guy Albertelli II lon-capa-users@mail.lon-capa.org
Fri, 4 May 2007 14:52:47 -0400 (EDT)


Hi Todd, Jay,


> Try <m eval="on">\[1/ $a\]</m>.  The eval="on" tells the system to
> escape the $a.

Just a more detailed explanation:

the eval ="on" tells the system to evaluate the expression for any
enclosed perl.

We don't do it by default because $ is a special charcter in both
LaTeX and perl. In LaTeX it means 'toggle math mode'.

So <m> $a$b </m> could mean either

display 'a' in 'math mode' and 'b' in not math mode

or display the contents of the varialbe $a and the contents of the
variable $b.

By default we assume the LaTeX interpretation, by setting eval="on" we
do a perl evaluation pass and the send the result on to LaTeX for
display.

> Depending on your situation, you may also want to
> experiment with the &format command:
> 
> <m eval="on">\[1/ &format($a,'2e') \]</m>
> <m eval="on">\[1/ &format($a,'3f') \]</m>
> 
> Todd
> 
> James Sullivan wrote:
> > I'm having some trouble with formatting of math equations, specifically fractions. The following is a code snippet that demonstrates the issue. 
> > 
> > [code snippet follows]
> > <!-- pt type="loncapa/perl">
> > $a = &random(1,5,1);
> > </scr -->
> > <m>\[1/3\]</m>
> > <m>\[1/$a\]</m>
> > 
> > The fraction 1/3 is displayed as I would expect. On the other hand the fraction with the variable denominator bombs out in latex with an error message like:
> > 
> > -------------------------------
> > WARNING:
> > **** Error: Fatal Abnormal eqdepth 2 on display equation exit, line 0
> > occured while attempting to convert this TeX:
> > \[1/$a\]
> > -------------------------------
> > 
> > I assume I need to somehow escape the $a to pass the value of the perl variable. Can anyone provide some guidance on this.
> > 
> > Thanks a bunch,
> > Jay
> > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > LON-CAPA-users mailing list
> > LON-CAPA-users@mail.lon-capa.org
> > http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
> 
> -- 
> Dr. Todd Ruskell
> Senior Lecturer, Department of Physics       Office:  Meyer Hall 326
> Colorado School of Mines                     Phone: 303-384-2080
> 1523 Illinois Street                         Fax: 303-273-3919
> Golden, CO 80401
> _______________________________________________
> LON-CAPA-users mailing list
> LON-CAPA-users@mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
> 

-- 
guy@albertelli.com   0-7-0-9-27,137