[LON-CAPA-users] Help with formatting
Guy Albertelli II
lon-capa-users@mail.lon-capa.org
Thu, 30 Oct 2003 14:43:28 -0500 (EST)
Hi Felicia,
> > You can use sprintf to properly format things.
>
> What is sprintf?
It is a function that can be used to format the conversion of things
(like numbers or strings) to strings.
It is what is internally used by &format and &prettyprint
> > <table>
> > <tr><td align="right">4</td><td>.</td><td align="left">54</td></tr>
> > ...
> >
> > You can use perl to divide the number up and display it this way.
> >
> > Let me know if you need full working code.
>
> I think this is the solution I need. I would appreciate knowing some of
> the perl to at least divide the number.
The 'spilt' down below divides the number up
<script type="loncapa/perl">
$table='<m>\begin{tabular}{lr @{.} l}';
for ($i=0;$i<4;$i++) {
$plus='';
if ($i==3) { $plus='$+$'; }
$number=&random(.1,1000,.0001);
($int,$decimal)=split(/\./,$number);
$table.=$plus.' & '.$int. ' & '.$decimal.' \\\\ ';
}
$table.='\end{tabular}</m>';
$table=&xmlparse($table);
</script>
<startouttext /><display>$table</display><endouttext />
I should be able to figure out
> the rest on my own. Dividing the number up is necessary especially when
> you don't know where the decimal point will show in your randomly
> generated number.
>
> I was hope TeX would have something easy for this, but I guess most
> people don't write elementary math text in TeX.
>
> Thanks!
> --
> Felicia Berryman
> LON-CAPA Coordinator
> Michigan State University
> Email: felicia@lon-capa.org
> Phone: (517)432-9866
> http://www.lon-capa.org
>
> _______________________________________________
> 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 LON-CAPA Developer 0-7-5-3-