-
-
Notifications
You must be signed in to change notification settings - Fork 872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for tabularx and xltabular #2138
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of three boolean arguments, how about using one character argument like tabular.env
? We can keep the longtable
argument for backward compatibility.
|
Edit: Or you could add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you could add
tabular.env
but make it act differently for different arguments.
Yes, that's what I meant. The current tabularx
argument would be equivalent to using tabular.env == 'tabularx'
. In my code suggestions, I was using tabular
instead of tabular.env
. Are you okay with the suggested changes? (I didn't test them but just typed them directly on Github)
Thanks!
I tested your changes and tried to make the following table: Lorem = c("Ipsum")
Dolor = c("Sit")
knitr::kable(data.frame(Lorem, Dolor), escape = FALSE, booktabs = TRUE, linesep = "\\addlinespace", tabular = "xltabular", caption = "Caption") But it threw this error:
|
Co-authored-by: Yihui Xie <xie@yihui.name>
Co-authored-by: Yihui Xie <xie@yihui.name>
Co-authored-by: Yihui Xie <xie@yihui.name>
Co-authored-by: Yihui Xie <xie@yihui.name>
Co-authored-by: Yihui Xie <xie@yihui.name>
Co-authored-by: Yihui Xie <xie@yihui.name>
I committed the suggestions. |
…ule` argument if necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a couple of changes to your code and I hope you are okay with them:
- I removed the
table.length
argument. If you need to specify the length fortabularx
orxltabular
, you may use the existingvalign
argument (despite the seemingly inappropriate name; technically the two arguments are doing essentially the same thing). - I removed the
header
argument to keep the number of arguments small. If you need it, you can pass it tomidrule
.
I'll merge for now. Please feel free to let me know if these changes don't make sense and we can amend this PR later. Thanks!
Thanks, your changes are perfect.
|
So far kable only supports tabular and longtable.
But tabularx and xltabular are popular among LaTeX users.
I added support for them: all you have to do is use
tabularx = TRUE
orxltabular = TRUE
.I also added an option called
header
, which allows you to specify things to put before the body of the table.