Professional Documents
Culture Documents
Publication Ready Scientific Reports and Presentations With Jupyter Notebooks - Live Editing of LaTeX Documents
Publication Ready Scientific Reports and Presentations With Jupyter Notebooks - Live Editing of LaTeX Documents
Teaching: 30 min
Exercises: 30 min
Questions
How to use JupyterLab LaTeX extension?
How to compile LaTeX documents within JupyterLab?
How to generate LaTeX documents from jupyter notebooks?
Objectives
Learn about Jupyterlab LaTeX extension
Learn about the generation of LaTeX documents from jupyter notebooks
We have been using JupyterLab to keep our research work and are now ready to write a scientific paper associated with our computing
results and for writing our paper, we will be using LaTeX (https://www.latex-project.org/).
https://annefou.github.io/jupyter_publish/03-latex/index.html 1/6
10/6/2020 Publication ready scientific reports and presentations with Jupyter notebooks: Live editing of LaTeX documents
Rename it to report_example.tex
Then we will create a very simple LaTeX document and check it out with the JupyterLab:
\documentclass{article}
\begin{document}
\end{document}
Save it and then right click to select “Show LaTeX preview” as shown in the figure below:
https://annefou.github.io/jupyter_publish/03-latex/index.html 2/6
10/6/2020 Publication ready scientific reports and presentations with Jupyter notebooks: Live editing of LaTeX documents
The pdf preview of your document will appear on the right hand side of JupyterLab:
Solution
Create a new bibtex file with at least one reference and reference it in report_example.tex
Solution
See https://fr.overleaf.com/learn/latex/Bibliography_management_with_bibtex
(https://fr.overleaf.com/learn/latex/Bibliography_management_with_bibtex) to get more examples.
https://annefou.github.io/jupyter_publish/03-latex/index.html 3/6
10/6/2020 Publication ready scientific reports and presentations with Jupyter notebooks: Live editing of LaTeX documents
Let’s go back to our jupyter notebook example and let’s create a nice LaTeX document from it.
Execute this cell and check converted directory. It should contain a list of files and in particular:
example.tex
example.pdf
nbpublish can be called directly from your jupyter notebook or from the jupyterLab Terminal.
Cell inspector
It is sometimes convenient to inspect and modify metadata of a given cell. For instance, to ignore the cell where nbpublish is run:
{
"ipub": {
"ignore": true
}
}
Add it in the metadata of the corresponding cell, as shown in the image below:
There are several options (not only latex_ipypublish_all) to generate and customize what you would like to see in your report.
Check the ipypublish documentation (https://ipypublish.readthedocs.io/en/latest/) for more information. Please note that the ipypublish
python package is still under development (beta version avaiable only).
https://annefou.github.io/jupyter_publish/03-latex/index.html 4/6
10/6/2020 Publication ready scientific reports and presentations with Jupyter notebooks: Live editing of LaTeX documents
Add the updated example.ipynb, example.pdf, report_example.tex, report_example.bib and report_example.pdf to your Github repository
research-bazaar-jupyter-2019 using JupyterLab git extension and/or JupyterLab Git Terminal.
A very simple way to combine them is to merge the pdf generated files. Create a new text file and rename it report_main.tex :
\documentclass{report}
\usepackage{pdfpages}
\usepackage{fancyhdr}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\pagestyle{fancy}
\rfoot{\thepage}
\begin{document}
\tableofcontents
\chapter{A chapter}
\section{Introduction}
\includepdf[pages=1-,pagecommand={\thispagestyle{fancy}}]{report_example.pdf}
\includepdf[pages=1-,pagecommand={\thispagestyle{fancy}}]{example.pdf}
\end{document}
As before, add report_main.tex and report_main.pdf to your Github repository research-bazaar-jupyter-2019 using JupyterLab git
extension and/or JupyterLab Git Terminal.
Key Points
(../02- (../04-
git/index.html) publis
Licensed under CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/) 2018–2019 by The Carpentries (https://carpentries.org/)
Licensed under CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/) 2016–2018 by Software Carpentry Foundation (https://software-
carpentry.org)
https://annefou.github.io/jupyter_publish/03-latex/index.html 5/6
10/6/2020 Publication ready scientific reports and presentations with Jupyter notebooks: Live editing of LaTeX documents
Edit on GitHub (https://github.com/annefou/jupyter_publish/edit/gh-pages/_episodes/03-latex.md) / Contributing
(https://github.com/annefou/jupyter_publish/blob/gh-pages/CONTRIBUTING.md) / Source (https://github.com/annefou/jupyter_publish/) /
Cite (https://github.com/annefou/jupyter_publish/blob/gh-pages/CITATION) / Contact (mailto:annefou@geo.uio.no)
Using The Carpentries style (https://github.com/carpentries/styles/) version 9.5.3 (https://github.com/carpentries/styles/releases/tag/v9.5.3).
https://annefou.github.io/jupyter_publish/03-latex/index.html 6/6