1
\documentclass[twoside,12pt]{article}
\usepackage{tabularx,multirow,amsmath}
\begin{document}
    \begin{table}
        \centering
        \caption{The average and standard deviation of the objective function values}
        \label{table1}
        \begin{tabular}{|c|c|m{2.5cm}|c|m{2.5cm}|}
            \hline
            \multirow{2}{*}[-0.5cm]{\textbf{Data}}&\multicolumn{2}{m{5cm}|}{T\textbf{he early blight disease segmentation method based K-means method optimized by PSO}}&\multicolumn{2}{m{5cm}|}{\textbf{The early blight disease segmentation based K-means method}}\\
            \cline{2-5}
            &\textbf{Average}&\textbf{Standard deviation}&\textbf{Average}&\textbf{Standard deviation}\\
            \hline
            $1^{\text{st}}$ Data&$791.322$&$6.182E-13$&$1526.041$&$285.213$\\
            \hline
            $2^{\text{nd}}$ Data&$506.116$&$3.627E-13$&$988.944$&$404.170$\\
            \hline
            $3^{\text{rd}}$ Data&$547.935$&$2.914E-13$&$818.622$&$139.281$\\
            \hline
            $4^{\text{th}}$ Data&$2237.106$&$7.292E-13$&$3322.156$&$1110.180$\\
            \hline
            $5^{\text{th}}$ Data&$895.024$&$8.921E-13$&$2394.048$&$0.692$\\
            \hline
            $6^{\text{th}}$ Data&$3338.712$&$3.213E-12$&$5402.165$&$2583.162$\\
            \hline
            \textbf{Average}&$1386,036$&$1.018E-12$&$2408.663$&$753.783$\\
            \hline
        \end{tabular}
    \end{table}
\end{document}

enter image description here

I'm not have idea to make center the last column. Anyone can redesign my table?

  • I'd use an siunitx based layout for this kind of table to not only center the entries but to also align the numbers with respect to the decimal separator. – leandriis Nov 30 '20 at 14:11
2

You can obtain what you want with >{\centering\arraybackslash}m{2.5cm} for the last column. However I would recommend loading siunitx and using the S column type to have numbers aligned on the decimal dot. Centring the column headers will be obtained by nesting them in a pair of braces. I also would load the caption package for a decent spacing between caption and table. Last, the makecell package will simplify formatting colmun headers and allow line breaking in standard cells.

Here is a code with both solutions:

\documentclass[twoside,12pt]{article}
\usepackage{tabularx,multirow,amsmath}
\usepackage{caption, makecell}
\usepackage{siunitx}

\begin{document}

\begin{table}
    \centering
    \caption{The average and standard deviation of the objective function values}
    \label{table1}
    \begin{tabular}{|c|c|m{2.5cm}|c|>{\centering\arraybackslash}m{2.5cm}|}
        \hline
        \multirow{2}{*}[-0.5cm]{\textbf{Data}}&\multicolumn{2}{m{5cm}|}{T\textbf{he early blight disease segmentation method based K-means method optimized by PSO}}&\multicolumn{2}{m{5cm}|}{\textbf{The early blight disease segmentation based K-means method}}\\
        \cline{2-5}
        &\textbf{Average}&\textbf{Standard deviation}&\textbf{Average}&\textbf{Standard deviation}\\
        \hline
        $1^{\text{st}}$ Data&$791.322$&$6.182E-13$&$1526.041$&$285.213$\\
        \hline
        $2^{\text{nd}}$ Data&$506.116$&$3.627E-13$&$988.944$&$404.170$\\
        \hline
        $3^{\text{rd}}$ Data&$547.935$&$2.914E-13$&$818.622$&$139.281$\\
        \hline
        $4^{\text{th}}$ Data&$2237.106$&$7.292E-13$&$3322.156$&$1110.180$\\
        \hline
        $5^{\text{th}}$ Data&$895.024$&$8.921E-13$&$2394.048$&$0.692$\\
        \hline
        $6^{\text{th}}$ Data&$3338.712$&$3.213E-12$&$5402.165$&$2583.162$\\
        \hline
        \textbf{Average}&$1386,036$&$1.018E-12$&$2408.663$&$753.783$\\
        \hline
    \end{tabular}\vskip 1cm

