The IPython Notebook has the ability to work with LaTeX citations. This capability consists of a couple of different parts.
To cite LaTeX references in Markdown cells, use HTML data attributes to specify the LaTeX cite key. Here is an example of what you would type into a Markdown cell:
<cite data-cite="granger2013">(Granger, 2013)</cite>
This uses a standard HTML tag, in this case cite
, along with the data-cite
attribute. The value of this attribute is the LaTeX citation key. You are not limited to using the cite
HTML tag for this; you can use any valid HTML tag with the data-cite
attribute. This flexibility allows you to style these citations in Markdown in any way you want. So the following is also valid:
<strong data-cite="granger2013">(Granger, 2013)</strong>
In order for LaTeX/BibTeX to resolve your citations, you have to specify the actual bibliography entries. The best way of doing that is using BibTeX, but you can also enter a bibliography manually using bibitem
. We have created a special bibliography
block in the nbconvert
templates for this purpose. Here is how you would use that block to declare your bibliography:
((*- extends 'latex_article.tplx' -*))
((* block bibliography *))
\bibliographystyle{unsrt}
\bibliography{ipython}
((* endblock bibliography *))
This assumes that we have the file ipython.bib
in the current working directory with our bibliography entries.
The last step is to run nbconvert
to generate the PDF document using pdflatex and bibtex. Here is an example of how you would tell nbconvert
to generate LaTeX output using your custom template and run pdflatex/bibtex to generate the PDF:
ipython nbconvert --to latex --template mytemplate.tplx --post pdf mynotebook.ipynb
This directory contains a full working example that can be run by typing:
ipython nbconvert
The setup for this example is contained in the config file ipython_nbconvert_config.py
.