On Wed, Jul 8, 2009 at 11:35 AM, John H Palmieri<jhpalmier...@gmail.com> wrote:
>
> There is some ugly LaTeX'ing going on in Sage:
>
> In the notebook, try
> {{{
> %latex
> $\sage{type(35))$
> }}}
> In this case, it uses the string "<type 'sage.rings.integer.Integer'>"
> as text, but the < and > signs get converted into an upside-down
> exclamation point and question mark.

Before reading further, when I see

 $\sage{type(35))$

I immediately think *syntax error*, since you have an opening { but no
closing "}".

 -- William

>
> Or click the "Typeset" button and try
> {{{
> type(35)
> }}}
> In this case, jsMath kicks in and tries to typeset "\text{<type
> 'sage.rings.integer.Integer'>}", but the symbols < and > confuse
> jsMath -- it thinks they're part of an html command.  As a result,
> there is *no* output at all.
>
> One more example, from a Sage doctest:
> {{{
> sage: R.<x,y>=QQbar[]
> sage: latex(-x^2-y+1)
> -x^{2} - y + \text{1}
> }}}
> What is that \text{1} doing there?
>
> Here are my suggested solutions:
>
> for problem 2, jsMath: use \hbox instead of \text.  This seems to
> work: {{{type(35)}}} prints out the correct string with the Typeset
> button checked.
>
> for problem 1, latex'ing type(...): use \texttt (typewriter font).
> More precisely, when Sage can't figure out how to LaTeX something, it
> converts it to a string and then encloses it in a \text{} command, and
> I'm suggesting that we use \texttt{} instead.  This is sort of like
> verbatim output; in any case, it prints < and > correctly.  It does
> look different from \text, though.  One example in the Sage code looks
> like this:
>
> sage: latex(CuspForms(3, 24).hecke_algebra()) # indirect doctest
>       \mathbf{T}_{\text{Cuspidal subspace of dimension 7 of Modular
> Forms space of dimension 9 for Congruence Subgroup Gamma0(3) of weight
> 24 over Rational Field}}
>
> With my proposed change, the subscript would appear in typewriter font
> instead of plain text.  I think the way to fix this is to modify the
> _latex_ method for Hecke algebras.  (I don't think it's going to look
> very good with either \text or \texttt, in this example.)
>
> for problem 3, -x^{2} - y + \text{1}: The issue is the same as problem
> 2: somehow, the element 1 has no _latex_ method, so Sage converts it
> to a string and then encloses it in \text{}.  I suggest this: if the
> object has no conversion to latex, then as before, convert it to a
> string.  If the string contains only digits and/or letters, then just
> use that string (so 'x' prints as an ordinary math-mode italic 'x',
> not as an upright \text{x}, and '1' appears as '1': the above
> situation would produce '-x^{2} - y + 1').  If the string contains
> anything else -- "<", spaces, whatever -- then it gets printed using
> \texttt{}, as explained above.
>
> Comments?
>
>  John
>
> >
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to