[Tex/LaTex] Making a nice table

tables

I have made following table which is not looking elegant. Could anybody help me in making it more better. Following is the tex code that I have used.

\documentclass[12pt]{article}
\usepackage{latexsym}
\usepackage{amsmath, times, amsfonts, mathrsfs, amssymb}
\usepackage{amsmath, times, amsfonts, mathrsfs, amssymb}
\begin{document}
\begin{table}[htbp]
\small \caption{\small Computation of number of iterations and error norms for Example 4.2:}
\centering
\begin{tabular}{c c c c c c c}
\hline
 Value of $\beta$ &  $k$  & $\|A^{-1} - X_{k}\|_2$ & $\|X_k  - X_{k-1}\|_2$   \\ [0.3ex] % inserts table
 &  & & &   &  & \\
 %
\hline
 0.9  & 0  &  0.489897948556636  & 0.462668212869655  \\
 & 1 &   0.044911860348910 & 0.044385148438250 \\
 & 2 &  6.418447480230614e-004 & 6.417891668548070e-004  \\
 & 3 &   5.683044758299918e-008 &   5.683044739894235e-008  \\
 & 4 &   1.861900614935455e-016 &   1.861900614935455e-016  \\
 & 5 &   0 &   0 \\  [1ex]
\hline
\end{tabular}
\label{table:nonlin}
\end{table}
\end{document}

After running it looks like this

Best Answer

This seems a job for booktabs and siunitx. The first provides good horizontal rules with appropriate spacing, the second is specialized in typesetting numbers with or without units of measure.

Type S columns make alignments at the decimal point; one can specify the number format:

table-format=1.15

means one digit for the integer part and 15 for the fractional part;

table-figures-exponent=2

means "keep two digits for the exponent";

table-sign-exponent=true

means that the exponent can be negative.

\documentclass[12pt]{article}
\usepackage{amsmath,amsfonts,mathrsfs,amssymb}
\usepackage{newtxtext,newtxmath} % better than "times"
\usepackage{booktabs} % pretty tables
\usepackage{siunitx}  % number formatting

\begin{document}

\begin{table}[htbp]
\centering\small 

\caption{Computation of number of iterations and error norms for Example 4.2}
\medskip

\begin{tabular}{
  c
  c
  *{2}{
   S[table-format=1.15,
     table-figures-exponent=2,
     table-sign-exponent=true]
  }
}
\toprule
Value of $\beta$ &
  $k$ &
  {$\|A^{-1} - X_{k}\|_2$} &
  {$\|X_k  - X_{k-1}\|_2$} \\
\midrule
0.9 & 0 &  0.489897948556636      & 0.462668212869655      \\
    & 1 &  0.044911860348910      & 0.044385148438250      \\
    & 2 &  6.418447480230614e-004 & 6.417891668548070e-004 \\
    & 3 &  5.683044758299918e-008 & 5.683044739894235e-008 \\
    & 4 &  1.861900614935455e-016 & 1.861900614935455e-016 \\
    & 5 &  0                      & 0                      \\
\bottomrule
\end{tabular}
\label{table:nonlin}
\end{table}
\end{document}

enter image description here