Closed drag05 closed 3 years ago
For reference, there is also a report in Rstudio community https://community.rstudio.com/t/rmd-works-fine-in-r-but-not-in-shiny/69109
@cderv
I know, that's mine too. Still trying to find an answer.
Thank you!
Oh ok ! As there was the same error in both, I linked those. Please do not hesitate to link when cross-posted. I'll look into it when I found some time.
@cderv
I will keep that in mind. Thank you!
@cderv
Hello, I wonder if there were any developments on this issue. Please advise, thank you!
What you have is a latex error. So if you google search for CTAN and longtabu, you'll find that this is included in tabu TeX package: https://ctan.org/pkg/tabu . Try to install the this package and make it available to your document.
I think this longtabu
environment is coming for the kableExtra 📦 because you used fullwidth = TRUE
https://github.com/haozhu233/kableExtra/blob/9399dccf5d722878cbb07cfbb2bf037fbb5582ad/R/kable_styling.R#L360-L366
I believe the use of package tabut should be added by default.
Maybe @haozhu233 could help, but it will be like us : Without a proper minimal reproducible example, there is not much we can do to help you ! Thank you!
Hope this helps.
@cderv
Thank you for your detailed answer! I thought the minimal reproducible example given above would have been sufficient.
The link you sent me shows requirement for both longtable
and tabu
:
longtable.sty
was present in my tinytex
installation but inside an environment called tools
(below), together with few other latex
packages
tlmgr_search('longtable')
tools:
texmf-dist/doc/latex/tools/longtable.pdf
texmf-dist/tex/latex/tools/longtable.sty
texmf-dist/source/latex/tools/longtable.dtx
texmf-dist/source/latex/tools/longtable.ins
but not present as an installed TeX Live
package listed by tl_pkgs()
:
'longtable' %in% grep( '^l',
tl_pkgs(),
value = TRUE)
[1] FALSE
while tabu
was present at all times:
> grep('^t',
tinytex::tl_pkgs(),
value = TRUE)
[1] "tabu" "tex"
[3] "tex-ini-files" "texlive-scripts"
[5] "texlive.infra" "textcase"
[7] "threeparttable" "thumbpdf"
[9] "times" "tipa"
[11] "titlesec" "tlgs"
[13] "tlperl" "tlpsv"
[15] "tools" "translator"
[17] "tufte-latex"
I assumed that - when called from within Shiny
- the rmarkdown::render()
function does not look in the tools
environment for longtable
however, it is able to look in this environment when called from outside Shiny
.
Therefore, I have implemented a workaround in which function render()
is called from outside Shiny
. The workaround brought back the long table split accross pages, as well as the pdf Report's missing header and footer.
Thank you!
I don't think it is related to longtable as the error you have is
! LaTeX Error: Environment longtabu undefined.
So longtabu environment, which is defined in the tabu CTAN package, that should be included in your document when you render to PDF.
I thought the minimal reproducible example given above would have been sufficient.
Sorry I may have missed it but I didn't find a piece of code I could run to reproduce your issue.
Have you already isolate the issue to be related to when in a shiny app? Or do you have still have the issue when you knit the document to pdf outside your app ?
Anyway, having an example we can run would be useful. You can even link a zip file if needed. See the issue guide : https://yihui.org/issue/#bug-reports
Thank you !
Therefore, I have implemented a workaround in which function render() is called from outside Shiny. The workaround brought back the long table split accross pages, as well as the pdf Report's missing header and footer.
And this would help me understand this, because if lontable is the issue here, I don't understand the first error message. 😄
@cderv
The issue appears only when render()
is being called within Shiny
. Quoting my first entry: "The Rmd works fine when used in stand alone form, either from R Studio, R console or command line, and loads same libraries via a contained R chunk."
Regarding the ! LaTeX Error: Environment longtabu undefined error:
The word 'longtabu' is mentioned in the kableExtra
link that you posted previously
However,
the error considers "longtabu undefined"
parse_packages()
is unable to find any missing packages from the latex
log file
tlmgr_install()
cannot find "longtabu" in any repository:
> tlmgr_install('longtabu')
tlmgr install longtabu
tlmgr.pl install: package longtabu not present in repository.
tlmgr.pl: action install returned an error; continuing.
tlmgr.pl: package repository http://ctan.mirror.colo-serv.net/systems/texlive/tlnet (verified)
tlmgr.pl: An error has occurred. See above messages. Exiting.
tlmgr update --self
tlmgr install longtabu
tlmgr.pl install: package longtabu not present in repository.
tlmgr.pl: action install returned an error; continuing.
tlmgr.pl: package repository http://ctan.mirror.colo-serv.net/systems/texlive/tlnet (verified)
tlmgr.pl: An error has occurred. See above messages. Exiting.
>
This suggests that the presence of word 'longtabu' inside pdfTable_styling
function may need be reconsidered.
And what is "longtabu" anyway? If it is an environment inside tabu
then why is it mentioned along with longtable
and tabu
in the ifelse statement?
Regarding the workaround:
in my Server.R
, instead of having
# create and save pdf report
observeEvent(input$reportPDF, {
rmarkdown::render('Report.Rmd'
, output_dir = './www/makeReport'
)
...
})
which throws the error
! LaTeX Error: Environment longtabu undefined,
I am sourcing a simple script named "WorkaroundScript.R":
# create and save pdf report
observeEvent(input$reportPDF, {
source('WorkaroundScript.R')
....
})
The WorkaroundScript.R is looking for "Report.Rmd" in the "./data" directory:
try(rmarkdown::render('./data/Report.Rmd'
, output_dir = './www/makeReport'))
saving the pdf Report in the '/makeReport' directory.
This is the workaround which obtains the pdf Report as required, without solving the "longtabu undefined" error above.
Thank you!
Sorry for the delay.
I don't think there is anything to do in tinytex. As I said above https://github.com/yihui/tinytex/issues/218#issuecomment-694738017, using kableExtra requires a set of packages in your document. See page 4 of this documentation https://haozhu233.github.io/kableExtra/awesome_table_in_pdf.pdf
I believe you are missing the tabu package for CTAN. You need \usepackage{tabu}
. I mentioned this several time. Did you try ?
Thanks.
kableExtra should load them by default for you but it seems in your usage it is not.
@cderv : Sorry for the big delay in my answer! I have followed your last advice with the same result. Thank you for your time!
I am having what appear to be very similar problems but find the discussion above does not help.
It appears the kable-styling function is requiring the Latex tabu package, but tabu seems to be irretrievably broken... see this https://github.com/tabu-issues-for-future-maintainer/tabu
Is no-one updating kableExtra to resolve this cal for a defunct package?
Hi @TC-RAC,
Please do open a new issue instead of adding to one that does not help you directly. It is best to open a new one and link to an old one than commenting on a closed thread. Thank you.
Is no-one updating kableExtra to resolve this cal for a defunct package?
If you are using kableExtra and have issue with it with tabu
LaTeX package, then you can open an issue in https://github.com/haozhu233/kableExtra
Thank you
I am building a shiny app that basically connects to a database, displays a table where the User can filter the data and then calls
rmarkdown::render()
by pressing a button and generate a.pdf
report in app's subdirectory named./makeReport
.For this app, all R packages are loaded via the
global.R
script.The Rmd works fine when used in stand alone form, either from R Studio, R console or command line, and loads same libraries via a contained R chunk.
I use
tinytex
and runtinytex_install
andtlmgr_update
. I have noMiKTex
installed.The pdf report contains text, graphs, and tables crossing several pages. Tables wider than 6 columns are column-split via
pander
package.The remaining tables are generated via
knitr::kable()
using the custom function below:which throws the following error:
This is one issue. The second is the Report loses its header together with all the information in it. The footer is still there but cannot get it to show the
page of Total pages
info. Just thepage
Probably misinterpreting the error message above, at first I tried to install package
longtable.sty
usingtinytex::tlmgr_install('longtable')
and got the follwing messages:I am able to print the table if use
format = 'pandoc'
orformat = 'markdown'
.The yaml header looks like this:
and
Please advise, thank you!
Originally posted by @drag05 in https://github.com/yihui/tinytex/issues/217#issuecomment-643645877