Closed fawda123 closed 1 year ago
I am sorry, I don't feel able to dive into rjtools that I don't know at all and I have little time available.
I believe 'flextable' implementation is correct, although of course there are always a doubt about specific cases. flextable latex dependencies are managed automatically and for manual insertion, add_latex_dep()
is provided.
Now, when I run your example naively, I get an HTML output and all is ok. I can read you are talking about latex but I don't understand what is the relation - rjtools::rjournal_web_article
is about HTML output.
Hi @davidgohel, thanks for the reply and I completely understand that this is outside of the scope of flextable. That being said, I should have clarified that the rjtools::rjournal_web_article
format renders both an HTML and PDF. As your example shows, the HTML web page works fine, but the PDF does not. You'll see the error I'm referring to if you switch the YAML to only PDF article output.
---
draft: true
type: package
output:
rjtools::rjournal_pdf_article:
self_contained: yes
toc: no
header-includes:
- \usepackage{longtable}
---
```{r}
library(flextable)
flextable(head(cars))
! Undefined control sequence.
The format ignore rmarkdown::latex_dependency()
. flextable's dependencies are using rmarkdown functions to make sure it's compliant with R Markdown documents.
% !TeX root = RJwrapper.tex
\title{}
\author{by }
\maketitle
It should contain something like:
\usepackage{multirow}
\usepackage{multicol}
\usepackage{colortbl}
\usepackage{hhline}
\newlength\Oldarrayrulewidth
\newlength\Oldtabcolsep
\usepackage{longtable}
\usepackage{array}
\usepackage{hyperref}
\usepackage{float}
\usepackage{wrapfig}
But they are not there, it explains why you have this error. You can fix the one you reported but then you will have to face other issues because of missing latex package ¯\(ツ)/¯
From reading the documentation, it seems the package is supporting longtable and kable - it does not say other format can be used so I understand you should only use one of those 2.
I closed the issue because I think rjtools does only accept longtable or kable
Thanks @davidgohel, adding the missing packages fixed the issue.
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.
I've posted an issue in the rjtools repository (https://github.com/rjournal/rjtools/issues/70), but I also figured there might be a solution on the flextable side. I cannot get a .Rmd file to render to PDF using flextable with the rjtools template.
output_format: pdf_document
! Undefined control sequence.