[Tex/LaTex] Column too wide in longtable

column widthlongtable

I am a beginner in LaTeX and have to make some very sophisticated tables in it. I use help from TeX.SE to complete the jobs of drawing these difficult tables.

This time I have been stuck with a table: Everything is working fine except a column (no. 8) is too wide. I have tried some tricks but nothing worked this time. Can anybody please help me to fix this problem?

\documentclass[a4paper,10pt]{article} 

\usepackage{graphicx}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{pdflscape}
\usepackage{footnote}

\begin{document}
\begin{landscape}
\begin{center}
\begin{savenotes}
{\renewcommand{\arraystretch}{1.1}
\begin{longtable}{|*{4}{c@{\hskip1pt}|}|*{4}{c@{\hskip1pt}|}|*{1}{c@{\hskip1pt}|}|*{3}{c@{\hskip1pt}|}|*{3}{c@{\hskip1pt}|}|*{1}{c@{\hskip1pt}|}}
\hline

{\bf \multirow{3}{*}{\rotatebox[origin=c]{90}{Nodes}}}& {\bf \multirow{3}{*}{\rotatebox[origin=c]{90}{Clusters}}}& \multirow{3}{1cm}{${|E^*|}$}& \multirow{3}{1.2cm}{\bf{\%age gap of} ${|E_{heu}|}$}& \multicolumn{4}{c|}{\bf \small Percentage of Clusters removed by}& \multirow{3}{1.4cm}{\small \bf No. of nodes removed}& \multicolumn{7}{c|}{\bf \small Time for computing solution (in seconds)}  \\\cline{5-8} \cline{10-16}


 & & &  & \multirow{2}{1cm}{Red 1\&2}& \multirow{2}{1cm}{Red 3}& \multirow{2}{1cm}{Red 4}& \multirow{2}{1cm}{Red 5}& & \multicolumn{3}{c|}{\bf {Before reductions}}& \multicolumn{3}{c|}{\bf {After reductions}}& \multirow{2}{1cm}{\bf {heu}}\\\cline{10-15}

& & &  &  & & & & & inr & rf-inr & imp & inr & rf-inr& imp&  \\\hline


\multirow{3}{*}{6}& 6& 6.00& 0.00& 31.67& 16.67& 0.00& 0.00& 2.80& 0.03& 0.02& 0.02& 0.00& 0.01& 0.01& 0.01\\
  & 18& 8.40& 7.14& 1.67& 42.78& 0.00& 0.00& 0.10& 0.03& 0.04& 0.03& 0.02& 0.02& 0.02& 0.02\\
  & 30& 10.40& 2.88& 0.00& 56.00& 0.67& 0.00& 0.00& 0.06& 0.05& 0.05& 0.02& 0.02& 0.02& 0.03\\\hline
\multirow{3}{*}{8}& 8& 8.00& 1.25& 37.50& 16.25& 0.00& 0.00& 4.30& 0.06& 0.06& 0.03& 0.01& 0.01& 0.01& 0.01\\
  & 24& 12.10& 9.09& 0.00& 37.08& 0.00& 0.00& 0.00& 0.11& 0.09& 0.07& 0.05& 0.05& 0.04& 0.03\\
  & 40& 14.60& 12.33& 0.00& 50.25& 0.00& 0.00& 0.00& 0.23& 0.13& 0.10& 0.06& 0.05& 0.04& 0.06\\\hline

\end{longtable}
}
\end{savenotes}
\end{center}
\end{landscape}
\end{document}

See the attached image

Best Answer

I would like to suggest that you streamline and simplify much of the code in the longtable environment. I would also like to suggest that you not use boldface at all; it's not needed -- really. Double vertical lines aren't needed either.

enter image description here

\documentclass[a4paper,10pt]{article} 

\usepackage{graphicx}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{pdflscape} % for 'landscape' env.
\usepackage{footnote}  % for 'savenotes' env. 

\begin{document}
\begin{landscape}
\centering
\begin{savenotes}
\renewcommand{\arraystretch}{1.1}
\setlength\tabcolsep{4pt}
\begin{longtable}{|*{16}{c|}}
\hline

\multirow{3}{*}{\rotatebox[origin=c]{90}{Nodes}}& 
\multirow{3}{*}{\rotatebox[origin=c]{90}{Clusters}} & 
\multirow{3}{*}{$|E^*|$}& 
   \multirow{3}{1.2cm}{{\% age gap of $|E_{heu}|$}}& 
   \multicolumn{4}{c|}{\small Percent.\ of clusters removed by}& 
   \multirow{3}{1.3cm}{\small No.\ of nodes removed}& 
   \multicolumn{7}{c|}{\small Time for computing solution (in seconds)}  \\
   \cline{5-8} \cline{10-16}
 & & & & 
 \multirow{2}{1cm}{Red 1\&2}& 
 \multirow{2}{1cm}{Red 3}& 
 \multirow{2}{1cm}{Red 4}& 
 \multirow{2}{1cm}{Red 5}& & 
 \multicolumn{3}{c|}{\small Before reductions}& 
 \multicolumn{3}{c|}{\small After reductions}& 
 \multirow{2}{*}{heu}\\
 \cline{10-15}
& & & & & & & & & inr & rf-inr & imp & inr & rf-inr& imp & \\
\hline\hline
\endhead

\hline
\endfoot

\multirow{3}{*}{6}& 6& 6.00& 0.00& 31.67& 16.67& 0.00& 0.00& 2.80& 0.03& 0.02& 0.02& 0.00& 0.01& 0.01& 0.01\\
  & 18& 8.40& 7.14& 1.67& 42.78& 0.00& 0.00& 0.10& 0.03& 0.04& 0.03& 0.02& 0.02& 0.02& 0.02\\
  & 30& 10.40& 2.88& 0.00& 56.00& 0.67& 0.00& 0.00& 0.06& 0.05& 0.05& 0.02& 0.02& 0.02& 0.03\\
\hline
\multirow{3}{*}{8}& 8& 8.00& 1.25& 37.50& 16.25& 0.00& 0.00& 4.30& 0.06& 0.06& 0.03& 0.01& 0.01& 0.01& 0.01\\
  & 24& 12.10& 9.09& 0.00& 37.08& 0.00& 0.00& 0.00& 0.11& 0.09& 0.07& 0.05& 0.05& 0.04& 0.03\\
  & 40& 14.60& 12.33& 0.00& 50.25& 0.00& 0.00& 0.00& 0.23& 0.13& 0.10& 0.06& 0.05& 0.04& 0.06\\
\end{longtable}
\end{savenotes}
\end{landscape}
\end{document}
Related Question