danijar / handout

Turn Python scripts into handouts with Markdown and figures
Apache License 2.0
2.01k stars 106 forks source link

Exporting to LaTeX #18

Open kirk86 opened 5 years ago

kirk86 commented 5 years ago

Hi and thanks for this package, I just had a couple of questions if you don't mind me asking since I couldn't find any answers in the readme. 1) Is it possible to export the document into latex? 2) Will you be releasing a conda package?

Thanks!

epogrebnyak commented 5 years ago

To my understanding html is currently the only output, but other formats are discussed (eg pdf via Webkit).

Also once there is a html, one can try create a latex with pandoc. If you can point out a good rendering engine / library for latex, that would be very helpful.

danijar commented 5 years ago

Exactly. If you give pandoc a try, please let us know how it goes. If HTML is well supported, we might be fine with having Handout always export HTML. In that case, we can provide a few examples on how to combine it with pandoc to export into various formats.

Please open a separate issue about conda :)

kirk86 commented 5 years ago

Thanks folks @danijar & @epogrebnyak for the responses, maybe if we exported directly to ipynb and then let the users convert that to other formats since ipynb allows for easy conversion to other formats such as html, pdf, latex, etc. (just an idea)

@epogrebnyak

If you can point out a good rendering engine / library for latex, that would be very helpful.

I usually use this to export an ipynb to latex, hope that helps.

Also another idea would be to combine forces with this in order to allow for easy export between .py and .ipynb.

epogrebnyak commented 5 years ago

@kirk86 - thanks for giving the clues on the latex workflow. As I understand, the current stand for Handout is one-directional transformation of .py to html, followed by options to convert to other formats.

These options seems to be (for issue #9):

In the space of py2nb that you mentioned there is also jupytext, just to note.

ipynb allows for easy conversion to other formats such as html, pdf, latex, etc. (just an idea)

Any pointers on how people convert from .ipynb to pdf/latex? nbconvert?

kirk86 commented 5 years ago

@epogrebnyak thanks for pointing to jupytext.

Any pointers on how people convert from .ipynb to pdf/latex? nbconvert?

jupyter nbconvert --to latex --template report <path/to/.ipynb> jupyter nbconvert --to pdf <path/to/.ipynb>

Alternatively, from inside jupyter menu Download as, then you'll find all the available options.

But in my experience it dumps everything (i.e. images, .tex files, etc.) in the same folder that .ipynb is located, while the package I used it keeps things nice tightly in separate folders, for instance images go to their own folder imgs, .tex files to their own tex folder, etc.

epogrebnyak commented 5 years ago

@kirk86 - thanks for pointing out the nbconvert commands! I'm now looking at nbconvert machinery to produce latex/pdf, posting for future reference:

kirk86 commented 5 years ago

@epogrebnyak

That's my understanding of it.

danijar commented 5 years ago

I think it'd be easy to write a LaTeX exporter -- we don't even need a templating library to make a first attempt at this.

We should only output LaTeX source in this case. The user can either manually call their LaTeX compiler afterwards or call it from within their script after the doc.show() line. Of course, this would be good to point out in an example.

We just need to support multiple exporters which is tracked in #9.