By filing an issue to this repo, I promise that
xfun::session_info('tinytex'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('yihui/tinytex').Dear, I am trying to use the xtable sideways-table floating environment (from https://cran.r-project.org/web/packages/xtable/vignettes/xtableGallery.pdf) in a R markdown report. However, I get an error message that the environment sidewaystable is undefined:
! LaTeX Error: Environment sidewaystable undefined.
I have then tried to install the package that is supposed to contain the environment (\usepackage{rotating})
> tlmgr_install("rotating")
tlmgr install rotating
tlmgr.pl install: package rotating not present in repository.
tlmgr.pl: action install returned an error; continuing.
tlmgr.pl: package repository https://ftp.snt.utwente.nl/pub/software/tex/systems/texlive/tlnet (verified)
tlmgr.pl: An error has occurred. See above messages. Exiting.
tlmgr update --self
tlmgr install rotating
tlmgr.pl install: package rotating not present in repository.
tlmgr.pl: action install returned an error; continuing.
tlmgr.pl: package repository https://ftp.snt.utwente.nl/pub/software/tex/systems/texlive/tlnet (verified)
tlmgr.pl: An error has occurred. See above messages. Exiting.
Then, I went on to check CTAN and I found that rotating is now integrated with latex-graphics (https://ctan.org/pkg/rotating?lang=en) which does not seem part of the repository either:
tlmgr install latex-graphics
tlmgr.pl install: package latex-graphics not present in repository.
tlmgr.pl: action install returned an error; continuing.
tlmgr.pl: package repository https://ftp.snt.utwente.nl/pub/software/tex/systems/texlive/tlnet (verified)
tlmgr.pl: An error has occurred. See above messages. Exiting.
tlmgr update --self
tlmgr install latex-graphics
tlmgr.pl install: package latex-graphics not present in repository.
tlmgr.pl: action install returned an error; continuing.
tlmgr.pl: package repository https://ftp.snt.utwente.nl/pub/software/tex/systems/texlive/tlnet (verified)
tlmgr.pl: An error has occurred. See above messages. Exiting.
I did install the package latex-graphics-dev, but still to no avail. I am aware that I could try to install from a zip archive as well (#126), but that seems like a hacky solution, especially with something as core to latex as the graphics package. So I am wondering, is there a cleaner solution? Am I using the wrong version? Is tlmgr using the wrong version? Below I includedthe output of xfun::session_info()
I am running the latest version of R, my Rstudio and all packages are up to date. My OS is Windows 10. I have issued a full reinstall as well (tinytex::reinstall_tinytex())
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362), RStudio 1.3.1093
Locale:
LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
LC_NUMERIC=C LC_TIME=English_United States.1252
Package version:
assertthat_0.2.1 base64enc_0.1.3 cellranger_1.1.0 cli_2.0.2 compiler_4.0.2 crayon_1.3.4 digest_0.6.25
dplyr_1.0.2 ellipsis_0.3.1 evaluate_0.14 fansi_0.4.1 generics_0.0.2 glue_1.4.2 graphics_4.0.2
grDevices_4.0.2 highr_0.8 hms_0.5.3 htmltools_0.5.0 jsonlite_1.7.1 knitr_1.29 lifecycle_0.2.0
magrittr_1.5 markdown_1.1 methods_4.0.2 mime_0.9 pillar_1.4.6 pkgconfig_2.0.3 prettyunits_1.1.1
progress_1.2.2 purrr_0.3.4 R6_2.4.1 Rcpp_1.0.5 readxl_1.3.1 rematch_1.0.1 rlang_0.4.7
rmarkdown_2.3 rstudioapi_0.11 stats_4.0.2 stringi_1.5.3 stringr_1.4.0 tibble_3.0.3 tidyselect_1.1.0
tinytex_0.25.4 tools_4.0.2 utf8_1.1.4 utils_4.0.2 vctrs_0.3.4 xfun_0.17 yaml_2.2.1
Speficially for tinytex:
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362), RStudio 1.3.1093
Locale:
LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
LC_NUMERIC=C LC_TIME=English_United States.1252
Package version:
graphics_4.0.2 grDevices_4.0.2 stats_4.0.2 tinytex_0.25.4 tools_4.0.2 utils_4.0.2 xfun_0.17
Reproducible example (R markdown file):
title: "Reprex xtable issue"
author: "FM Kerckhof"
date: "r Sys.Date()"
fontsize: 10pt
geometry: "left=3cm,right=3cm,top=2cm,bottom=2cm"
output:
pdf_document:
toc: yes
fig_caption: yes
number_sections: yes
editor_options:
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(knitr)
library(xtable)
data("CO2")
# Introduction
This is a Rmd that serves as a reprex for an issue with tinytex and
sidewaystable.
# Normal xtable enviroment runs smoothly
Without sidewaystable we get a properly rendered table in Table \ref{tab:oktable}.
```{r workingtable, echo=FALSE,warning=FALSE, results='asis'}
names(CO2) <- c("Plant identifier","Type","Treatment","Carbon dioxide concentration (mL/L)","CO2 uptake rate (micromol/m2)")
print(xtable(CO2,caption = "Overview table of measurements.",label = "tab:oktable",align = "rp{2cm}|p{2cm}p{3cm}p{3cm}p{3cm}"),
sanitize.text.function=function(x){x},hline.after=c(-1,0),caption.placement="top",
include.rownames=FALSE,comment=FALSE,sanitize.colnames.function=NULL)
The sideways table environment cannot be found, the encompassing LaTeX packages
cannot be installed.
```{r problemtable, echo=FALSE,warning=FALSE, results='asis'}
print(xtable(CO2,caption = "Overview table of measurements.",label = "tab:faultytable",align = "rp{2cm}|p{2cm}p{3cm}p{3cm}p{3cm}"),
sanitize.text.function=function(x){x},hline.after=c(-1,0),caption.placement="top",
include.rownames=FALSE,comment=FALSE,sanitize.colnames.function=NULL,
floating = TRUE, floating.environment = "sidewaystable")
# Session info
```{r sessioninfo}
knitr::kable(devtools::session_info()$packages[,1:3])
````
Could you read and follow the issue guide exactly to provide all the required information? As requested, please provide a reproducible example, otherwise it is often hard for us to help you. Thanks!
Apologies, I editted my initial issue. I pasted a working example of a markdown document
(but I had to escape the chuncks for github to take the formatting).
FWIW you can format correctly by following the issue guide https://yihui.org/issue/#please-format-your-issue-correctly
It seems the issue comes from the fact the package rotating is not loading in the tex file.
To see that, I added keep_tex in
yaml
output:
pdf_document:
toc: yes
fig_caption: yes
number_sections: yes
keep_tex: true
and look for \usepackage{rotating} that I did not found, and hence the error.
So I tried adding the package by using extra_dependencies
output:
pdf_document:
toc: yes
fig_caption: yes
number_sections: yes
keep_tex: true
extra_dependencies: rotating
and it works fine, because \usepackage{rotating} is now explicitly added.
This is explained explicitly in the doc for xtable you linked (https://cran.r-project.org/web/packages/xtable/vignettes/xtableGallery.pdf) at chapter 5.10
Requires usepackage{rotating} in the LATEX preamble.
If you want to use that, you'll need to add yourself the correct package in the preamble. Either using what I used, or by inserting a custom preamble. See:
And also for next time, consider asking on RStudio community for example - it is better suited for asking questions with a broad community of r-helper !
Thank you !
Thank you @cderv , for the problem resolution, the clear explanation and the guidelines for future issues. I should not worry about future compatibility given that rotating is part of latex-graphics, according to CTAN (https://ctan.org/pkg/rotating?lang=en)?
Most helpful comment
It seems the issue comes from the fact the package
rotatingis not loading in the tex file.To see that, I added
keep_texinyaml output: pdf_document: toc: yes fig_caption: yes number_sections: yes keep_tex: trueand look for
\usepackage{rotating}that I did not found, and hence the error.So I tried adding the package by using
extra_dependenciesand it works fine, because
\usepackage{rotating}is now explicitly added.This is explained explicitly in the doc for xtable you linked (https://cran.r-project.org/web/packages/xtable/vignettes/xtableGallery.pdf) at chapter 5.10
If you want to use that, you'll need to add yourself the correct package in the preamble. Either using what I used, or by inserting a custom preamble. See:
And also for next time, consider asking on RStudio community for example - it is better suited for asking questions with a broad community of r-helper !
Thank you !