"Download as Pdf via LaTeX" in a yupyter notebook

298 views
Skip to first unread message

Peter Luschny

unread,
Jun 8, 2016, 1:33:32 PM6/8/16
to sage-cloud
Hi,

a nice error message is displayed when I try the command

    File/Download as/Pdf via LaTeX

in a yupyter notebook with SageMath 6.10 kernel.

Cheers, Peter


Harald Schilly

unread,
Jun 8, 2016, 1:47:02 PM6/8/16
to sage-cloud
Hello, I don't know exactly what's going on. This is cause by two
possible problems.

1. it took too long to create it. In that case just do F5 to reload
that download page again. I haven't figured out who times out too
early :-\

2. There are problems with latex. jupyter is very optimistic and
assumes, that every latex code will always compile no matter what. On
the command line, you can try your luck with

jupyter-nbconvert --to=latex [filename].ipynb

and debug by hand, or also be optimistic by doing

jupyter-nbconvert --to=pdf [filename].ipynb

As a possible solution to all of this, maybe does anyone know a good
html to pdf converter? Because then, a third possibility would be to
first run

jupyter-nbconvert --to=html [filename].ipynb

which produces a single html file containing everything (and works all
the time, because hey, jupyter is html!), and then running such a html
to pdf converter to get the PDF. I think, firefox or some headless
chrome could do that, but then you have page folds and other extras
printed in the pages :-(

-- harald
> --
> You received this message because you are subscribed to the Google Groups
> "sage-cloud" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-cloud+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cloud/a497eb5c-d4c9-4cd6-96c3-e90ddf5afe93%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Peter Luschny

unread,
Jun 8, 2016, 2:21:11 PM6/8/16
to sage-...@googlegroups.com
Hi Harald,

> 2. There are problems with latex.
> jupyter-nbconvert --to=latex [filename].ipynb

This worked.

> jupyter-nbconvert --to=pdf [filename].ipynb

This did not work, there were compiler errors.
I downloaded the tex file and looked at it.

The result is: The MathJax front end of yupyter is in no way
compatible with the nbconverter. In the notebook everything
displays fine but the TeX output of the converter is rubbish.

Thanks for your help!

Peter

Samuel Lelièvre

unread,
Jun 8, 2016, 2:22:59 PM6/8/16
to sage-cloud


Le mercredi 8 juin 2016 19:47:02 UTC+2, Harald Schilly a écrit :
Hello, I don't know exactly what's going on. This is cause by two
possible problems.

1. it took too long to create it. In that case just do F5 to reload
that download page again. I haven't figured out who times out too
early :-\

2. There are problems with latex. jupyter is very optimistic and
assumes, that every latex code will always compile no matter what. On
the command line, you can try your luck with

jupyter-nbconvert --to=latex [filename].ipynb

and debug by hand, or also be optimistic by doing

jupyter-nbconvert --to=pdf [filename].ipynb

As a possible solution to all of this, maybe does anyone know a good
html to pdf converter? Because then, a third possibility would be to
first run

jupyter-nbconvert --to=html [filename].ipynb

which produces a single html file containing everything (and works all
the time, because hey, jupyter is html!), and then running such a html
to pdf converter to get the PDF. I think, firefox or some headless
chrome could do that, but then you have page folds and other extras
printed in the pages :-(

The headers and footers that you get when printing in Firefox or Chrome
are customizable, you can set them to include nothing there.

Peter Luschny

unread,
Jun 9, 2016, 7:12:22 PM6/9/16
to sage-...@googlegroups.com
> As a possible solution to all of this, maybe does anyone know a good
> html to pdf converter? Because then, a third possibility would be to
> first run jupyter-nbconvert --to=html [filename].ipynb
> which produces a single html file containing everything (and works all
> the time, because hey, jupyter is html!), and then running such a html
> to pdf converter to get the PDF.

Yes, this is a possible substitute.

Windows 10 and Apple OS have native (system intern) pdf-printers
which are quite good (better than for example the converter
of the Chrome browser IMO).

But again the developers of IPython decided that you do not
get what you see (and what I want): they include tons of css
but for instance for @media print they suppress colors which
makes my plots ugly.

Cheers, Peter
Reply all
Reply to author
Forward
0 new messages