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.

Sean Allred
  • 27,421
b4154
  • 157
  • 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
  • I have bunch of solution for your problem, however problem is us of R Sweave. I know nothing about it. So haven't any idea, how to use "classic approach" in it. Otherwise the following can help: (i) in document preamble add package tabularx}, (ii) your table change frombegin{tabular}{...} ... \end{tabular}to\begin{tabularc}{\textwidth}{XX...X} ... \end{tabularx}` By this the width of table will be equal to text width and all columns will have equal width Content in it will be left aligned and stretch to right border of cell. Maybe someone can provide you better help – Zarko Nov 30 '15 at 14:56
  • I'm still in dilemma with my issue. Please help me. A idea or some clue informations may help to lead to the solution – b4154 Dec 01 '15 at 09:50
  • I'm still in dilemma with my issue. Please help me. A idea or some clue informations may help to lead to the solution – b4154 Dec 01 '15 at 12:08
  • I'm sorry, at R Sweave, as I already told you, I can't help you. If you upload somewhere LaTeX file so that I can download it, I can edit it in my WinEdt editor and return it corrected. However, than it will be prepared for use in some standard editor for work with LaTeX. – Zarko Dec 01 '15 at 12:26
  • Here you can see how the code is written. The purpose is almost 100% but also in cells with width 70% and 30%: http://stackoverflow.com/questions/34020337/best-practice-for-two-tables-in-own-row-e-g-t170-t230-and-achieving?noredirect=1 . It would be nice if you have a suggestion – b4154 Dec 01 '15 at 12:55
  • Have you looked at the posting How to force a table into page width? for information on how to force a tabular-like environment to occupy the full width of the text block? – Mico Dec 01 '15 at 14:41

1 Answers1

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.

Zarko
  • 296,517
  • 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 01 '15 at 15:41
  • Are the generated tables with "tabularx" 100% wide? – b4154 Dec 01 '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 https://en.wikibooks.org/wiki/LaTeX/Tables. – Zarko Dec 01 '15 at 17:17
  • How can you create spaces between the tables? Edit: But without affecting left and right positions?! – b4154 Dec 02 '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 02 '15 at 13:45
  • All information you have in my answer. Repeated it as your own, is not nice from you ... – Zarko Dec 02 '15 at 15:04
  • That was not my purpose. I wanted to show the whole solution. Forgot to put {\small ... {tabularx}....} so that others can see it. See you – b4154 Dec 02 '15 at 15:11