Наличие full_width = T
в моей функции kable приводит к ошибке:
! You can't use `\relax' after \the.
\tabu@elapsedtime ...optime {\the \pdfelapsedtime
}\tabu@message {(tabu)\tab...
Но удаление - \usepackage{fontspec}
и latex_engine: xelatex
из YAML позволяет ему работать.
Воспроизводимый код :
---
title: "For Stackoverflow"
output:
pdf_document:
latex_engine: xelatex
keep_tex: true
header-includes:
- \usepackage{booktabs}
- \usepackage{longtable}
- \usepackage{array}
- \usepackage{multirow}
- \usepackage{wrapfig}
- \usepackage{float}
- \usepackage{colortbl}
- \usepackage{pdflscape}
- \usepackage{tabu}
- \usepackage{threeparttable}
- \usepackage{threeparttablex}
- \usepackage[normalem]{ulem}
- \usepackage{makecell}
- \usepackage{xcolor}
- \usepackage{fontspec}
---
```{r message=FALSE, warning=FALSE}
library(kableExtra)
data <- data.frame('Column 1'=c('1','2','3','4','5'), 'Column 2'=c('a','b','c', 'd', 'e'))
kable(data, 'latex') %>%
kable_styling(full_width = T)
```
Вот текстовый файл:
\begin{document}
\maketitle
\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{library}\NormalTok{(kableExtra)}
\NormalTok{data <-}\StringTok{ }\KeywordTok{data.frame}\NormalTok{(}\StringTok{'Column 1'}\NormalTok{=}\KeywordTok{c}\NormalTok{(}\StringTok{'1'}\NormalTok{,}\StringTok{'2'}\NormalTok{,}\StringTok{'3'}\NormalTok{,}\StringTok{'4'}\NormalTok{,}\StringTok{'5'}\NormalTok{), }\StringTok{'Column 2'}\NormalTok{=}\KeywordTok{c}\NormalTok{(}\StringTok{'a'}\NormalTok{,}\StringTok{'b'}\NormalTok{,}\StringTok{'c'}\NormalTok{, }\StringTok{'d'}\NormalTok{, }\StringTok{'e'}\NormalTok{))}
\KeywordTok{kable}\NormalTok{(data, }\StringTok{'latex'}\NormalTok{) }\OperatorTok{%>%}
\StringTok{ }\KeywordTok{kable_styling}\NormalTok{(}\DataTypeTok{full_width =}\NormalTok{ T)}
\end{Highlighting}
\end{Shaded}
\begin{tabu} to \linewidth {>{\raggedright}X>{\raggedright}X}
\hline
Column.1 & Column.2\\
\hline
1 & a\\
\hline
2 & b\\
\hline
3 & c\\
\hline
4 & d\\
\hline
5 & e\\
\hline
\end{tabu}
\end{document}
Похоже, что основное различие между текстовыми файлами full_width=T
и full_width=F
заключается в том, что при значении true tabu используемый; в то время как при значении false используется таблица.
Вот информация о моей сессии:
- Session info -------------------------------------------------------------------------------------------------
setting value
version R version 3.6.0 (2019-04-26)
os Windows 7 x64 SP 1
system x86_64, mingw32
ui RStudio
language (EN)
date 2020-02-20
- Packages -----------------------------------------------------------------------------------------------------
! package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0)
backports 1.1.4 2019-04-10 [1] CRAN (R 3.6.0)
boot 1.3-22 2019-04-02 [1] CRAN (R 3.6.0)
broom 0.5.2 2019-04-07 [1] CRAN (R 3.6.0)
callr 3.2.0 2019-03-15 [1] CRAN (R 3.6.0)
cellranger 1.1.0 2016-07-27 [1] CRAN (R 3.6.0)
cli 1.1.0 2019-03-19 [1] CRAN (R 3.6.0)
codetools 0.2-16 2018-12-24 [1] CRAN (R 3.6.0)
colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.0)
crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0)
curl 3.3 2019-01-10 [1] CRAN (R 3.6.0)
data.table 1.12.2 2019-04-07 [1] CRAN (R 3.6.0)
DBI 1.0.0 2018-05-02 [1] CRAN (R 3.6.0)
desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.0)
devtools 2.2.1 2019-09-24 [1] CRAN (R 3.6.0)
digest 0.6.19 2019-05-20 [1] CRAN (R 3.6.0)
dplyr * 0.8.1 2019-05-14 [1] CRAN (R 3.6.0)
ellipsis 0.3.0 2019-09-20 [1] CRAN (R 3.6.1)
evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.0)
forcats * 0.4.0 2019-02-17 [1] CRAN (R 3.6.0)
foreach 1.4.4 2017-12-12 [1] CRAN (R 3.6.0)
formatR 1.6 2019-03-05 [1] CRAN (R 3.6.0)
fs 1.3.1 2019-05-06 [1] CRAN (R 3.6.0)
futile.logger 1.4.3 2016-07-10 [1] CRAN (R 3.6.0)
futile.matrix 1.2.7 2018-04-20 [1] CRAN (R 3.6.0)
futile.options 1.0.1 2018-04-20 [1] CRAN (R 3.6.0)
generics 0.0.2 2018-11-29 [1] CRAN (R 3.6.0)
ggplot2 * 3.1.1 2019-04-07 [1] CRAN (R 3.6.0)
glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.0)
gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.0)
haven 2.1.0 2019-02-19 [1] CRAN (R 3.6.0)
hms 0.4.2 2018-03-10 [1] CRAN (R 3.6.0)
htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.6.0)
httr 1.4.0 2018-12-11 [1] CRAN (R 3.6.0)
iterators 1.0.10 2018-07-13 [1] CRAN (R 3.6.0)
jsonlite 1.6 2018-12-07 [1] CRAN (R 3.6.0)
kableExtra * 1.1.0.9000 2019-11-05 [1] Github (haozhu233/kableExtra@a9504c0)
knitr * 1.25 2019-09-18 [1] CRAN (R 3.6.1)
lambda.r 1.2.3 2018-05-17 [1] CRAN (R 3.6.0)
lambda.tools 1.0.9 2016-05-11 [1] CRAN (R 3.6.0)
lattice 0.20-38 2018-11-04 [1] CRAN (R 3.6.0)
lazyeval 0.2.2 2019-03-15 [1] CRAN (R 3.6.0)
lpSolve 5.6.13 2015-09-19 [1] CRAN (R 3.6.0)
lubridate 1.7.4 2018-04-11 [1] CRAN (R 3.6.0)
magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0)
memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.0)
modelr 0.1.4 2019-02-18 [1] CRAN (R 3.6.0)
munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.0)
nlme 3.1-139 2019-04-09 [1] CRAN (R 3.6.0)
numDeriv 2016.8-1 2016-08-27 [1] CRAN (R 3.6.0)
PerformanceAnalytics 1.5.2 2018-03-02 [1] CRAN (R 3.6.0)
pillar 1.4.0 2019-05-11 [1] CRAN (R 3.6.0)
pkgbuild 1.0.3 2019-03-20 [1] CRAN (R 3.6.0)
pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.6.0)
pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.6.0)
plyr 1.8.4 2016-06-08 [1] CRAN (R 3.6.0)
pracma 2.2.5 2019-04-09 [1] CRAN (R 3.6.0)
prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.6.0)
D processx 3.3.1 2019-05-08 [1] CRAN (R 3.6.0)
ps 1.3.0 2018-12-21 [1] CRAN (R 3.6.0)
purrr * 0.3.2 2019-03-15 [1] CRAN (R 3.6.0)
quadprog 1.5-7 2019-05-06 [1] CRAN (R 3.6.0)
quantmod 0.4-14 2019-03-24 [1] CRAN (R 3.6.0)
R.methodsS3 1.7.1 2016-02-16 [1] CRAN (R 3.6.0)
R.oo 1.22.0 2018-04-22 [1] CRAN (R 3.6.0)
R6 2.4.0 2019-02-14 [1] CRAN (R 3.6.0)
Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.6.0)
readr * 1.3.1 2018-12-21 [1] CRAN (R 3.6.0)
readxl 1.3.1 2019-03-13 [1] CRAN (R 3.6.0)
registry 0.5-1 2019-03-05 [1] CRAN (R 3.6.0)
remotes 2.1.0 2019-06-24 [1] CRAN (R 3.6.1)
reshape2 1.4.3 2017-12-11 [1] CRAN (R 3.6.0)
rlang 0.3.4 2019-04-07 [1] CRAN (R 3.6.0)
rmarkdown * 1.12 2019-03-14 [1] CRAN (R 3.6.0)
RMTstat 0.3 2014-11-01 [1] CRAN (R 3.6.0)
RODBC 1.3-15 2017-04-13 [1] CRAN (R 3.6.0)
ROI 0.3-2 2019-01-23 [1] CRAN (R 3.6.0)
RPostgreSQL 0.6-2 2017-06-24 [1] CRAN (R 3.6.0)
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.0)
rstudioapi 0.10 2019-03-19 [1] CRAN (R 3.6.0)
rvest 0.3.4 2019-05-15 [1] CRAN (R 3.6.0)
scales 1.0.0 2018-08-09 [1] CRAN (R 3.6.0)
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0)
slam 0.1-45 2019-02-26 [1] CRAN (R 3.6.0)
stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.0)
stringr * 1.4.0 2019-02-10 [1] CRAN (R 3.6.0)
tawny 2.1.7 2018-04-20 [1] CRAN (R 3.6.0)
tawny.types 1.1.5 2018-04-20 [1] CRAN (R 3.6.0)
testthat * 2.1.1 2019-04-23 [1] CRAN (R 3.6.0)
tibble * 2.1.1 2019-03-16 [1] CRAN (R 3.6.0)
tidyr * 0.8.3 2019-03-01 [1] CRAN (R 3.6.0)
tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.6.0)
tidyverse * 1.2.1 2017-11-14 [1] CRAN (R 3.6.0)
tinytex * 0.17 2019-10-30 [1] CRAN (R 3.6.1)
TTR 0.23-4 2018-09-20 [1] CRAN (R 3.6.0)
usethis 1.5.0 2019-04-07 [1] CRAN (R 3.6.0)
viridisLite 0.3.0 2018-02-01 [1] CRAN (R 3.6.0)
webshot 0.5.1.9001 2019-09-25 [1] Github (wch/webshot@4bbf4f7)
withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0)
xfun 0.11 2019-11-12 [1] CRAN (R 3.6.0)
XML 3.98-1.19 2019-03-06 [1] CRAN (R 3.6.0)
xml2 1.2.0 2018-01-24 [1] CRAN (R 3.6.0)
xts 0.11-2 2018-11-05 [1] CRAN (R 3.6.0)
yaml 2.2.0 2018-07-25 [1] CRAN (R 3.6.0)
zoo * 1.8-5 2019-03-21 [1] CRAN (R 3.6.0)
У кого-нибудь есть идеи? Спасибо за любую помощь.