# Need help to adjust horizontal spaces in a table

I am making a table but i am not able to adjust it. Here is a screen shot. i have used following tex code

\begin{table}[ht]

\centering

\begin{tabular}{c c c c c c c}

\hline\hline

Methods &computing time & iterative times & $\|A X_k A - A\|_2$ & $\|X_k A X_k - X_k\|_2$  & $\|(A X_k)^* - A X_k\|_2$ & $\|(A X_k)^* - A X_k\|_2$ \\ [0.5ex]

\hline

method() & &  &  &  &  & \\

proposed method &  &  &  &  &  &  \\

\hline

\end{tabular}

\end{table}


Could anybody help me. I would be very much thankful to you.

-
What do you want to do exactly? Reduce this 0.3 cm margin (rough estimate) between each column? Because I doubt it'll be enough to make your table fit in the page width. –  T. Verron Sep 24 '12 at 13:37
@T.Verron Thanks for reply. How to do that? I am not that much good in latex. I just took some old samples and tried to apply. –  srijan Sep 24 '12 at 13:40
You can set the column separation with \setlength{\tabcolsep}{2pt}. If it doesn't work, and it probably won't, you can also reduce the font by using \small. And if it still isn't enough, you should consider rewriting your column headers in a shorter way. –  T. Verron Sep 24 '12 at 13:57

You have quite a few columns in your table, and each column header is quite wide. To make the table fit in the textblock, I suspect you'll need to

• reduce the font size used in the table slightly,
• reduce the amount of inter-column whitespace, and
• reduce the widths of columns 2 and 3 by splitting their headers over two consecutive lines.

Separately, I'd also recommend you use the commands \toprule, \midrule, and \bottomrule provided by the booktabs package and that you create a command named, say, \norm, to denote the L_2 norm expressions. By creating such a command, you'll have a much easier time in the future if you ever decide to change the appearance of the \norm function.

Finally, you didn't specify which font size, paper width, and margin widths you employ, so I've had to make some assumptions about these important parameters in the MWE below. The MWE starts with a horizontal line that spans the width of the text block to give you an idea of the value of this important parameter.

\documentclass[10pt]{article}
\usepackage[margin=1in]{geometry} % assume 1" margins
\usepackage{amsmath,booktabs}
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
\begin{document}
\noindent Width of text block:
\hrule

\begin{table}[ht]
\small % reduce font size by about 10%
\caption{My table}
\centering
\setlength\tabcolsep{2.5pt} % default value: 5pt
\begin{tabular}{@{}l *{6}{c} @{}} % remove blank spaces at ends of table
\toprule
Methods &
computing  &
iterative &
$\norm{A X_k A - A}_2$ &
$\norm{X_k A X_k - X_k}_2$  &
$\norm{(A X_k)^* - A X_k}_2$ &
$\norm{(A X_k)^* - A X_k}_2$ \\
& time & times\\
\midrule
method() & &  &  &  &  & \\
proposed method &  &  &  &  &  &  \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

-
Thank you very much sir. –  srijan Oct 1 '12 at 5:43

You can also use tabulary-package.

Here is a MWE:

\documentclass{scrartcl}
\usepackage{booktabs,tabulary}

\begin{document}
\begin{table}[ht]

\centering

\begin{tabulary}{\linewidth}{CCCCCCC}

\toprule

Methods & computing time & iterative times & $\|A X_k A - A\|_2$ & $\|X_k A X_k - X_k\|_2$  & $\|(A X_k)^* - A X_k\|_2$ & $\|(A X_k)^* - A X_k\|_2$ \\ [0.5ex]

\midrule

method() & &  &  &  &  & \tabularnewline

proposed method &  &  &  &  &  &  \tabularnewline

\bottomrule

\end{tabulary}

\end{table}

\end{document}


-
Thank you very much sir. –  srijan Oct 1 '12 at 5:43

In addition to the adjustments which were also suggested by @T.Verron, you might want to use booktabs's rules in order to allow distinguishing between the columns (especially when you set the column separation width to such a low value).

\documentclass[a4paper]{article}

\usepackage{booktabs,array}

\begin{document}
\begin{table}
\centering
\small
% manual adjustment of column separation width and cmidrule kerning
\renewcommand{\tabcolsep}{2pt}
\renewcommand{\cmidrulekern}{2pt}
\begin{tabular}{m{1.5cm} m{1.6cm} m{1.3cm} c c c c}
\toprule
Methods & computing time & iterative times & $\|A X_k A - A\|_2$ & $\|X_k A X_k - X_k\|_2$  & $\|(A X_k)^* - A X_k\|_2$ & $\|(A X_k)^* - A X_k\|_2$ \\

\cmidrule(r){1-1} \cmidrule(lr){2-2} \cmidrule(lr){3-3} \cmidrule(lr){4-4} \cmidrule(lr){5-5} \cmidrule(lr){6-6} \cmidrule(l){7-7}
method() & &  &  &  &  & \\
proposed method &  &  &  &  &  &  \\
\bottomrule
\end{tabular}
\end{table}

\end{document}


Since we now use a \tabcolsep of 2 pt, I reduced the kerning of the \cmidrules to 2 pt (the default is 0.5 em).

I also introduced m-columns to allow fixed-width cells with line-breaking (p-type columns may also suffice, but I like the vertical centering better).

-