# Automatically adjusting the size table cells

Is it possible to automatically adjust the size table cells according to their content, or to make the size of all cells uniform ?

This is an example:

\begin{table}[t]
\center
\footnotesize
\caption{resultsss}
\label{labss}
\begin{tabular}{ c c }

\begin{tabular}{ | c || c | c | c | c | } \hline
\multicolumn{4}{|c|}{\textbf{a text over here a text over here}} \\ \hline
\textit{Method 1} & 19923 & 123 & 123 \\ \hline
\textit{Method 2} & 1203 & 123 & 123 \\ \hline
\end{tabular}

&

\begin{tabular}{ | c || c | c | c | c | } \hline
\multicolumn{5}{|c|}{\textbf{another text over here}} \\ \hline
\textit{Method 1} & 789 & 789 & 789 & 789 \\ \hline
\textit{Method 2} & 789 & 789 & 789 & 789 \\ \hline
\end{tabular}

\end{tabular}
\end{table}

-
Please always post complete documemts not just fragments. –  David Carlisle Jul 10 '12 at 15:23

If \multicolumn span is wider than the columns it spans then all the extra width goes into the last spanned column. This is a feature of the underlying \halign primitive. One solution is to make the intercolumn space wider but shrinkable so that the default sum of the column widths is always greater then the span width. this looks better though if you don't have vertical lines.

I also corrected the \center to \centering and added a necessary preamble.

\documentclass{article}

\begin{document}

\begin{table}[t]
\centering
\footnotesize
\caption{resultsss}
\label{labss}
\begin{tabular}{ c c }

\begin{tabular*}{.5\textwidth}{ @{\extracolsep{\textwidth minus \textwidth}}| c || c | c | c |@{} } \hline
\multicolumn{4}{@{}|c|@{}}{\textbf{a text over here a text over here}}\\ \hline
\textit{Method 1} & 19923 & 123 & 123 \\ \hline
\textit{Method 2} & 1203 & 123 & 123 \\ \hline
\end{tabular*}

&

\begin{tabular}{ | c || c | c | c | c | } \hline
\multicolumn{5}{|c|}{\textbf{another text over here}} \\ \hline
\textit{Method 1} & 789 & 789 & 789 & 789 \\ \hline
\textit{Method 2} & 789 & 789 & 789 & 789 \\ \hline
\end{tabular}

\end{tabular}
\end{table}

\end{document}

-

I'm not entirely sure what you mean by your question whether it's possible to "make the size of all cells uniform": Do you want the column widths to be uniform within a group of columns of a given table, or do you want all columns to be equally wide across all columns of both tables?

In the example below I'm assuming that you want the former. As a result of using two tabularx environments, the first columns of the two tables are equally wide, the three data columns of the first table have equal widths, and the four data columns of the second table have equal width. I hope this is what you're looking for.

\documentclass{article}
\usepackage{tabularx}
\begin{document}
\begin{table}[t]
\footnotesize % Also possible: \small
\caption{Results}
\label{labss}
\begin{tabularx}{0.48\textwidth}{| l || *{3}{>{\centering\arraybackslash}X|}} \hline
\multicolumn{4}{|c|}{\textbf{a text over here a text over here}} \\  \hline
\textit{Method 1} & 19923 & 123 & 123 \\  \hline
\textit{Method 2} & 1203 & 123 & 123 \\  \hline
\end{tabularx}
\hspace*{\fill} % spread the two tables as far apart as is possible
\begin{tabularx}{0.48\textwidth}{| l || *{4}{>{\centering\arraybackslash}X|}} \hline
\multicolumn{5}{|c|}{\textbf{another text over here}} \\ \hline
\textit{Method 1} & 789 & 789 & 789 & 789 \\ \hline
\textit{Method 2} & 789 & 789 & 789 & 789 \\ \hline
\end{tabularx}
\end{table}
\end{document}


-
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.9999860525131226, "perplexity": 622.8759324087401}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2014-10/segments/1394678686979/warc/CC-MAIN-20140313024446-00098-ip-10-183-142-35.ec2.internal.warc.gz"}