4

I want to know how to do in gridExtra 2.0.0 what I could do in previous versions to change table width/height padding e.g.:

grid.arrange(tableGrob(mtcars,padding.h=unit(1,"mm"),padding.v=unit(1,"mm")))

(Sorry I couldn't test the code above because I don't have the older version of gridExtra installed)

I don't want to shrink the text, just want to tighten everything together so the table fits where I'm putting it on a PDF page.

I can see the "widths" property has "+4mm" on every entry, but I don't know how to change those to, say, +2mm.

Of course I would prefer if there was a simple "padding" property I could change.

My question is in a similar vein as this one.

user944849
  • 14,524
  • 2
  • 61
  • 83
TrialNError
  • 113
  • 2
  • 7

1 Answers1

7

You have to use a theme, and as baptiste comments, you can use ttheme_default to show the properties of the default theme.

ttheme_default()

To set the padding of the table "core" to 1 mm:

mytheme <- gridExtra::ttheme_default(
             core = list(padding=unit(c(1, 1), "mm"))
           )
mytable <- tableGrob(mtcars, theme = mytheme)
Håvard Tveite
  • 215
  • 2
  • 7