Skip to content

DataFrame-output in Jupyter as LaTeX breaks PDF-rendering via Typst #3493

@roland-KA

Description

@roland-KA

It seems to me, that DataFrames within a Jupyter notebook are by default rendered using a LaTeX-format. This is no problem when the notebook is

  • displayed in a preview using HTML
  • rendered to PDF using LaTeX

But in the meantime there is also the possibility to render a Jupyter notebook (in VS Code which uses Quarto) to PDF using Typst.

A DataFrame like

df = DataFrame(
    fruit = ["banana", "apple"],
    price = [4.5, 3.6]
)

get's in this processing pipeline still converted to:

\begin{tabular}{r|cc}
	& fruit & price\\
	\hline
	& String & Float64\\
	\hline
	1 & banana & 4.5 \\
	2 & apple & 3.6 \\
\end{tabular}

This cannot be processed further. So DataFrames don't show up in the PDFs created this way. I have already created an issue on this topic (with more details) in the Quarto repo (quarto-dev/quarto-cli#12298). But in the meantime I think, this is rather a DataFrame-specific problem.

As I understand, DataFrames use PrettyTables do display themselves in different formats (using so-called backends). Is there a way to change the default backend used by DataFrames within a Jupyter notebook?

From the PrettyTables documentation I just saw that the backend can be choosen for specific explicit calls to their rendering functions. But I don't understand how to change the backend globally within a notebook.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions