# [IPython-User] nbconvert rendering of iPython output cells represented by core.display classes

Todd mtoddmatthews@gmail....
Thu Dec 27 04:54:59 CST 2012

Thanks for the help. I agree with Matthias that it would be very nice
to have such a project. For the moment, I have a basic problem using
_repl_latex_ for a simple case. The one liner suggested by
Alejandro for putting all of the row entries into a LaTeX string will
be helpful; but, I am struggling with the wrapping information.

Latex is new territory; so, I created a dummy table in a markdown for
starters. In iPython the makdown cell, it appears as LaTeX code wrapped
in a lined text cell (ie, not rendered as LaTeX) and when running
through nbconvert/pdflatex, the desired LaTeX table is produced.
Secondary question - can the Latex code be displayed as LaTeX in the markdown from
within iPython?

Now for the main problem - I should be able to match the successful
nbconvert/pdflatex behavior by having the _repl_latex_ produce the exact
same LaTeX code (wrapped in "$$" for mathjax) and then return it. But, this does not get converted with nbconvert/pdflatex with pdflatex complaining about "\Improper prevdepth". I am missing something basic. Any thoughts? Here is the code for completeness: In markdown (works with nbconvert/pdflatex): \begin{table}[h] \begin{center} \begin{tabular}{|c|c|c|} \hline Item1 & Item2 & Item3 \\ \hline\hline test1 & test2 & test3 \\ test4 & test5 & test6 \\ \hline \end{tabular} \end{center} \caption{Data Summary} \label{table:datasum} \end{table} And the _repl_latex_ definition (does not work when rendering object in nbconvert/pdflatex or iPython; however, the string returned is seemingly identical to the markdown text above): def _repr_latex_(self): tex = "$$\\begin{table}[h]\n"
tex += "\\begin{center}\n"
tex += "\\begin{tabular}{|c|c|c|}\n"
tex += "\\hline\n"
tex += "Item1  &  Item2  &  Item3 \\\\\n"
tex += "\\hline\\hline\n"
tex += "test1      &  test2      &  test3 \\\\\n"
tex += "test4      &  test5      &  test6 \\\\\n"
# WILL REPLACE TWO LINES ABOVE WITH ONE LINER SUGGESTED BY
# ALEJANDRO TO DEFINE ROW ENTRIES FROM LIST
tex += "\\end{center}\n"
tex += "\\caption{Data Summary}\n"
tex += "\\label{table:datasum}\n"
tex += "\\end{table}"
return tex