[Tex/LaTex] Table width 100% and changing font size

sweavetables

I want to size table to 100% but it has to be able to change the font size.

[Purpose BEGINS here: achieve 100% width of table]

    print(xT, size="\\small", ...)

[Purpose ENDs here];

xT is a table created with function xtable.

Using

\resizebox{\textwidth}{!}{% print(xT, size="\\small", ...) }

sizes the table to 100% but the font size I set (e.g. \small) is than not accepted so that the font size is getting very big. This doesn't look nice.

Best Answer

This is more extended comment than answer. It is based on guessing, since you are not willing to provide more data, that someone can help you. This means, that the answer probably will not help you.

Use adjustobox for stretching table to text width is not right way to do this. It stretch all in it, from table to font size in it. When you lie to have table spanning whole text width, you need first to ask yourself, what is benefits to stretch table over it natural width? Table will look more empty (more white space between columns). Is this what you like to achieve?

From your comments follows, that your table float actually contain two tables. Cant this tables are separated by empty space? If not, than one of among many possible solutions is:

\begin{table}[htb]
  \begin{tabularx}{.7\textwidth}{XXX}% table structure is not known
    AAA & BBBB & CCCC  \\
  \end{tabularx}%no space between tables
  \begin{tabularx}{.3\textwidth}{XX}% table structure is not known
    DDDD & EEEE    \\
  \end{tabularx}
\end{table}

In this case the tables will stick each to other, font will not be changed and cells content will be adjusted. Iy like to mimic c, l or `rĖ™tipe of columns you need to define new columns type. For example:

\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}

For use of tabularx you need to put in preamble \usepackage{tabularx}.

In case that some white space between tables is desired, than replace % with hfill, which will move tables to the left and right text border.

Disclamer: since I never use R Sweave I do not know, how to described possible solution manage in it. Consequently I'm not able to offer further help in solving of your problem.