Jupyterlab, Jupyter r kernel and pandoc

#1

I have installed the r kernel in JupyterLab.
With this code snippet I build an HTML file and convert this HTML file into a PDF file using LaTeX. I would like to be able to change the appearance of the table according to my requirements. How can I change the frame, the paper size and the margins of the left and right sides, as with a book? The html files shows the correct border.

library(knitr)
library(kableExtra)
library(IRdisplay)

kable(alpha, format = "html", caption = "Caption", longtable = TRUE) %>%
kable_styling(c("striped", "bordered", "hover", "condensed", "responsive"), full_width = F, font_size = 12 ) %>%
save_kable(file = "alpha.html")
as.character() %>%
display_html()

kable(beta, format = "html", caption = "Caption", longtable = TRUE) %>%
kable_styling(c("striped", "bordered", "hover", "condensed", "responsive"), full_width = F, font_size = 12 ) %>%
save_kable(file = "beta.html")
as.character() %>%
display_html()

pandoc('alpha.html', format='latex')
pandoc('beta.html', format='latex')
#2

The library which does that conversion is nbconvert. The controls for LaTeX are somewhat limited, and we’re working on making the process better. But it could really use more developers volunteering some time to making it better or pulling the LaTeX concerns into their own module.

As to your specific questions there’s an open ticket which covers LOCALE gaps, including paper size, here. One way you can control this more today is to export to LaTex (from the interface, or directly with nbconvert) and making changes to the latex as you see best before piping to xelatex, which is what’s used to convert latex to pdf under the hood.

1 Like