4 ms·
>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?
by abhishekjha 6y ago
>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?
- heisenzombie 6y agoYes, 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
- carreau 6y agoWow 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.
- heisenzombie 6y agoThat work you did those years ago made me a hero at work :) Thanks!
- carreau 6y agoNever 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.
- setgree 6y agoHere'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 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