ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 21 Mar 2011 15:49:06 -0500Print to pdf, Bad quality in evaluated latexhttps://ask.sagemath.org/question/8014/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.
Fri, 18 Mar 2011 21:58:40 -0500https://ask.sagemath.org/question/8014/print-to-pdf-bad-quality-in-evaluated-latex/Answer by kcrisman for <p>Hi</p>
<p>In the sage notebook there is a problem when wanting to print to pdf or printer.
I have "typeset" enabled.
An example:
1st cell:</p>
<pre><code>%latex
Something is wrong
</code></pre>
<p>2nd cell:</p>
<pre><code>2/3
</code></pre>
<p>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.</p>
<p>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.</p>
<p>Any help appreciated.</p>
https://ask.sagemath.org/question/8014/print-to-pdf-bad-quality-in-evaluated-latex/?answer=12213#post-id-12213I'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!Mon, 21 Mar 2011 14:22:30 -0500https://ask.sagemath.org/question/8014/print-to-pdf-bad-quality-in-evaluated-latex/?answer=12213#post-id-12213Comment by Kabi for <p>I'm putting this in a different answer spot because I think you have a different question than I first thought.</p>
<p>What is your use case? Here are two ways to get nice-looking TeX-ish code in the notebook.</p>
<ol>
<li>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 <code>$xyz$</code> or <code>$$xyz$$</code> will end up looking like $xyz$ or $$xyz\; .$$ This is how I usually get nicely TeXed stuff.</li>
<li>Use the <code>html()</code> command. You can often get good stuff from that - such as <code>html("I like the number $%s$"%5)</code> 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.</li>
</ol>
<p>I do not know why the <code>%latex</code> 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 <code>%latex</code>, given the two options above - but if you do, please reply!</p>
https://ask.sagemath.org/question/8014/print-to-pdf-bad-quality-in-evaluated-latex/?comment=21954#post-id-21954Thank you!!Mon, 21 Mar 2011 15:49:06 -0500https://ask.sagemath.org/question/8014/print-to-pdf-bad-quality-in-evaluated-latex/?comment=21954#post-id-21954Comment by Kabi for <p>I'm putting this in a different answer spot because I think you have a different question than I first thought.</p>
<p>What is your use case? Here are two ways to get nice-looking TeX-ish code in the notebook.</p>
<ol>
<li>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 <code>$xyz$</code> or <code>$$xyz$$</code> will end up looking like $xyz$ or $$xyz\; .$$ This is how I usually get nicely TeXed stuff.</li>
<li>Use the <code>html()</code> command. You can often get good stuff from that - such as <code>html("I like the number $%s$"%5)</code> 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.</li>
</ol>
<p>I do not know why the <code>%latex</code> 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 <code>%latex</code>, given the two options above - but if you do, please reply!</p>
https://ask.sagemath.org/question/8014/print-to-pdf-bad-quality-in-evaluated-latex/?comment=21955#post-id-21955Thank you!! This is great and exactly what I was looking for. Didn't know about the text cell..Mon, 21 Mar 2011 15:49:04 -0500https://ask.sagemath.org/question/8014/print-to-pdf-bad-quality-in-evaluated-latex/?comment=21955#post-id-21955Answer by Kabi for <p>Hi</p>
<p>In the sage notebook there is a problem when wanting to print to pdf or printer.
I have "typeset" enabled.
An example:
1st cell:</p>
<pre><code>%latex
Something is wrong
</code></pre>
<p>2nd cell:</p>
<pre><code>2/3
</code></pre>
<p>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.</p>
<p>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.</p>
<p>Any help appreciated.</p>
https://ask.sagemath.org/question/8014/print-to-pdf-bad-quality-in-evaluated-latex/?answer=12211#post-id-12211Hi
Thanks for the reply.
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.
Mon, 21 Mar 2011 09:32:58 -0500https://ask.sagemath.org/question/8014/print-to-pdf-bad-quality-in-evaluated-latex/?answer=12211#post-id-12211Comment by Kabi for <p>Hi</p>
<p>Thanks for the reply.</p>
<p>I just tried your suggestion using sws2tex, and it has the exact same problem as I described in the notebook.</p>
<p>The evaluated LaTeX code is a blurry image. The example code example from my first post is enough to show the problem.</p>
<p>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.</p>
https://ask.sagemath.org/question/8014/print-to-pdf-bad-quality-in-evaluated-latex/?comment=21956#post-id-21956I 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 readableMon, 21 Mar 2011 11:14:31 -0500https://ask.sagemath.org/question/8014/print-to-pdf-bad-quality-in-evaluated-latex/?comment=21956#post-id-21956Answer by Kabi for <p>Hi</p>
<p>In the sage notebook there is a problem when wanting to print to pdf or printer.
I have "typeset" enabled.
An example:
1st cell:</p>
<pre><code>%latex
Something is wrong
</code></pre>
<p>2nd cell:</p>
<pre><code>2/3
</code></pre>
<p>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.</p>
<p>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.</p>
<p>Any help appreciated.</p>
https://ask.sagemath.org/question/8014/print-to-pdf-bad-quality-in-evaluated-latex/?answer=12214#post-id-12214Thank you!!
This is great, and exactly what I was looking for.
I didn't know about the text cell before.Mon, 21 Mar 2011 15:44:13 -0500https://ask.sagemath.org/question/8014/print-to-pdf-bad-quality-in-evaluated-latex/?answer=12214#post-id-12214Answer by kcrisman for <p>Hi</p>
<p>In the sage notebook there is a problem when wanting to print to pdf or printer.
I have "typeset" enabled.
An example:
1st cell:</p>
<pre><code>%latex
Something is wrong
</code></pre>
<p>2nd cell:</p>
<pre><code>2/3
</code></pre>
<p>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.</p>
<p>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.</p>
<p>Any help appreciated.</p>
https://ask.sagemath.org/question/8014/print-to-pdf-bad-quality-in-evaluated-latex/?answer=12208#post-id-12208This is somewhat of a workaround, since it's not part of Sage proper, but you may enjoy trying to use [sws2tex](https://bitbucket.org/whuss/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.Sat, 19 Mar 2011 14:34:27 -0500https://ask.sagemath.org/question/8014/print-to-pdf-bad-quality-in-evaluated-latex/?answer=12208#post-id-12208