[Tex/LaTex] Controlling formatting options for xtable

knitrrsweave

All,

I'm a LaTex/knitr/Sweave amateur and have had trouble finding answers to what seem like they should be fairly simple questions online. I have a .Rnw script that I am currently compiling to PDF using knitr's knit2pdf function. Within that script I have tables converted to LaTex format using xtable. I would like to do two things:

(1) Lose the "Table 1:" label. Apparently this is not as straightforward as passing a blank or NA character string to xtable's label argument.

(2) Increase the font size of the table entries

Here is a simple .Rnw script. I've saved this as 'test_template.Rnw':

\documentclass{article}

%%Save this script file as 'test_template.Rnw' in an easy-to-access location. 

\begin{document}

<<test_table, results='asis', echo=FALSE>>=
MAT <- matrix(1:9, 3, 3)
print(xtable(MAT, caption = '\\textbf{Test Table}', label = ''), 
      caption.placement = getOption("xtable.caption.placement", "top"))
@

\end{document}

and here is the R code that I am using to render the PDF:

install.packages('knitr')
library(knitr)
setwd('SET WORKING DIRECTORY HERE') #..Note: Working directory should match the location of the .Rnw file. 
knit2pdf('test_template.Rnw')

UPDATE

Scott's answer was right on target. Note that that label formatting options have to be coded independently within the label character string using double escapes ('\\'). Thanks!

\documentclass{article}

\usepackage{caption}

\begin{document}

\captionsetup{labelformat=empty}

<<test_table, results='asis', echo=FALSE>>=
MAT <- matrix(1:9, 3, 3)
print(xtable(MAT, caption = '\\textbf{\\Huge{Test Table}}', label = ''), 
  caption.placement = getOption("xtable.caption.placement", "top"), size = 'Huge')
@

\end{document}

Best Answer

For getting rid of the prefix, you can use the caption package and then

\captionsetup{labelformat=empty}

For increasing the font size, note in ?print.xtable

size: An arbitrary character vector intended to be used to set the
      font size in a LaTeX table.  The supplied value (if not
      ‘NULL’) is inserted just before the tabular environment
      starts.  Default value is ‘NULL’.

I'm not sure what syntax it's looking for.

Alternatively you could probably increase the font size as you would normally for text in LaTeX before the table.