Skip to content

Yet another IPython notebook to LaTeX converter - this one exports clean code easily absorbed in other reports.

Notifications You must be signed in to change notification settings

NelisW/ipynb2tex

Repository files navigation

ipynb2tex

Yet another IPython notebook to LaTeX converter - this one exports clean code in the user-required style, or can easily be absorbed in other reports.

The LaTeX converters supplied with IPython 2 used Pygments to colour the Python code, as well as several other features which do not fit my requirement.

Features

  • Reads and converts IPython 2.x and 3.x files (nbformats 3 and 4).
  • Code is formatted as a LaTeX lstlistings environment, which looks neater to my eye.
  • Pictures, graphs and tables can be formatted as LaTeX floats, or in line with the text.
  • Floating figures and tables can have LaTeX captions.
  • Raw NBConvert cells are passed through to LaTeX with no change.
  • References and hyperlinks are treated as first-class LaTeX references.
  • HTML tables are reformatted as LaTeX tables.
  • The header template interface allows the user to add his own style file.
  • Supports Pandas to_latex() dataframe exports as inline or floating tables
  • Supports IPython.core.display.Latex object in the output cell.

Known deficiencies

  1. Some complex cell-merged HTML tables may not render correctly in LaTeX (let me know if you have such a table).
  2. The following HTML elements are not currently processed, these elements are simply ignored: div, img.
  3. The iframe HTML element is tested for embedded PDF files which are then included as an image.
  4. Coloured text in HTML is not exported as coloured text in LaTeX.
  5. Many reserved LaTeX symbols such as hash, caret, underscore and dollar are 'legal' in normal markdown. When rendering to LaTeX these symbols cause errors unless escaped with backslash. In many cases these symbols are escaped, but not always because of context. If the symbols are escaped, they render incorrectly in normal Markdown. Therefore, choose your target renderer and enter the symbols accordingly, accepting problems in the alternative renderer.
  6. IPython notebook names must not have spaces in the filename.
  7. This notebook is not kept current with the latest Jupyter developments.

Instructions

The instructions on how to set up the notebook is given in the example notebook test2LaTeX.ipynb, please study it carefully. Someday when I have more time, I will write better instructions :-).

The most important (and most difficult) is to use the cell meta data to control LaTeX output such as:

  • captions for figures, tables and listings.
  • LaTeX citations and references.

See the example notebook for more information.

About

Yet another IPython notebook to LaTeX converter - this one exports clean code easily absorbed in other reports.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published