[IPython-User] Printing a string and latex together in a notebook

Francesco Montesano franz.bergesund@gmail....
Sun Nov 18 15:38:43 CST 2012


Does this help?
http://mail.scipy.org/pipermail/ipython-user/2012-November/011530.html

Cheers,
Francesco


2012/11/18 Aaron Meurer <asmeurer@gmail.com>

> Would it make sense to create (or does one already exist) a Markdown
> object (or Markdown output type) which takes a string input and
> renders it like a Markdown cell would? Then it would just be something
> like Markdown("The answer is %s" % latex(x**2, mode='inline')) (note
> that latex(mode='inline') includes the $ delimiters).
>
> Aaron Meurer
>
> On Nov 18, 2012, at 3:46 AM, Matthias BUSSONNIER
> <bussonniermatthias@gmail.com> wrote:
>
> >
> > Le 18 nov. 2012 à 00:40, Mike Witt a écrit :
> >
> >> In an ipython notebook, I'd like to do something like this:
> >>
> >>  x = Symbol('x')
> >>  print('The answer is: $%s$' %latex(x**2))
> >>
> >> The closest I've figured out how to get is:
> >>
> >>  print('The answer is:')
> >>  display(x**2)
> >>
> >> Or something equivalent to that. I'd like to mix the string
> >> and the math output on the same line, but I can't figure
> >> out the syntax.
> >
> > Hi,
> > In the general case, I don't think it is super simple.
> > You will have to get the function that compute the repr_tex of x**2 and
> use
> >
> > from IPython.display import Latex
> > Latex('your formatted latex string here')
> >
> > In your case, sympy provide an easy way to get latex repr when possible.
> > So in your case this should work (watch out for sympy.latex with
> lowercase L an IPython.Latex  with Upper Case L)
> >
> > from sympy import Symbol, latex
> > from IPython.display import Latex
> > x= Symbol('x')
> > Latex(' I can have inline latex : $%s$'% latex(x**2))
> >
> >> Note that I'm in a code cell, not a markdown cell. I want to
> >> calculate the answer and then print it with informative strings
> >> intermixed with the math. Is this possible?
> >
> > This is not yet alway possible or easy, but we are working on way to
> improve that.
> > --
> > Matthias
> >
> >
> >>
> >> -Mike
> >> _______________________________________________
> >> IPython-User mailing list
> >> IPython-User@scipy.org
> >> http://mail.scipy.org/mailman/listinfo/ipython-user
> >
> > _______________________________________________
> > IPython-User mailing list
> > IPython-User@scipy.org
> > http://mail.scipy.org/mailman/listinfo/ipython-user
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20121118/efe0fc58/attachment.html 


More information about the IPython-User mailing list