I'm using the tufte::tufte_handout class in RMarkdown/Rstduio. Is there a way to get a full-width table, as you can a full width image/plot?
EDIT: Just to be clear, I know how make figures full width with the relevant chunk options. Here I want to have the same effect on a table
I'm wondering also whether this is more of a latex question than rmarkdown, so have added that tag.
EDIT2: As a minimal non-working example see:
---
title: "Untitled"
output: tufte::tufte_handout
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(pander)
library(tidyverse)
```
```{r, fig.fullwidth = TRUE}
cars %>% t %>% head(20) %>% pander
```
The only way I can think of to get a full-width table working in Tufte Handouts is to use the (awesome) kableExtra
package. This package gives you a lot more formatting and editing options and I would recommend looking into these guides here: Guide 1 & Guide 2.
This is the code I got it working with:
---
title: "Tufte Handout"
output:
tufte::tufte_handout:
includes:
in_header: testheader.tex
latex_engine: xelatex
---
```{r setup, include=FALSE}
library(tufte)
knitr::opts_chunk$set(tidy = FALSE, cache.extra = packageVersion('tufte'),
kable.force.latex = TRUE)
options(htmltools.dir.version = FALSE)
```
## Full width table
This is a test. This is a test. This is a test. This is a test. This is a
test. This is a test. This is a test. This is a test.
```{r, resize.width=100, echo=FALSE}
library(knitr)
library(magrittr)
library(kableExtra)
knitr::kable(mtcars[1:6, 1:6], format = "latex", booktabs=T,
table.envir='table*') %>%
kable_styling(latex_options = c("hold_position"), full_width=T)
```
Tex header (testheader.tex) for kableExtra:
\usepackage{xcolor}
\usepackage{background}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{array}
\usepackage{multirow}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{colortbl}
\usepackage{pdflscape}
\usepackage{tabu}
\usepackage{threeparttable}
A couple of things are important to get it working which is why I am highlighting it here. Namely: kable.force.latex = TRUE
and table.envir='table*'
. Obviously you might not need everything that you find in the code and tex header so please feel free to adjust accordingly.
Output looks as follows: