pretty print question

75 views
Skip to first unread message

Juan Grados

unread,
Apr 1, 2014, 9:25:30 AM4/1/14
to sage-support
Dears members,

I want make a pretty_print in the follow code but I get false, and I want get the pretty expression of

$$x=\left(\begin{array}{rr}
1 & 2 \\
3 & 4
\end{array}\right)$$

var('x')
>A=matrix([[1,2],[3,4]])
>pretty_print(x==A)

How I will be able to fix that?


--
---------------------------------------------------------------------
MSc. Juan del Carmen Grados Vásquez
Laboratório Nacional de Computação Científica 
Tel: +55 24 2233-6260
(http://www.lncc.br/)
http://juaninf.blogspot.com
---------------------------------------------------------------------

Dominique Laurain

unread,
Apr 1, 2014, 4:57:52 PM4/1/14
to sage-s...@googlegroups.com
x = var('x')

A=matrix([[1,2],[3,4]])
print "$$x=",latex(A),"$$"
pretty_print('x='+latex(A))

Dominique Laurain

unread,
Apr 1, 2014, 4:59:16 PM4/1/14
to sage-s...@googlegroups.com
x = var('x')

A=matrix([[1,2],[3,4]])
print "$$x==",latex(A),"$$"
pretty_print('x=='+latex(A))

Juan Grados

unread,
Apr 1, 2014, 8:07:44 PM4/1/14
to sage-support
thanks but I get

$$x= \left(\begin{array}{rr}

1 & 2 \\
3 & 4
\end{array}\right) $$
\newcommand{\Bold}[1]{\mathbf{#1}}\hbox{x=\left(\begin{array}{rr}
1 & 2 \\
3 & 4
\end{array}\right)}


the latex code and not pretty print


--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

P Purkayastha

unread,
Apr 2, 2014, 8:51:56 AM4/2/14
to sage-s...@googlegroups.com
pretty_print('x = ', matrix([[1,2], [3,4]]))

P Purkayastha

unread,
Apr 2, 2014, 8:53:31 AM4/2/14
to sage-s...@googlegroups.com
If you want x to be typeset normally, then you can do the following:
pretty_print(LatexExpr('x = '), matrix([[1,2], [3,4]]))

Dominique Laurain

unread,
Apr 7, 2014, 3:07:06 AM4/7/14
to sage-s...@googlegroups.com
I don't know so much about cell display in SAGE cloud...but I guess... there are step s:
1. cell content in ASCII raw text is processed by Tex 
2. tex content is then displayed by Mathjax 

I am sure about Mathjax because I can  mouse right button click on the displayed matrix in my browser (currently Chrome) and I get
one menu about Mathjax renderer (can be HTML-CSS, Mathml or SVG ; I cannot use MathMl because my browser has not brwser extension to display mathml ; SVG is my default display)

With the menu "show math as / tex commands" I get :

{x= \left(\begin{array}{rr}
1 & 2 \\
3 & 4
\end{array}\right)}

That means that default commands (set by new command) have been already parsed by Tex before send to Mathjax.

I can advice you to check is your browser can parse Mathjax commands : go to URL www.mathjax.org with your browser, to check if you have nice display
 of math upper right in the windo w. If not, check Javascript is ok.

If ok, then try to use various things in the SAGE cloud : first try to process a TEX file ; second search in one terminal is tex working for your projects; third, use the %latex tag in one cell

P Purkayastha

unread,
Apr 7, 2014, 3:34:40 AM4/7/14
to sage-s...@googlegroups.com, Dominique Laurain
It depends on how Sage presents the latex in the HTML code. Mathjax
does not parse all latex code. It only parses those that are in a
special <span> or <div>.

One way to get Sage to pass on the latex within the specific <span> or
<div> is to make the string a "LatexExpr" string.
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "sage-support" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/sage-support/1vtfecpnDJ0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> sage-support...@googlegroups.com
> <mailto:sage-support...@googlegroups.com>.
> To post to this group, send email to sage-s...@googlegroups.com
> <mailto:sage-s...@googlegroups.com>.

P Purkayastha

unread,
Apr 7, 2014, 3:42:08 AM4/7/14
to sage-s...@googlegroups.com, Dominique Laurain
On Mon 07 Apr 2014 03:34:40 PM SGT, P Purkayastha wrote:
> It depends on how Sage presents the latex in the HTML code. Mathjax
> does not parse all latex code. It only parses those that are in a
> special <span> or <div>.
>
> One way to get Sage to pass on the latex within the specific <span> or
> <div> is to make the string a "LatexExpr" string.


Sorry, I should have checked before mailing. Sage passes on the latex
in a <script> tag. And MathJax generates the required <span> or <div>.
You can look at methods and classes in the file "sage.misc.latex??" to
see what is generated.
Reply all
Reply to author
Forward
0 new messages