I am trying to pretty print the help output available for some R packages, particularly when they have comments with roxygen markup.
I have tried using the R package printr
, but I'm unable to get it to reproduce the nice output it shows. Instead, when I render the Rmarkdown file to PDF, it generates the source code verbatim prefixed by "##" comment markers.
Here is an MRE:
---
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r example}
library(printr)
library(stats)
?confint
```
This outputs something that fails to pretty print the help. If I replace pdf_document with html_document, I get the expected pretty printed output.
Any ideas? I saw this posted as an issue on its github page, Help pages rendered as code block in knit to pdf · Issue #36 · yihui/printr · GitHub, but the author only responds with:
"That is a natural idea. I actually tried it in the very beginning but it was tricky. The main problem is how to properly insert the LaTeX "packages" like Rd.sty
into the final .tex
output document, since the LaTeX output of a help page requires extra LaTeX packages."
This was back in 2018, so apparently it was very tricky. Are there any other packages that might help with this?