Hacker News new | past | comments | ask | show | jobs | submit login

>I've done this to directly generate branded PDF reports via latex.

Can you elaborate on this a little? Do you mean via Jupyter notebooks?




Here's an example where nbconverts a notebook and a template into a formatted tex file, and then a journal-ready PDF:

https://codeocean.com/capsule/9155944/tree/v1

The nbconvert syntax is

  jupyter nbconvert --exec --to latex --template ieee.tplx --output ../results/editorial.tex editorial.ipynb
and then `pdflatex` converts the tex file to a PDF


Yes, via Jupyter notebooks -- using the same machinery that gives the 'File > Export Notebook As...' functionality.

My method is roughly this:

1. Create a Python package that subclasses nbconvert.exporters.LatexExporter -- in the setup.py you register the class to 'nbconvert.exporters' in the 'entry_points' dict.

2. You can do general filtering/compiling by registering 'Exporter.filters'. The compile process can be modified by implementing a custom 'from_notebook_node()'

3. You can include a folder containing jinja template(s) in the package to implement whatever styling you want

4. I have some standard metadata that I pull from the notebook/cell metadata (using the standard Jupyter/lab frontend metadata sidebar) to define things like document titles, authors, etc.

5. Do the conversion like: jupyter nbconvert --to=myfancyexportformat notebook.ipynb


Wow someone use the features I wrote years ago ! <3 You might want to submit a blog post to Jupyter.org to show that this is possible and make it more known.


That work you did those years ago made me a hero at work :) Thanks!


Never had the opportunity to really document it, so thinks for finding it; I would have hoped for a much wider variety of exporter to be published. I'm still happy about the "pip install package" --to=qualname. I thin you can hardly make it simpler.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: