# Print to pdf, Bad quality in evaluated latex

Hi

In the sage notebook there is a problem when wanting to print to pdf or printer. I have "typeset" enabled. An example: 1st cell:

%latex
Something is wrong


2nd cell:

2/3


The first cell produces blurry output and the second cell produces much better output. I have read that when using the latex interpreter then sage prints to pdf/dvi (depending on using latex/pdflatex) converts to png and crops the png. And the output of the first cell is obviously an image of poor quality.

What I would like to be able to do, is to write latex code such as sections and formatting, and then print or email the resulting notebook in a normal readable quality.

Any help appreciated.

edit retag close merge delete

Sort by » oldest newest most voted

I'm putting this in a different answer spot because I think you have a different question than I first thought.

What is your use case? Here are two ways to get nice-looking TeX-ish code in the notebook.

1. Use a text cell! Move your cursor until you see a thin blue line between two regular math cells, and then press Shift at the same time as you click. Now you get a nice WYSIWYG editor, with the advantage that most things you put between $xyz$ or $$xyz$$ will end up looking like $xyz$ or $$xyz\; .$$ This is how I usually get nicely TeXed stuff.
2. Use the html() command. You can often get good stuff from that - such as html("I like the number $%s$"%5) becomes "I like the number $5$." This requires a little use of string formatting if you want to have a variable input, but otherwise should behave normally with respect to LaTeX. I use this in interactive cells a lot.

I do not know why the %latex gives such unsatisfactory results, but my guess is that it's using some inferior font in the browser, as opposed to the jsmath fonts, which the two solutions above will use. I really don't know why sws2tex would have problems with this, but remember that sws2tex isn't necessarily about converting percent directives, but just normal Sage input. In any case, I don't think you need %latex, given the two options above - but if you do, please reply!

more

Thank you!! This is great and exactly what I was looking for. Didn't know about the text cell..

( 2011-03-21 15:49:04 -0600 )edit

Thank you!!

( 2011-03-21 15:49:06 -0600 )edit

This is somewhat of a workaround, since it's not part of Sage proper, but you may enjoy trying to use sws2tex which creates a nice pdf for you. It can't handle 100% of worksheets, but it's handled most of mine I've used very nicely.

more

Hi

I just tried your suggestion using sws2tex, and it has the exact same problem as I described in the notebook.

The evaluated LaTeX code is a blurry image. The example code example from my first post is enough to show the problem.

This problem is to bad, and I hope there is some way to get around it. Sage is very good for doing day 2 day work, but it's not so usefull when it's not possible to print a notebook containing evaluated LaTeX code. The only workaround I have is to not write evaluated LaTeX code in the notebook, but just plain text, and sage code.

more

I am wondering if there is a way to make sage use a better resolution for the image. This would be a workaround, just have the text more readable

( 2011-03-21 11:14:31 -0600 )edit