[Tex/LaTex] Two columns stretched more than the others in tabular

tablestabularx

A year ago, I based on an example to produce a table adaptable to what I need. The table was displayed without errors when it was in a journal template. Now I moved it to another template, It went outside the page limit. So I added adjustbox but another thing happened, two columns (S4s in the picture) are more stretched than the others. Is there a way to solve this issue?

\begin{table}
\centering
\setlength\tabcolsep{2pt}
\caption{Mapping Precision of MedK} \label{tab:t3}
\begin{adjustbox}{max width=\textwidth}
\begin{tabular}{ | l | l | l | l | l | l | l | l | l | l | c | l | l | l | c | l | }
\hline
\multirow{2}{*}{Keyword}  & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}Results Requested\\per source\end{tabular}} & \multicolumn{5}{c|}{Results available} & \multicolumn{4}{c|}{Properties retrieved}& \multicolumn{4}{c|}{\begin{tabular}[c]{@{}c@{}}Properties matched\\with \end{tabular}} & \multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Overall\\Precision\end{tabular}} \\[1ex] \cline{3-15}
     &  & S1 & S2 & S3 & S4 & overall & S1 & S2 & S3 & S4 & S1 & S2 & S3 & S4 &  \\ \hline
     &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
     &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
     &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
     &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
\end{tabular}
\end{adjustbox}
\end{table}

enter image description here

Best Answer

enter image description here

\multicolumn adds all width to the last spanned column if it is wider than the columns it spans. Just put \makebox[3em]{} in one cell in each column to force a minimum width (replacing 3em by whatever is needed). Only apply scaling such as adjustbox to tables as a last resort, and even then don't do it.

But here I think if you choose a smaller font, and line-break your headings, then you shouldn't have over-sized multicolumns, something like:

\documentclass{article}
\usepackage{multirow}
\begin{document}

\begin{table}
\centering
\small
\setlength\tabcolsep{1.7pt}
\caption{Mapping Precision of MedK} \label{tab:t3}

\begin{tabular}{@{}| l | l | l | l | l | l | l | l | l | l | c | l | l | l | c | l |@{}}
\hline
\multirow{2}{*}{Keyword}  & 
\multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}Results Requested\\per source\end{tabular}} &
 \multicolumn{5}{c|}{\begin{tabular}[c]{@{}c@{}}Results\\available\end{tabular}}&
\multicolumn{4}{c|}{\begin{tabular}[c]{@{}c@{}}Properties\\retrieved\end{tabular}}&
   \multicolumn{4}{c|}{\begin{tabular}[c]{@{}c@{}}Properties\\matched\\with \end{tabular}} & 
\multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Overall\\Precision\end{tabular}} \\[1ex] \cline{3-15}
     &  & S1 & S2 & S3 & S4 & overall & S1 & S2 & S3 & S4 & S1 & S2 & S3 & S4 &  \\ \hline
     &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
     &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
     &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
     &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  \\ \hline
\end{tabular}

\end{table}
\end{document}