Closed
Description
A few months ago I submitted a pull request that was merged which adds support for tabularx
and xltabular
tables for LaTeX in kable
. If you use one of these and try to make a table without a caption, you will get an error.
---
output:
pdf_document:
extra_dependencies: xltabular
---
```{r, echo = FALSE}
library(knitr)
col1 = c("Lorem", "Ipsum")
col2 = c("Dolor", "Sit")
df = data.frame(col1, col2)
# These two will NOT work
kable(df, "latex", tabular = "tabularx")
kable(df, "latex", tabular = "xltabular")
# These two WILL work
kable(df, "latex", tabular = "tabularx", caption = "")
kable(df, "latex", tabular = "xltabular", caption = "")
```
Here is the error I got:
! Missing number, treated as zero.
<to be read again>
l
l.70 \begin{tabularx}{l|l}
Error: LaTeX failed to compile file.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See file.log for more info.
Execution halted
shell returned 1
I understand what the problem is, it is using \begin{tabularx}{l|l}
instead of \begin{tabularx}{\linewidth}{l|l}
. It is strange that not having a caption causes this.
By filing an issue to this repo, I promise that
- I have fully read the issue guide at https://yihui.org/issue/.
- I have provided the necessary information about my issue.
- If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
- If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included
xfun::session_info('knitr')
. 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/knitr')
. - If I have posted the same issue elsewhere, I have also mentioned it in this issue.
- I have learned the Github Markdown syntax, and formatted my issue correctly.
I understand that my issue may be closed if I don't fulfill my promises.
Metadata
Metadata
Assignees
Labels
No labels