jupyter / nbconvert

Jupyter Notebook Conversion
https://nbconvert.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.72k stars 564 forks source link

Bug with enumerations in latex output? #292

Open fperez opened 8 years ago

fperez commented 8 years ago

Consider an R notebook that simply contains the cell 1:5.

Converting this notebook produces latex with the following:

    \begin{enumerate*}
\item 1
\item 2
\item 3
\item 4
\item 5
\end{enumerate*}

but for some reason, when attempting to run pdflatex we get this error:

! LaTeX Error: Environment enumerate* undefined.

despite the fact that the preamble contains

\usepackage{enumerate} % Needed for markdown enumerations to work

and the console log shows:

(/usr/local/texlive/2014/texmf-dist/tex/latex/tools/enumerate.sty)

I'm not 100% sure this is our bug, but it does stop users dead on their tracks with certain notebooks.

takluyver commented 8 years ago

Ping @flying-sheep in case there is an issue with something we're doing on the R side.

flying-sheep commented 8 years ago

Well, as you know, Jupyter used to be part of IPython. That’s why nobody thought it’d be a problem to create a default LateX template that has exactly the \usepackage{...} calls that IPython needs.

Now, however, other kernels either need to utilize a subset of the LaTeX packages IPython uses (which has historically grown over time) or require a custom template.

There’s no way for a kernel to provide custom templates or even something more specific (like listing LaTeX packages), but it really should be. Especially for LaTeX.

I think that downloading a 4 line template and using the console is exactly the right amount of inconvenience that is acceptable for users but still incentive to fix the root issue (lack of flexibility in nbconvert/Jupyter and a Kernel-specific termplate)

flying-sheep commented 8 years ago

what you need is is documented in the repr package. try:

package?repr

The repr package

Description:

The repr package

Details:

The LaTeX repr of vectors needs \usepackage[inline]{enumitem}

The LaTeX repr of functions with the repr.function.highlight option set to FALSE needs \usepackage{minted}

See Also:

repr, repr-options, repr-generics, repr_text

takluyver commented 8 years ago

We do need to do something smarter with Latex conversions. Maybe part of it is that display_data messages with latex output should have some metadata indicating required packages, which could be persisted in cell/notebook metadata, and used by nbconvert when exporting to latex.

Part of the confusion is also that we're using Latex preamble from pandoc, but that's not really as static as we had hoped.