I often use the Tufte handout in RMarkdown output to pdf to write technical documents. I have one that will have a lot of regression results, so I'm attempting to use flextable for pretty printing the results. However, I can't find any way to get flextable results to respect columns or widths. Here is my minimal example of a doc w/ a flextable that doesn't work followed by a graph that fits where it should:
---
title: "A Tufte Handout Example"
output:
tufte::tufte_handout:
citation_package: natbib
latex_engine: xelatex
bibliography: skeleton.bib
link-citations: yes
---
```{r setup, include=FALSE}
library(tufte)
options(htmltools.dir.version = FALSE)
```
## Margin Figure
```{r flextable1, echo=F, fig.margin=T}
library(flextable)
ft <- flextable(head(airquality))
ft <- autofit(ft)
theme_box(ft)
```
## It should be over there...
```{r fig-margin, fig.margin = TRUE, fig.cap = "MPG vs horsepower, colored by transmission.", fig.width=3.5, fig.height=3.5, cache=TRUE, message=FALSE}
library(ggplot2)
mtcars2 <- mtcars
mtcars2$am <- factor(
mtcars$am, labels = c('automatic', 'manual')
)
ggplot(mtcars2, aes(hp, mpg, color = am)) +
geom_point() + geom_smooth() +
theme(legend.position = 'bottom')
```
