# How to create a table like the following picture?

How to create a table like the following picture? I read latex table styles post in here. But I don' t find.

begin{tabular}{||c|c|c|c|c|c|c|}
\hline \hline$x$ & $t$ & Exact solution $u(x, t)$ & $u_{4}(x, t)$ & HPM and DTM $u_{4}(x, t)$ & Abssolute error $u_{4}(x, t)$ & Abssolute error HPM and DTM $u_{4}(x, t)[17,18]$ \\
\hline 0.25 & 0.25 & $3.2101 \cdot 10^{-1}$ & $3.2101 \cdot 10^{-1}$ & $3.21004 \cdot 10^{-1}$ & $5.7849 \cdot 10^{-7}$ & $2.1224 \cdot 10^{-6}$ \\
\hline 0.25 & 0.5 & $4.1218 \cdot 10^{-1}$ & $4.1216 \cdot 10^{-1}$ & $4.12109 \cdot 10^{-1}$ & $2.00 \cdot 10^{-5}$ & $7.09427 \cdot 10^{-5}$ \\
\hline 0.25 & 0.75 & $5.2925 \cdot 10^{-1}$ & $5.2909 \cdot 10^{-1}$ & $5.28687 \cdot 10^{-1}$ & $1.6439 \cdot 10^{-4}$ & $5.63481 \cdot 10^{-4}$ \\
\hline 0.25 & $1 .$ & $6.7957 \cdot 10^{-1}$ & $6.7882 \cdot 10^{-1}$ & $6.77083 \cdot 10^{-1}$ & $7.5129 \cdot 10^{-4}$ & $2.48712 \cdot 10^{-3}$ \\
\hline 0.5 & 0.25 & $6.4201 \cdot 10^{-1}$ & $6.4201 \cdot 10^{-1}$ & $6.42008 \cdot 10^{-1}$ & $1.157 \cdot 10^{-6}$ & $4.2448 \cdot 10^{-6}$ \\
\hline 0.5 & 0.5 & $8.2436 \cdot 10^{-1}$ & $8.2432 \cdot 10^{-1}$ & $8.24219 \cdot 10^{-1}$ & $4.00 \cdot 10^{-5}$ & $1.41885 \cdot 10^{-4}$ \\
\hline 0.5 & 0.75 & 1.0585 & 1.0582 & 1.05737 & $3.2879 \cdot 10^{-4}$ & $1.12696 \cdot 10^{-3}$ \\
\hline 0.5 & $1 .$ & 1.3591 & 1.3576 & 1.35417 & $1.5026 \cdot 10^{-3}$ & $4.97425 \cdot 10^{-3}$ \\
\hline 0.75 & 0.25 & $9.6302 \cdot 10^{-1}$ & $9.6302 \cdot 10^{-1}$ & $9.63013 \cdot 10^{-1}$ & $1.7355 \cdot 10^{-6}$ & $6.3672 \cdot 10^{-6}$ \\
\hline 0.75 & 0.5 & 1.2365 & 1.2365 & 1.23633 & $6.00 \cdot 10^{-5}$ & $2.12828 \cdot 10^{-4}$ \\
\hline 0.75 & 0.75 & 1.5878 & 1.5873 & 1.58606 & $4.9318 \cdot 10^{-4}$ & $1.69044 \cdot 10^{-3}$ \\
\hline 0.75 & $1 .$ & 2.0387 & 2.0365 & 2.03125 & $2.2539 \cdot 10^{-3}$ & $7.46137 \cdot 10^{-3}$ \\
\hline $1 .$ & 0.25 & 1.284 & 1.284 & 1.28402 & $2.314 \cdot 10^{-6}$ & $8.4896 \cdot 10^{-6}$ \\
\hline $1 .$ & 0.5 & 1.6487 & 1.6486 & 1.64844 & $8.00 \cdot 10^{-5}$ & $2.83771 \cdot 10^{-4}$ \\
\hline $1 .$ & 0.75 & 2.117 & 2.1163 & 2.11475 & $6.5758 \cdot 10^{-4}$ & $2.25392 \cdot 10^{-3}$ \\
\hline $1 .$ & $1 .$ & 2.7183 & 2.7153 & 2.70833 & $3.0052 \cdot 10^{-3}$ & $9.9485 \cdot 10^{-3}$ \\
\hline
\end{tabular}


• Take a look at the hline package for the double outer border and the colortbl package for the gray background in the first column. – leandriis May 30 at 5:43
• Try with \usepackage{hhline} and  \hhline{|t:==:t:==:t:==:t|}... – MadyYuvi May 30 at 6:07

This may or may not be a start. It does look similar to the target output.

