Ask Your Question

LatexExpr space problem

asked 2012-09-12 09:58:54 -0500

mhfrey gravatar image

I am trying to format test in a notebook and I am having problems with the text being run together. The sage code is:

Pintegral_int = 2

Pint_txt_int = "This is a test: " +"P_{integral}= "+str(round(Pintegral_int,6)) \ +", 1/P_{integral}= "+str(round(1/Pintegral_int,6)) \ +"at dB= " +str(round(20*log(Pintegral_int, 10),4)) \ +", 90^{\circ} pulse"+"\mu s"

Pint_txt_int; show(LatexExpr(Pint_txt_int))

image description

The "Thisisatest" is missing the spaces between words. I would appreciate any help on how to solve this problem.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-09-12 11:26:09 -0500

benjaminfjones gravatar image

This is not a Sage question, it's a LaTeX question. But anyway, try wrapping "This is a test" in a \text latex macro, i.e.

Pint_txt_int = "\\text{This is a test}: " + ...
edit flag offensive delete link more



In case you want more details: by default, everything in a LatexExpr is typeset in LaTeX's math mode, and that's why the spaces disappear.

John Palmieri gravatar imageJohn Palmieri ( 2012-09-12 16:07:03 -0500 )edit

Yep, that's a good point. I shouldn't leave such terse answers but it's hard not to while waiting at the drug store with only one's phone for company :)

benjaminfjones gravatar imagebenjaminfjones ( 2012-09-13 16:42:46 -0500 )edit

Your Answer

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

Add Answer

Question Tools


Asked: 2012-09-12 09:58:54 -0500

Seen: 156 times

Last updated: Sep 12 '12