1

I have this xtable and I'd like to set the fontsize

I am doing:

library(xtable)
options(xtable.include.rownames=F) 
#options(xtable.scalebox=.5)
options(xtable.size = "small")
options(xtable.tabular.environment = "longtable")
#options(xtable.width = "10 in")
options(xtable.comment=F)
options(xtable.floating = F)
#options("xtable.latex.environments", c("center"))

t = xtable(MYTABLE)

align(t) = "r|p{1.3cm}|p{1.25cm}|p{2cm}|p{.5cm}|p{1.8cm}|p{1.5cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|"
digits(t) = c(0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1)
print(t, sanitize.text.function = identity,hline.after =      c(-1,seq(0,nrow(t)))  , add.to.row = list(pos = list(0), command = "\\hline \\endhead ")       )

options(xtable.size = "small") does not change the font size. Is there a way I can change the font size with options(xtable.size = ??) or fontsize = 9?

I see here https://cran.r-project.org/web/packages/xtable/vignettes/xtableGallery.pdf you can use the add.to.row to change options but can font size be changed that way somehow?

add.to.row <- list(pos = list(0), command = NULL)
command <- paste0("\\hline\n\\endhead\n",
"\\hline\n",
"\\multicolumn{", dim(x)[2] + 1, "}{l}",
"{\\footnotesize Continued on next page}\n",
"\\endfoot\n",
"\\endlastfoot\n")
add.to.row$command <- command
print(x.big, hline.after=c(-1), add.to.row = add.to.row,
tabular.environment = "longtable")

Thank you.

user3022875
  • 8,598
  • 26
  • 103
  • 167
  • perhaps useful https://stackoverflow.com/questions/33994194/changing-the-font-size-of-table-using-print-xtable – user20650 Jul 14 '17 at 17:09
  • Thank you! Do you by chance know if you can set scalebox on a longtable? My table is going off the right of the page. I just decresed the font size using the link you sent but still it goes off the page. – user3022875 Jul 14 '17 at 17:16
  • The `print` command has a `size` argument to set the fontsize. You can use standard latex values for this (e.g., "small", "scriptsize", "footnotesize", "tiny"). In your case, for example, `print(t, size="small")`. See the help for `print.xtable` (type `?print.xtable`) for more details. – eipi10 Jul 14 '17 at 17:21
  • @user3022875 ; when things get tricky using xtable, I tend to use `only.contents=TRUE`, and then just `cat` the relevant latex code before and after. – user20650 Jul 14 '17 at 19:12

0 Answers0