How to configure Latex, Jupyter and Org mode in Emacs
2 minutes read
Why use Jupyter notebooks when you can connect to a kernel directly from within Org mode in Emacs?
Configure texlive
I’m on Arch BTW, and i don’t like the texlive-basic
, texlive-full
and texlive-bin
packages that are present in the Arch repos. So I’ll be setting up a local Texlive installation in this section. I’ve symlinked (to /usr/local/bin
) some binaries that Emacs requires. I didn’t add the entire installation folder to PATH
because it adds a lot of executables to my fish
autosuggestions.
Org mode settings
Org-mode does need could do with some configuration to accomodate LaTeX previews. Note that the steps below will be applicable only to the graphical version of Emacs.
Better defaults
This makes it convenient to use Jupyter
src blocks within Emacs. Note that emacs-jupyter
needs to be set up for this. I’ve also set a custom size for the LaTeX (and image, e.g plot) previews here.
Org mode LaTeX configuration
Org-fragtog
is a package that brings [on-hover]{.underline} LaTeX preview functionality to Emacs. This requires a local LaTeX environment such as the one I’m using. The configuration below loads LaTeX previews when a file is opened.
This automatically configures LaTeX previews for us because the Jupyter kernel supports %matplotlib inline
.
Conda
I’m using Anaconda
for ML work, and so I’ve configured Emacs to auto-load my ML
environment (in which I’ve installed the Jupyter
packages). I’ve installed miniconda to ~/.miniconda
and so i’ve set these variables accordingly, you’d have to modify these values based on your prefix.
PDF Org-export previews
pdf-tools is a replacement of DocView for viewing PDF files inside Emacs. It uses the poppler
library, which also means that ‘pdf-tools’ can be used to modify PDFs. This requires the poppler
library, and so it must be installed (in my case, using pacman
). This also brings PDF editing abilities to Emacs - which I guess isn’t available in DocView mode. This uses epdfinfo
under the hood and renders PDFs quite well. I’m pleased enough to make this my system-wide PDF editor.
Conclusion
Whoops, did i forget images? Here ya go:
Ok then, I’ll be back with some Emacs content in the near future. Stay tuned!