0

I’ve successfully converted Jupyter HTML-format simple tables to LaTex-format tables using pandoc.read(raw.text, ‘html’).blocks in a lua filter. The resulting LaTex is \begin(longtable} … That’s okay for simple tables, but longtable does not support nested tables, which I do need.

How to convert to LaTex tabular tables (which support nested tables) rather than to longtable tables (which do not)? Or is there some other solution to converting nested tables?

1 Answers1

0

I've come to better overall solution. Rather than have pandoc convert HTML tables to LaTex tables, I've coded the tables in both HTML and LaTex format within the Jupyter notebook. The HTML representation will be rendered when running Jupyter; the LaTex representation will be copied as-is by pandoc when converting from Jupyter-format to LaTeX format.

x = data.frame(a=c(1,2,3), b=c(10,20,30), c=c(100,200,300))
x.html = kable(x, format=“html”, escape=FALSE, align=rep(“r”, ncol(x)), caption=“This is from HTML”, row.names=FALSE, table.attr=“style="white-space: nowrap;"”)
x.latex = kable_styling(latex_options=c(“hold_position”),
kable(x, format=“latex”, escape=FALSE, align=rep(“r”, ncol(x)), caption=“This is from LaTex”, row.names=FALSE))
mbx = list(data=list(“text/html”=as.character(x.html), “text/latex”=as.character(x.latex)), metadata=NULL)
publish_mimebundle(mbx$data, mbx$metadata)