Set width to "auto" for pagedtable?


#1

The df_print: paged option in Rmarkdown is great for big tables. For tables with fewer columns, however, it would be nice to have an option for something like width: auto for basic HTML tables. I found the CSS file for pagedtable on Github and played around with it (see example below). I couldn’t get the box and footer width right though. Any ideas?

    ---
    output: 
      html_document:
        df_print: paged
    ---

    <style type='text/css'>
    .pagedtable table {
      width: auto;
    }
    </style>


    ```{r}
    iris[,c(1,2,5)]
    ```


#2

This is maybe not ideal but it seems to work

---
output: 
  html_document:
    df_print: paged
---

```{r}
tbl <-iris[,c(1,2,5)]
```

<div style='width:500px;margin: 0 auto;'>
```{r echo=FALSE}
tbl
```
</div>

#3

And this is the resulting doc:


#4

Thanks for the suggestion @rich_i. This would work but then you would have adjust the settings for each table. A CSS option would be a lot more convenient