1

Pretty straight forward issue here. My kables won't align to the left. Here's an example of my rmarkdown:

---
title: ""
output: pdf_document
classoption: landscape
---
#### This is a kable  
```{r, echo=FALSE, fig.align='left'}
knitr::kable(head(mtcars))
```

#### This is a table  
```{r, echo=FALSE, fig.align='left'}
head(mtcars)
```

Why is this happening? It should be simple to align a kable to the left but I can't seem to find anything useful.

Ben G
  • 4,148
  • 2
  • 22
  • 42
  • I am trying `kable(...) %>% kable_styling(position = "left") and I am getting annoying errors, also maybe try rendering to HTML, and then print to pdf if you still have issues. – Daniel_j_iii Jun 23 '20 at 01:56

1 Answers1

3

OK, here's my hack which I got from this answer.

---
title: ""
output: pdf_document
classoption: landscape
---
#### This is a kable
\hfill\break
```{r, echo=FALSE}
library(magrittr)

knitr::kable(head(mtcars), "latex") %>% 
  kableExtra::kable_styling(position = "left")
```

#### This is a table  
```{r, echo=FALSE, fig.align='left'}
head(mtcars)
```
Ben G
  • 4,148
  • 2
  • 22
  • 42