On Jul 20, 3:30 pm, VictorMiller <[email protected]> wrote:
> I have a program which calculates a table of values, and I'd like to
> display it nicely formatted. I've written a function to produce latex
> for it (using tabular), but I can't figure out how to get SAGE to
> display this in a notebook. I've tried the html command but that
> doesn't work. Here's a small example. I can put the following in a
> cell:
>
> %latex
> \begin{tabular}{c|c} \hline A & B \\ \hline \hline 1 & 2 \\ \hline \end
> {tabular}
Okay, so have your program produce the table as output ("\begin
{tabular}{c|c} \hline A & B ..."), and then do
%latex
\sage{my_program(args...)}
Is that what you want?
> and it renders as I expect. however, if I put the above latex in a
> string and try html or view it just spits out the latex (minus the
> first two characters!).
Try
a = r"\begin{tabular}..."
to store the latex code in a string.
> And incidentally, I can't figure out the following part of the latex
> documenation since something seems to be missing. Exactly what does
> the Latex function do?
sage: from sage.misc.latex import Latex
sage: L = Latex()
At this point, "calling" L will try to convert its argument to a
string suitable for printing in latex:
sage: L(3+5)
8
sage: L(range(3))
\left[0, 1, 2\right]
sage: L("hello")
\text{hello}
Also, "L.eval(string, globals=globals())" will run Latex on string,
creating a png file with the output; it will use the parameters used
in initializing L -- in my situation, I didn't use any, but I could
have done
sage: L = Latex(debug=True, pdflatex=True)
for example. Finally, note that "latex" is defined to be "Latex
()" (or "Latex(density=130)" in the notebook), so I could have just
used "latex(3+5)", "latex(range(3))", etc., in my examples.
John
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---