Does this help?<div><a href="http://mail.scipy.org/pipermail/ipython-user/2012-November/011530.html">http://mail.scipy.org/pipermail/ipython-user/2012-November/011530.html</a><br></div><div><br></div><div>Cheers,</div><div>
Francesco</div><div class="gmail_extra"><br><br><div class="gmail_quote">2012/11/18 Aaron Meurer <span dir="ltr"><<a href="mailto:asmeurer@gmail.com" target="_blank">asmeurer@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Would it make sense to create (or does one already exist) a Markdown<br>
object (or Markdown output type) which takes a string input and<br>
renders it like a Markdown cell would? Then it would just be something<br>
like Markdown("The answer is %s" % latex(x**2, mode='inline')) (note<br>
that latex(mode='inline') includes the $ delimiters).<br>
<br>
Aaron Meurer<br>
<br>
On Nov 18, 2012, at 3:46 AM, Matthias BUSSONNIER<br>
<div class="HOEnZb"><div class="h5"><<a href="mailto:bussonniermatthias@gmail.com">bussonniermatthias@gmail.com</a>> wrote:<br>
<br>
><br>
> Le 18 nov. 2012 à 00:40, Mike Witt a écrit :<br>
><br>
>> In an ipython notebook, I'd like to do something like this:<br>
>><br>
>> x = Symbol('x')<br>
>> print('The answer is: $%s$' %latex(x**2))<br>
>><br>
>> The closest I've figured out how to get is:<br>
>><br>
>> print('The answer is:')<br>
>> display(x**2)<br>
>><br>
>> Or something equivalent to that. I'd like to mix the string<br>
>> and the math output on the same line, but I can't figure<br>
>> out the syntax.<br>
><br>
> Hi,<br>
> In the general case, I don't think it is super simple.<br>
> You will have to get the function that compute the repr_tex of x**2 and use<br>
><br>
> from IPython.display import Latex<br>
> Latex('your formatted latex string here')<br>
><br>
> In your case, sympy provide an easy way to get latex repr when possible.<br>
> So in your case this should work (watch out for sympy.latex with lowercase L an IPython.Latex with Upper Case L)<br>
><br>
> from sympy import Symbol, latex<br>
> from IPython.display import Latex<br>
> x= Symbol('x')<br>
> Latex(' I can have inline latex : $%s$'% latex(x**2))<br>
><br>
>> Note that I'm in a code cell, not a markdown cell. I want to<br>
>> calculate the answer and then print it with informative strings<br>
>> intermixed with the math. Is this possible?<br>
><br>
> This is not yet alway possible or easy, but we are working on way to improve that.<br>
> --<br>
> Matthias<br>
><br>
><br>
>><br>
>> -Mike<br>
>> _______________________________________________<br>
>> IPython-User mailing list<br>
>> <a href="mailto:IPython-User@scipy.org">IPython-User@scipy.org</a><br>
>> <a href="http://mail.scipy.org/mailman/listinfo/ipython-user" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-user</a><br>
><br>
> _______________________________________________<br>
> IPython-User mailing list<br>
> <a href="mailto:IPython-User@scipy.org">IPython-User@scipy.org</a><br>
> <a href="http://mail.scipy.org/mailman/listinfo/ipython-user" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-user</a><br>
_______________________________________________<br>
IPython-User mailing list<br>
<a href="mailto:IPython-User@scipy.org">IPython-User@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-user" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-user</a><br>
</div></div></blockquote></div><br></div>