# Layouting of sage notebook

Hi, I want to take a printout of the notebook output. But since the eqns sage calculated are too large, it wrote the entire equation in a single line. I am not able to take a printout of my notebook because of this single line output. Is there any way, I can make sage output the results in a specified width. So that I can take printout on normal A4 Size papers? Thanking in advance. -indiajoe

Update:

The notebook I am having trouble is the one in the following published page.

http://480.sagenb.org/home/pub/60/

The notorious long eqn is the one at the end of the first cell. I am not able to make them print in multiple lines.

edit retag close merge delete

Sort by » oldest newest most voted

If you can see a reasonable way to split the equation up, you could have sage store the pieces in separate variables and print them separately . . . but the obvious example I tried

sum(i*x**i for i in range(30))


automatically prints on several different lines anyway.

For your case, if you change the definition of f to

f= A2*Term1 + B2*Term2 == (42/10)**2


and change the last part to

newf=f(k=kvalue)
newg=g(k=kvalue)
opf = newf.lhs().operands()
show(opf)
print("+")
show(opf==newf.rhs())
show(newg)


you'll get something like This could maybe be improved a little, but illustrates two key things:

• use .operands() to split an equation or symbolic expression into pieces which you can print separately

• the additional zeroes are coming from the precision of the real numbers you're working with (53 bits by default, I think). If you use rationals instead, you'll get exact values, or you could use lower-precision real numbers.

more

@niles: Thanks for looking into my layout problem. I have updated the question with the link to the published example. It has the long eqn which is creating problem at the end of the first cell. The eqn is printing lot of unwanted zeros also. I don't know how to remove that too. Thanks again.. If you're willing to accept a change in size and slight difference in appearance, you could try defining

show2 = sage.misc.latex.pretty_print


and then using

show2(newf)


which produces for me.

more