1

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.

  • 1
    Welcome to SE. Please, provide minimal working example starting width \begin{document} ... only necessary used packages .. \begin{document} ... your table ... \end{document}. As far as I know no one here have crystal ball to see, what is going on with your table :-( – Zarko Nov 30 '15 at 13:28
  • There is many ways to make table with equal with text or column width. Is this your problem? – Zarko Nov 30 '15 at 13:30
  • Font size of the table is setted using R Sweave with print: print(xT, size="\\small"). But I want that the font size is small and the table width is 100%. Using \resizebox{\textwidth}{!}{% LATEX_TABLE_CODE } results that the font size "small" is changed extremly – b4154 Nov 30 '15 at 13:42
  • 1
    Please, do not use comment to describe your table. Just add to your question minimal working example as I asked you in my previous comment. – Zarko Nov 30 '15 at 13:46
  • @Zarko: Yes I want equal column width but in such a way that the table fits to left and right (100% width of table). Hope you have any solution. – b4154 Nov 30 '15 at 14:44
2

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.

|improve this answer|||||
  • Maybe tabularx will help. If yes I will replace tabular with tabularx (and the lll... with xxx...) of the tables which are generated with xtable() and printed with print.xtable(xT,..., size="\\tiny",...). – b4154 Dec 1 '15 at 15:41
  • Are the generated tables with "tabularx" 100% wide? – b4154 Dec 1 '15 at 15:41
  • Their width is determined with given width: \begin{tabularx}{<width of table>}{column types}. In my example I reproduce width of mini pages as you use in example you show in given link: ` 0.7\textwidth` + \0.3\textwidth. Since they are in line, both together has width \textwidth`. You really need to read some basic information how to set tables in LateX, for example en.wikibooks.org/wiki/LaTeX/Tables. – Zarko Dec 1 '15 at 17:17
  • How can you create spaces between the tables? Edit: But without affecting left and right positions?! – b4154 Dec 2 '15 at 13:26
  • With the comment I mean creating space in between (e.g. 10%) but flushing left and right so that the lines of the table on the right does not go out. Hope you understand what I mean – b4154 Dec 2 '15 at 13:45

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.