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':


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


<<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"))


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

setwd('SET WORKING DIRECTORY HERE') #..Note: Working directory should match the location of the .Rnw file. 


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!





<<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')


migrated from stackoverflow.com Mar 13 '14 at 13:00

This question came from our site for professional and enthusiast programmers.


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


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.

  • Thanks for the answer. I had to play around with it for a little bit, but these were the right solutions answers. I've added my revised script which answers both questions. – Aaron Mar 15 '14 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.