Ask Your Question
0

Typesetting text in TeX view()

asked 2012-06-07 06:36:23 -0500

Mathemage gravatar image

updated 2015-01-25 11:01:44 -0500

FrédéricC gravatar image

Is there a standard way to typeset TeX formulas together with normal text via view()?

So far I've been using

tex_string = "\hbox{- stationary points: }"
for pt in stats:
    tex_string += latex(pt)
    tex_string += ", " 
view(tex_string)

where stats is a list of some points (defined with formulas).

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
0

answered 2017-03-09 03:37:53 -0500

It has been quite a while since the question was asked, but I seem to have an answer. The key points are to use unescaped strings (avoid \t in \textbf be misinterpreted for a tab) and LatexExpr(). The following is a MWE in my jupyter notebook:

var('x')
stats=((1,2),(3,4),(x,x^2-1))
tex_string = r"\textbf{stationary points: }"
tex_string += ", ".join(map(latex,stats))
show(LatexExpr(tex_string))
view(LatexExpr(tex_string))

This code both shows a typeset version in the notebook (second last command) and opens up a pdf viewer with typeset latex code (last command).

edit flag offensive delete link more
0

answered 2012-06-08 12:54:35 -0500

Eviatar Bach gravatar image

You can do the following in a notebook cell:

%latex
Stationary points: $\sage{stats}$
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-06-07 06:36:23 -0500

Seen: 214 times

Last updated: Mar 09