\sisetup{table-format=4.3, table-number-alignment=center}
\renewcommand{\theadfont}{\normalsize\bfseries}
\renewcommand{\theadalign}{bc}
\setlength{\extrarowheight}{3pt}
  \begin{tabular}{|c|S|S[table-format=1.3e-2]|S| S|}%m{2.5cm}
 \hline
 \multirowcell{5.17}{\textbf{Data}}&\multicolumn{2}{c|}{\thead{The early blight disease\\ segmentation method\\ based K-means method \\ optimized by PSO}}&\multicolumn{2}{c|}{\thead{The early blight disease\\ segmentation based K-\\means method}}\\
 \cline{2-5}
 &{\thead{Average}}&{\thead{Standard\\ deviation}}& {\thead{Average}} & {\thead{Standard\\ deviation}}\\
 \hline
$1^{\text{st}}$ Data & 791.322 & 6.182e-13 & 1526.041 & 285.213 \\
 \hline
 $2^{\text{nd}}$ Data & 506.116 & 3.627e-13 & 988.944 & 404.170 \\
 \hline
 $3^{\text{rd}}$ Data & 547.935 & 2.914e-13 & 818.622 & 139.281 \\
 \hline
 $4^{\text{th}}$ Data & 2237.106 & 7.292e-13 & 3322.156 & 1110.180 \\
 \hline
 $5^{\text{th}}$ Data & 895.024 & 8.921e-13 & 2394.048 & 0.692 \\
 \hline
 $6^{\text{th}}$ Data & 3338.712 & 3.213e-12 & 5402.165 & 2583.162 \\
 \hline
 \textbf{Average}& 1386,036 & 1.018e-12 & 2408.663 & 753.783 \\
 \hline
 \end{tabular}
 \end{table}

 \end{document}

enter image description here

1

You could use >{\centering\arraybackslash}m{2.5cm}, but there are several improvements that can be done on your table.


Can anyone redesign my table?

First: never repeat information. The first column is about data, so there's no need to repeat “Data” in each row.

Second: the numbers should be aligned by their decimal separator, so they can be read and compared more easily.

Third: vertical rules are barriers that hinder the table readability. A table is not the screenshot from a worksheet, but a typographical object whose aim is to present data in the most readable format.

Fourth: long headers are distracting. Write only the relevant information. The description ought to be in the caption. It's the data that is of interest to the reader and they know what it's about because it's written in the caption.

Fifth: avoid boldfacing column headers. They already stick out by themselves.

Sixth: 1st is Victorian age silliness. Avoid it: it was revived for unknown reasons by a very widespread word processing system; apparently one of its developers had a fancy for those superscript abbreviations and made them to appear automatically, so people started to think it is the best way to write “first” and so on: it isn't.

\documentclass[twoside,12pt]{article}
\usepackage{siunitx,booktabs,caption}

\sisetup{output-decimal-marker={,}}

\begin{document}

\begin{table}
\centering
\caption[The average and standard deviation of the objective function values]
        {The average and standard deviation of the objective function values:
         early blight disease segmentation based K-means method, optimized by
         PSO (columns 2~and~3) and non optimized (columns 4~and~5)}
\label{table1}

\begin{tabular}{
  @{}
  l
  S[table-format=4.3]
  S[table-format=1.3e-2]
  S[table-format=4.3]
  S[table-format=4.3]
  @{}
}
\toprule
Data & \multicolumn{2}{c}{optimized} & \multicolumn{2}{c}{non optimized} \\
\cmidrule(lr){2-3} \cmidrule(l){4-5}
& {Average} & {\begin{tabular}{@{}c@{}}Standard \\ deviation\end{tabular}}
& {Average} & {\begin{tabular}{@{}c@{}}Standard \\ deviation\end{tabular}}
\\
\midrule
1st     &  791.322 & 6.182E-13 & 1526.041 &  285.213 \\
2nd     &  506.116 & 3.627E-13 &  988.944 &  404.170 \\
3rd     &  547.935 & 2.914E-13 &  818.622 &  139.281 \\
4th     & 2237.106 & 7.292E-13 & 3322.156 & 1110.180 \\
5th     &  895.024 & 8.921E-13 & 2394.048 &    0.692 \\
6th     & 3338.712 & 3.213E-12 & 5402.165 & 2583.162 \\
\midrule
Average & 1386,036 & 1.018E-12 & 2408.663 &  753.783 \\
\bottomrule
\end{tabular}

\end{table}

\end{document}

enter image description here

If you remove the \sisetup line, the numbers will automatically have a decimal point independently on how you input them; with the line you get a decimal comma. This will happen in every table where you use S columns.

enter image description here

If you prefer the 6.182E-13 format, use

\sisetup{output-exponent-marker=\mathrm{E}}

and the output will become

enter image description here

Again, this will happen in all tables where you use S columns.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.