\documentclass{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{makecell}
% \usepackage{siunitx} %<- consider using
\begin{document}
\begin{table}
\centering
\begingroup\setlength{\fboxsep}{1pt}
\fbox{\begin{tabular}{|c|c|c|c|c|c|c|}
\hline\rowcolor{gray!30}
$x$ & $t$ & \makecell{Exact solution\\ $u(x, t)$} & $u_{4}(x, t)$ &
\makecell{HPM and DTM\\ $u_{4}(x, t)$} & \makecell{Absolute error\\ $u_{4}(x, t)$} & \makecell{Absolute error HPM and\\ DTM $u_{4}(x, t)[17,18]$} \\[2ex]
\hline 0.25 & 0.25 & $3.2101 \cdot 10^{-1}$ & $3.2101 \cdot 10^{-1}$ & $3.21004 \cdot 10^{-1}$ & $5.7849 \cdot 10^{-7}$ & $2.1224 \cdot 10^{-6}$ \\
\hline 0.25 & 0.5 & $4.1218 \cdot 10^{-1}$ & $4.1216 \cdot 10^{-1}$ & $4.12109 \cdot 10^{-1}$ & $2.00 \cdot 10^{-5}$ & $7.09427 \cdot 10^{-5}$ \\
\hline 0.25 & 0.75 & $5.2925 \cdot 10^{-1}$ & $5.2909 \cdot 10^{-1}$ & $5.28687 \cdot 10^{-1}$ & $1.6439 \cdot 10^{-4}$ & $5.63481 \cdot 10^{-4}$ \\
\hline 0.25 & $1 .$ & $6.7957 \cdot 10^{-1}$ & $6.7882 \cdot 10^{-1}$ & $6.77083 \cdot 10^{-1}$ & $7.5129 \cdot 10^{-4}$ & $2.48712 \cdot 10^{-3}$ \\
\hline 0.5 & 0.25 & $6.4201 \cdot 10^{-1}$ & $6.4201 \cdot 10^{-1}$ & $6.42008 \cdot 10^{-1}$ & $1.157 \cdot 10^{-6}$ & $4.2448 \cdot 10^{-6}$ \\
\hline 0.5 & 0.5 & $8.2436 \cdot 10^{-1}$ & $8.2432 \cdot 10^{-1}$ & $8.24219 \cdot 10^{-1}$ & $4.00 \cdot 10^{-5}$ & $1.41885 \cdot 10^{-4}$ \\
\hline 0.5 & 0.75 & 1.0585 & 1.0582 & 1.05737 & $3.2879 \cdot 10^{-4}$ & $1.12696 \cdot 10^{-3}$ \\
\hline 0.5 & $1 .$ & 1.3591 & 1.3576 & 1.35417 & $1.5026 \cdot 10^{-3}$ & $4.97425 \cdot 10^{-3}$ \\
\hline 0.75 & 0.25 & $9.6302 \cdot 10^{-1}$ & $9.6302 \cdot 10^{-1}$ & $9.63013 \cdot 10^{-1}$ & $1.7355 \cdot 10^{-6}$ & $6.3672 \cdot 10^{-6}$ \\
\hline 0.75 & 0.5 & 1.2365 & 1.2365 & 1.23633 & $6.00 \cdot 10^{-5}$ & $2.12828 \cdot 10^{-4}$ \\
\hline 0.75 & 0.75 & 1.5878 & 1.5873 & 1.58606 & $4.9318 \cdot 10^{-4}$ & $1.69044 \cdot 10^{-3}$ \\
\hline 0.75 & $1 .$ & 2.0387 & 2.0365 & 2.03125 & $2.2539 \cdot 10^{-3}$ & $7.46137 \cdot 10^{-3}$ \\
\hline $1 .$ & 0.25 & 1.284 & 1.284 & 1.28402 & $2.314 \cdot 10^{-6}$ & $8.4896 \cdot 10^{-6}$ \\
\hline $1 .$ & 0.5 & 1.6487 & 1.6486 & 1.64844 & $8.00 \cdot 10^{-5}$ & $2.83771 \cdot 10^{-4}$ \\
\hline $1 .$ & 0.75 & 2.117 & 2.1163 & 2.11475 & $6.5758 \cdot 10^{-4}$ & $2.25392 \cdot 10^{-3}$ \\
\hline $1 .$ & $1 .$ & 2.7183 & 2.7153 & 2.70833 & $3.0052 \cdot 10^{-3}$ & $9.9485 \cdot 10^{-3}$ \\
\hline
\end{tabular}}\endgroup
\end{table}
\end{document}


If one creates a table with lots and lots of vertical and horizontal lines, some of which are supposed to be doubled, it's very easy to create the impression of a high-security prison for them pesky numbers -- the reader's eye dare not enter this prison, to avoid getting stuck there forever. I'd like to suggest that you for a much more "open" look, by omitting all vertical lines and employing far fewer, but better spaced, horizontal lines. This can be done by replacing \hline and \cline with the line-drawing macros of the booktabs package.

I would also like to suggest that you employ the machinery of the siunitx package -- specifically, its S column type -- to typeset the numbers; I'd provide some more explicit structure to the header material and, last but not least, I'd employ a tabularx environment to allow automatic line breaking, as needed, of the material in the header cells.

Here, then, is my proposed solution:

\documentclass{article} % or some other suitable document class
\usepackage{booktabs} % for \toprule, \midrule, \bottomrule etc macros
\usepackage{siunitx} % for 'S' column type
\newcolumntype{T}[1]{S[table-format=#1,
tight-spacing=true,exponent-product=\cdot,
round-mode=places,round-precision=4]}
\usepackage{tabularx,ragged2e}
\newcolumntype{C}{>{\Centering}X} % centered version of 'X' column type
\newcommand\mC[1]{\multicolumn{1}{C}{#1}} % handy shortcut macro

\usepackage{newtxtext,newtxmath} % optional
\usepackage{caption}
\captionsetup{skip=0.333\baselineskip,font=bf} % captions in bold

\begin{document}

\begin{table}[htbp]
\setlength\tabcolsep{4pt}  % default: 6pt
\caption{\boldmath Comparison fourth solution of FVIM for $\alpha=1$
with those obtained by HPM and DTM}
\begin{tabularx}{\textwidth}{@{} *{2}{S[table-format=1.2]} *{5}{T{1.4e-1}} @{}}
\toprule
$x$ & $t$
&\multicolumn{3}{c}{Solutions}
&\multicolumn{2}{c@{}}{Absolute error}\\
\cmidrule(lr){3-5}\cmidrule(l){6-7}
&& \mC{Exact solution $u(x, t)$}
&  \mC{$u_{4}(x, t)$}
&  \mC{HPM and DTM $u_{4}(x, t)$}
&  \mC{$u_{4}(x, t)$}
&  \multicolumn{1}{C@{}}{HPM and DTM $u_{4}(x, t)$ [17, 18]} \\
\midrule
0.25 & 0.25 & 3.2101e-1 & 3.2101e-1 & 3.21004e-1 & 5.7849e-7 & 2.1224e-6 \\
0.25 & 0.5  & 4.1218e-1 & 4.1216e-1 & 4.12109e-1 & 2.00e-5 & 7.09427e-5 \\
0.25 & 0.75 & 5.2925e-1 & 5.2909e-1 & 5.28687e-1 & 1.6439e-4 & 5.63481e-4 \\
0.25 & 1.   & 6.7957e-1 & 6.7882e-1 & 6.77083e-1 & 7.5129e-4 & 2.48712e-3 \\
0.5  & 0.25 & 6.4201e-1 & 6.4201e-1 & 6.42008e-1 & 1.157e-6 & 4.2448e-6 \\
0.5  & 0.5  & 8.2436e-1 & 8.2432e-1 & 8.24219e-1 & 4.00e-5 & 1.41885e-4 \\
0.5  & 0.75 & 1.0585 & 1.0582 & 1.05737 & 3.2879e-4 & 1.12696e-3 \\
0.5  & 1.   & 1.3591 & 1.3576 & 1.35417 & 1.5026e-3 & 4.97425e-3 \\
0.75 & 0.25 & 9.6302e-1 & 9.6302e-1 & 9.63013e-1 & 1.7355e-6 & 6.3672e-6 \\
0.75 & 0.5  & 1.2365 & 1.2365 & 1.23633 & 6.00e-5 & 2.12828e-4 \\
0.75 & 0.75 & 1.5878 & 1.5873 & 1.58606 & 4.9318e-4 & 1.69044e-3 \\
0.75 & 1.   & 2.0387 & 2.0365 & 2.03125 & 2.2539e-3 & 7.46137e-3 \\
1.   & 0.25 & 1.284 & 1.284 & 1.28402 & 2.314e-6 & 8.4896e-6 \\
1.   & 0.5  & 1.6487 & 1.6486 & 1.64844 & 8.00e-5 & 2.83771e-4 \\
1.   & 0.75 & 2.117 & 2.1163 & 2.11475 & 6.5758e-4 & 2.25392e-3 \\
1.   & 1.   & 2.7183 & 2.7153 & 2.70833 & 3.0052e-3 & 9.9485e-3 \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}

• IMHO this looks definitely better than what I got. – user194703 May 30 at 7:37
• To be very honest: I think such tables get read at best by a handful of people. What I want to say is that somewhere there is some data in an electronic format, and one can use it in one way or another to draw conclusions from it. I do not think that many will print this out and look at every digit. But I may be wrong. – user194703 May 30 at 7:59
• @Schrödinger'scat - Fully agreed. My cynical view is that a well-designed table will be remembered by, say, 10 readers; a poorly-designed table will not be remembered by anyone... The OP can certainly improve the odds of the table making a lasting impression by showing a surface plot alongside the table. In addition, the OP better provide a brief but clear presentation of the main points that readers are supposed to remember about the table. Just telling the readers, "Hey, there's a table over there with lots and lots of numbers -- go figure out what the numbers mean", is not going to cut it. – Mico May 30 at 8:33
• I did not mean to imply that the exercise is useless. After all we do look at online tables in newspapers and so on, so somewhere one needs to be able to learn and develop these skills. The same statement apply, of course, to all these plots and graphs. Many of them will be buried in some thesis. Nonetheless is it useful to be ready to go when one really needs to produce one that goes in a paper. – user194703 May 30 at 8:49
• @Schrödinger'scat -- I suppose we wouldn't be having this discussion if we thought the exercise was useless -- because then we wouldn't have bothered posting answers, right? – Mico May 30 at 9:22