ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 24 Jul 2018 11:52:53 -0500File -> Download as LaTeXhttp://ask.sagemath.org/question/43051/file-download-as-latex/I'm using SageMath 8.2 on a Windows 10 Native with Jupyter Notebook.
The output file obtained by File -> Download as Latex is appalling!
All the output and input cells are placed in verbatim Latex constructs which prevents the usage of all the facilities provided by Latex. I understand why the input cells are in verbatim Latex constructs, after all you want to see exactly what the user wrote, but output cell should not be in verbatim Latex constructs.
The Greek characters are not used at all, even when variables have been defined including their Greek character.
All kind of arrows are printed |--> instead of taking advantage of the many arrows in Latex.
Long lines are just cut when the border is reached.
Exponentials are not shown properly, they appear with the ^ symbol.
The * character (multiplication) should not appear in results.
Daniel
Tue, 17 Jul 2018 13:37:48 -0500http://ask.sagemath.org/question/43051/file-download-as-latex/Comment by slelievre for <p>I'm using SageMath 8.2 on a Windows 10 Native with Jupyter Notebook.</p>
<p>The output file obtained by File -> Download as Latex is appalling!</p>
<p>All the output and input cells are placed in verbatim Latex constructs which prevents the usage of all the facilities provided by Latex. I understand why the input cells are in verbatim Latex constructs, after all you want to see exactly what the user wrote, but output cell should not be in verbatim Latex constructs.</p>
<p>The Greek characters are not used at all, even when variables have been defined including their Greek character.</p>
<p>All kind of arrows are printed |--> instead of taking advantage of the many arrows in Latex.</p>
<p>Long lines are just cut when the border is reached.</p>
<p>Exponentials are not shown properly, they appear with the ^ symbol.</p>
<p>The * character (multiplication) should not appear in results.</p>
<p>Daniel</p>
http://ask.sagemath.org/question/43051/file-download-as-latex/?comment=43066#post-id-43066Please provide a link to a Jupyter Notebook worksheet and the resulting .tex file.
For example, you could do that using the "share" functionality in [CoCalc](https://cocalc.com).Wed, 18 Jul 2018 06:41:51 -0500http://ask.sagemath.org/question/43051/file-download-as-latex/?comment=43066#post-id-43066Comment by Emmanuel Charpentier for <p>I'm using SageMath 8.2 on a Windows 10 Native with Jupyter Notebook.</p>
<p>The output file obtained by File -> Download as Latex is appalling!</p>
<p>All the output and input cells are placed in verbatim Latex constructs which prevents the usage of all the facilities provided by Latex. I understand why the input cells are in verbatim Latex constructs, after all you want to see exactly what the user wrote, but output cell should not be in verbatim Latex constructs.</p>
<p>The Greek characters are not used at all, even when variables have been defined including their Greek character.</p>
<p>All kind of arrows are printed |--> instead of taking advantage of the many arrows in Latex.</p>
<p>Long lines are just cut when the border is reached.</p>
<p>Exponentials are not shown properly, they appear with the ^ symbol.</p>
<p>The * character (multiplication) should not appear in results.</p>
<p>Daniel</p>
http://ask.sagemath.org/question/43051/file-download-as-latex/?comment=43055#post-id-43055**Edit :** comment promoted to answer, see below...Wed, 18 Jul 2018 00:51:39 -0500http://ask.sagemath.org/question/43051/file-download-as-latex/?comment=43055#post-id-43055Answer by Iguananaut for <p>I'm using SageMath 8.2 on a Windows 10 Native with Jupyter Notebook.</p>
<p>The output file obtained by File -> Download as Latex is appalling!</p>
<p>All the output and input cells are placed in verbatim Latex constructs which prevents the usage of all the facilities provided by Latex. I understand why the input cells are in verbatim Latex constructs, after all you want to see exactly what the user wrote, but output cell should not be in verbatim Latex constructs.</p>
<p>The Greek characters are not used at all, even when variables have been defined including their Greek character.</p>
<p>All kind of arrows are printed |--> instead of taking advantage of the many arrows in Latex.</p>
<p>Long lines are just cut when the border is reached.</p>
<p>Exponentials are not shown properly, they appear with the ^ symbol.</p>
<p>The * character (multiplication) should not appear in results.</p>
<p>Daniel</p>
http://ask.sagemath.org/question/43051/file-download-as-latex/?answer=43071#post-id-43071I agree with Emmanuel that this is not a question, though it is a valid issue. I would be helpful to at least see an example notebook.
That said I think I see what you're saying. Even if the notebook has `%display latex` set, when exporting the notebook to tex it wraps all code output blocks in verbatim, and containing the plain-text output rather than the latex output. If you put latex in a *markdown* cell it does get converted properly but only if you have *pandoc* installed. And it seems Sage does not include pandoc by default (perhaps it should, assuming there's no license conflict, etc.)
I confirmed that this isn't just an issue with Sage. You can also test this easily in a plain Python notebook, e.g. by defining a class with a `_repr_latex_` method (see https://ipython.readthedocs.io/en/stable/config/integrating.html)
class Latex(object):
def __init__(self, latex):
self.latex = latex
def _repr_latex_(self):
return self.latex
pi = Latex(r'$$ \pi $$')
pi
When I run this, it sees the `_repr_latex_` and indeed renders the output cell as latex. However, when I run "Download as PDF" it just shows the default plain-text in a verbatim block, as you pointed out. I don't like that either, and it's either a bug, or there should at least be an option to control that.
The "Download as Latex" feature in the Jupyter is, well, a Jupyter-specific feature. It doesn't know anything about Sage, and I'm not sure if the necessary APIs exist in Jupyter to ensure that a code block containing latex-formatted output actually renders the latex when converting to a tex file. This would be an issue for https://github.com/jupyter/nbconvert A quick search of the open issues didn't reveal anything obviously related to me though.
As we move towards emphasizing Jupyter more, we should definitely improve the latex handling story there. Latex is very important for Sage, and in general handled better overall by the classic sage notebook (which you can still try using if it does improve certain tasks for you). This might be an issue to add to https://trac.sagemath.org/ticket/25837Wed, 18 Jul 2018 07:47:48 -0500http://ask.sagemath.org/question/43051/file-download-as-latex/?answer=43071#post-id-43071Comment by eric_g for <p>I agree with Emmanuel that this is not a question, though it is a valid issue. I would be helpful to at least see an example notebook.</p>
<p>That said I think I see what you're saying. Even if the notebook has <code>%display latex</code> set, when exporting the notebook to tex it wraps all code output blocks in verbatim, and containing the plain-text output rather than the latex output. If you put latex in a <em>markdown</em> cell it does get converted properly but only if you have <em>pandoc</em> installed. And it seems Sage does not include pandoc by default (perhaps it should, assuming there's no license conflict, etc.)</p>
<p>I confirmed that this isn't just an issue with Sage. You can also test this easily in a plain Python notebook, e.g. by defining a class with a <code>_repr_latex_</code>method (see <a href="https://ipython.readthedocs.io/en/stable/config/integrating.html">https://ipython.readthedocs.io/en/sta...</a>)</p>
<pre><code>class Latex(object):
def __init__(self, latex):
self.latex = latex
def _repr_latex_(self):
return self.latex
pi = Latex(r'$$ \pi $$')
pi
</code></pre>
<p>When I run this, it sees the <code>_repr_latex_</code> and indeed renders the output cell as latex. However, when I run "Download as PDF" it just shows the default plain-text in a verbatim block, as you pointed out. I don't like that either, and it's either a bug, or there should at least be an option to control that.</p>
<p>The "Download as Latex" feature in the Jupyter is, well, a Jupyter-specific feature. It doesn't know anything about Sage, and I'm not sure if the necessary APIs exist in Jupyter to ensure that a code block containing latex-formatted output actually renders the latex when converting to a tex file. This would be an issue for <a href="https://github.com/jupyter/nbconvert">https://github.com/jupyter/nbconvert</a> A quick search of the open issues didn't reveal anything obviously related to me though.</p>
<p>As we move towards emphasizing Jupyter more, we should definitely improve the latex handling story there. Latex is very important for Sage, and in general handled better overall by the classic sage notebook (which you can still try using if it does improve certain tasks for you). This might be an issue to add to <a href="https://trac.sagemath.org/ticket/25837">https://trac.sagemath.org/ticket/25837</a></p>
http://ask.sagemath.org/question/43051/file-download-as-latex/?comment=43130#post-id-43130See [Trac #23330](https://trac.sagemath.org/ticket/23330) for the "Download as PDF" issue and references there, especially [this comment](https://groups.google.com/forum/#!msg/sage-devel/LC_4PSjyx2M/coAzvbo1CAAJ).Tue, 24 Jul 2018 11:52:53 -0500http://ask.sagemath.org/question/43051/file-download-as-latex/?comment=43130#post-id-43130Comment by Emmanuel Charpentier for <p>I agree with Emmanuel that this is not a question, though it is a valid issue. I would be helpful to at least see an example notebook.</p>
<p>That said I think I see what you're saying. Even if the notebook has <code>%display latex</code> set, when exporting the notebook to tex it wraps all code output blocks in verbatim, and containing the plain-text output rather than the latex output. If you put latex in a <em>markdown</em> cell it does get converted properly but only if you have <em>pandoc</em> installed. And it seems Sage does not include pandoc by default (perhaps it should, assuming there's no license conflict, etc.)</p>
<p>I confirmed that this isn't just an issue with Sage. You can also test this easily in a plain Python notebook, e.g. by defining a class with a <code>_repr_latex_</code>method (see <a href="https://ipython.readthedocs.io/en/stable/config/integrating.html">https://ipython.readthedocs.io/en/sta...</a>)</p>
<pre><code>class Latex(object):
def __init__(self, latex):
self.latex = latex
def _repr_latex_(self):
return self.latex
pi = Latex(r'$$ \pi $$')
pi
</code></pre>
<p>When I run this, it sees the <code>_repr_latex_</code> and indeed renders the output cell as latex. However, when I run "Download as PDF" it just shows the default plain-text in a verbatim block, as you pointed out. I don't like that either, and it's either a bug, or there should at least be an option to control that.</p>
<p>The "Download as Latex" feature in the Jupyter is, well, a Jupyter-specific feature. It doesn't know anything about Sage, and I'm not sure if the necessary APIs exist in Jupyter to ensure that a code block containing latex-formatted output actually renders the latex when converting to a tex file. This would be an issue for <a href="https://github.com/jupyter/nbconvert">https://github.com/jupyter/nbconvert</a> A quick search of the open issues didn't reveal anything obviously related to me though.</p>
<p>As we move towards emphasizing Jupyter more, we should definitely improve the latex handling story there. Latex is very important for Sage, and in general handled better overall by the classic sage notebook (which you can still try using if it does improve certain tasks for you). This might be an issue to add to <a href="https://trac.sagemath.org/ticket/25837">https://trac.sagemath.org/ticket/25837</a></p>
http://ask.sagemath.org/question/43051/file-download-as-latex/?comment=43074#post-id-43074> Latex is very important for Sage, and in general handled better overall by the classing sage notebook
And even better by \LaTeX and SageTeX (or Pyhontex, which may be estimated as better-maintained....).Wed, 18 Jul 2018 10:56:31 -0500http://ask.sagemath.org/question/43051/file-download-as-latex/?comment=43074#post-id-43074Answer by Emmanuel Charpentier for <p>I'm using SageMath 8.2 on a Windows 10 Native with Jupyter Notebook.</p>
<p>The output file obtained by File -> Download as Latex is appalling!</p>
<p>All the output and input cells are placed in verbatim Latex constructs which prevents the usage of all the facilities provided by Latex. I understand why the input cells are in verbatim Latex constructs, after all you want to see exactly what the user wrote, but output cell should not be in verbatim Latex constructs.</p>
<p>The Greek characters are not used at all, even when variables have been defined including their Greek character.</p>
<p>All kind of arrows are printed |--> instead of taking advantage of the many arrows in Latex.</p>
<p>Long lines are just cut when the border is reached.</p>
<p>Exponentials are not shown properly, they appear with the ^ symbol.</p>
<p>The * character (multiplication) should not appear in results.</p>
<p>Daniel</p>
http://ask.sagemath.org/question/43051/file-download-as-latex/?answer=43056#post-id-43056That's not a question, that's a rant. But this is not https://rant.sagemath.org
Since you show neither :
* anything you process, nor
* any part of what you expected to get,
it's pretty hard to divine how you could get it : I'm still running *Homo Sapiens L.* V 1.0 (i. e. no telepathic interface)...
Would you consider putting down your input and your expected output and either ask a **real** question here or report a bug via [sage-support](https://groups.google.com/forum/#!forum/sage-support) ?
Hint : creating a \Latex file perusing [Sagetex](http://doc.sagemath.org/html/en/installation/index.html) (or [Pythontex](https://ctan.org/pkg/pythontex)) might get you results closer to what you seem to expect. A good tool for this is emacs + [Sage shell mode](https://github.com/sagemath/sage-shell-mode)Wed, 18 Jul 2018 01:01:06 -0500http://ask.sagemath.org/question/43051/file-download-as-latex/?answer=43056#post-id-43056Comment by danielvolinski for <p>That's not a question, that's a rant. But this is not <a href="https://rant.sagemath.org">https://rant.sagemath.org</a></p>
<p>Since you show neither :</p>
<ul>
<li><p>anything you process, nor</p></li>
<li><p>any part of what you expected to get, </p></li>
</ul>
<p>it's pretty hard to divine how you could get it : I'm still running <em>Homo Sapiens L.</em> V 1.0 (i. e. no telepathic interface)...</p>
<p>Would you consider putting down your input and your expected output and either ask a <strong>real</strong> question here or report a bug via <a href="https://groups.google.com/forum/#!forum/sage-support">sage-support</a> ?</p>
<p>Hint : creating a \Latex file perusing <a href="http://doc.sagemath.org/html/en/installation/index.html">Sagetex</a> (or <a href="https://ctan.org/pkg/pythontex">Pythontex</a>) might get you results closer to what you seem to expect. A good tool for this is emacs + <a href="https://github.com/sagemath/sage-shell-mode">Sage shell mode</a></p>
http://ask.sagemath.org/question/43051/file-download-as-latex/?comment=43075#post-id-43075This is a list of bugs in SageMath regarding TeX. There is no need for an example, you can try it with your own files and get a similar result. The TeX and PDF output as it is today is not suitable to be presented in any academic forum.Thu, 19 Jul 2018 02:01:01 -0500http://ask.sagemath.org/question/43051/file-download-as-latex/?comment=43075#post-id-43075