I have a simple table:
\begin{table}[]
\begin{tabular}{c|c|c|c|c|c|c|c|}
\cline{2-7} &
\multicolumn{1}{p{2.7cm}|}{RIGHT} &
\multicolumn{1}{c|}{LEFT}&
\multicolumn{1}{c|}{LEFT}&
\multicolumn{1}{c|}{LEFT}&
\multicolumn{1}{c|}{LEFT}&
\multicolumn{1}{c|}{LEFT} \\ \hline
\multicolumn{1}{|c|}{test1} & 1 & 1 &1 & 1 & 1 &1\\ \hline
\multicolumn{1}{|c|}{test2} & 1 & 1 &1 & 1 & 1 &1\\ \hline
\multicolumn{1}{|c|}{test2} & 1 & 1 &1 & 1 & 1 &1\\ \hline
\end{tabular}
\end{table}
Looks like this:
I am trying to make this table to fit in the page and to increase the row size when text is too long but I didn't manage to do that.
In the above table if in a cell I insert a long text it will look like this:
Someone help me to resize my table with this:
\newcommand*{\ResizeTableIfTooBig}[1]{%
%% #1 = table
\savebox{\MyTable}{#1}%
\ifdim\wd\MyTable<\linewidth
\usebox{\MyTable}%
\else
\resizebox{\textwidth}{!}{\usebox{\MyTable}}%
\fi
}%
The problem is that this snapshot just scales the table and when text from cells is too long the font is very small.
What will help me is a table with 7 columns which will not come out of the paper and will create a new line when the text is too long for each column(without scaling font).
Something like this:
Best Answer
You can use
tabularx
to make your table fit line width: