2
    \documentclass[final,3p,times,authoryear]{elsarticle}          
      \usepackage{amssymb}
       \usepackage{multirow}
       \usepackage{amsmath}  
      \usepackage[linesnumbered,ruled]{algorithm2e}
   \usepackage[noend]{algpseudocode}
\usepackage{tikz, graphicx}
\usepackage[export]{adjustbox}
\usepackage{tabularx}
\usepackage{subcaption}
\usepackage{natbib}
\usepackage{siunitx}
\usepackage{cite}

\setcitestyle{square,numbers,comma,sort&compress}
\makeatletter
\renewcommand{\fnum@figure}{Fig. \thefigure}
\makeatother
%\usepackage[top=2.5cm, bottom=1.8cm,left=2.5cm]{geometry}
\usepackage{booktabs}
\journal{AA}
\begin{document}
   \begin{table}[!htbp]
   \caption{AAAA}
   \label{XXXXX}
    \setlength\tabcolsep{0pt}
    \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
             ll
            S[table-format=1.4]
       *{5}{S[table-format=-1.4]}
                        }
     \toprule
      \multirow{2}{*}[-1ex]{A} % "[-1ex]" correction of the vertical 
           position of cell content.
                     % it is required because of the use of lines from 
       "booktabs"
       & \multirow{2}{*}[-1ex]{B}
         & {\multirow{2}{*}[-1ex]{C}
                    & \multicolumn{5}{c}{D}                 \\
       \cmidrule{4-8}
       &   &        & {dd}     & {ddd}     &   
      {ddd}   & {dddd}  & {Proposed}      \\
      \midrule
        \multirow{3}{*}{XZA}
        & Vertical & 0.9085 & -0.0090 & -0.0035 & -0.0181 &  0.0061 & 
       -0.0029  \\
        & Horizontal  & 0.9376 & -0.0002 &  0.0011 & -0.0164 &  0.0180 &  
          0.0021  \\
        & Diagonal & 0.8635 & -0.0066 & -0.0029 &  0.0004 & -0.0079 &   
        0.0006  \\
       \end{tabular*}
       \end{table}
 \end{document}

I want the border lines in this table, what should be done, can somebody help, I am getting overbull hbox, how can i fix this?

  • Welcome to TeX - LaTeX! Please complete your code snippet to a minimal document including \documentclass so that others can compile this. Also please see the booktabs package documentation for good advice about styling of tables. – Andrew Swann Apr 25 '18 at 7:52
  • What you mean by "border lines". Vertical lines, maybe? Please elaborate. – Mico Apr 25 '18 at 8:03
  • your edited code is still not complete. i cant compile it. and please, preserve your original table code, not mix with solutions from answers. with this make received answers irrelevant (what for your original code are not). – Zarko Apr 25 '18 at 13:22
5
  • i wouldn't draw vertical lines. specially not in combination with rules from the package booktabs. it will become ugly (to my taste).
  • your table is not consistent. the first row is not complete (in mwe below i change number of columns spanned by \multicolumn{5}{c}{D}
  • for columns with number i would use column type S from package siunitx

\documentclass[final,3p,times,authoryear]{elsarticle}
\journal{AA}
%\usepackage[top=2.5cm, bottom=1.8cm,left=2.5cm]{geometry}

\usepackage{booktabs, multirow}
\usepackage{siunitx}

\begin{document}
\begin{table}[!htbp]
\setlength\tabcolsep{0pt}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                ll
                S[table-format=1.4]
           *{5}{S[table-format=-1.4]}
                            }
    \toprule
\multirow{2}{*}[-1ex]{A} % "[-1ex]" correction of the vertical position of cell content.  
                         % it is required because of the use of lines from "booktabs"
    & \multirow{2}{*}[-1ex]{B} 
             & {\multirow{2}{*}[-1ex]{C}}       
                        & \multicolumn{5}{c}{D}                 \\
    \cmidrule{4-8}
&   &        & {Q}     & {R}     & {s}     & {T}     & {P}      \\
    \midrule
\multirow{3}{*}{AA}
& H & 0.9376 & -0.0002 &  0.0011 & -0.0164 &  0.0180 &  0.0021  \\
& V & 0.9085 & -0.0090 & -0.0035 & -0.0181 &  0.0061 & -0.0029  \\
& D & 0.8635 & -0.0066 & -0.0029 &  0.0004 & -0.0079 &  0.0006  \\
    \bottomrule
\end{tabular*}
    \end{table}
see my splendid table \ref{XXXXX}.

\end{document}

which gives

enter image description here

  • however, if you like to have cell contents in "prison", than you can do this with:

\documentclass{article}
\usepackage{multirow}
\usepackage{siunitx}

\begin{document}
\begin{table}[!htbp]
\centering
\setlength\extrarowheight{2pt}
\begin{tabular}{|l|l||S[table-format=1.4]|
                 *{5}{S[table-format=-1.4]|}}
    \hline
\multirow{2}{*}[-0.5ex]{A}   
    & \multirow{2}{*}[-0.5ex]{B} 
             & {\multirow{2}{*}[-0.5ex]{C}}       
                        & \multicolumn{5}{c|}{D}                 \\
    \cline{4-8}
&   &        & {Q}     & {R}     & {s}     & {T}     & {P}      \\
    \hline
\multirow{3}{*}{AA}
& H & 0.9376 & -0.0002 &  0.0011 & -0.0164 &  0.0180 &  0.0021  \\
    \cline{2-8}
& V & 0.9085 & -0.0090 & -0.0035 & -0.0181 &  0.0061 & -0.0029  \\
    \cline{2-8}
& D & 0.8635 & -0.0066 & -0.0029 &  0.0004 & -0.0079 &  0.0006  \\
    \hline
\end{tabular}
    \end{table}
\end{document}

enter image description here

edit after your editing of question, my above answer (considered your document preamble) gives

enter image description here

this table looks ugly to me. would turn it into the next form:

enter image description here

\documentclass[final,3p,times,authoryear]{elsarticle}
\journal{AA}
%\usepackage[top=2.5cm, bottom=1.8cm,left=2.5cm]{geometry}
\usepackage{booktabs, multirow}
\usepackage{siunitx}

\begin{document}
   \begin{table}[!htbp]
\caption{AAAA}
\label{XXXXX}
    \centering
\begin{tabular}{ll
                S[table-format=1.4]
           *{5}{S[table-format=-1.4]}
                            }
    \toprule
\multirow{2}{*}[-1ex]{A}
    & \multirow{2}{*}[-1ex]{B}
             & {\multirow{2}{*}[-1ex]{C}}
                        & \multicolumn{5}{c}{D}                 \\
    \cmidrule{4-8}
&   &        & {Q}     & {R}     & {s}     & {T}     & {P}      \\
    \midrule
\multirow{3}{*}{AA}
& H & 0.9376 & -0.0002 &  0.0011 & -0.0164 &  0.0180 &  0.0021  \\
& V & 0.9085 & -0.0090 & -0.0035 & -0.0181 &  0.0061 & -0.0029  \\
& D & 0.8635 & -0.0066 & -0.0029 &  0.0004 & -0.0079 &  0.0006  \\
    \bottomrule
\end{tabular}
    \end{table}
see my splendid table \ref{XXXXX}.
\end{document}

as you can see, in the both cases referencing of table works!

  • +1. In the first example, I'd be tempted to replace *{6}{S[table-format=-1.4] with S[table-format=1.4]*{5}{S[table-format=-1.4] for ever-so-slightly tighter spacing. – Mico Apr 25 '18 at 11:06
  • @Mico, thank you very much to pointed me on this ... in the second table i use such a column setting, apparently i forgot to correct this in the first table :-(. corrected now! – Zarko Apr 25 '18 at 11:41
  • i can't refer this table in my text, how can i refer it? is it because of table* – Upstart Apr 25 '18 at 11:50
  • 1
    @Upstart, for referencing you need to add \caption{...} and label{...} to table, which should be in table float environment. bot are not given in your mwe, so i didn't consider this in my answer. – Zarko Apr 25 '18 at 11:54
  • 2
    @Upstart, first you need to provide mwe, a complete small document which we can compile and see what is your problem. please edit your question. otherwise, we can only guess, but we can't really help you. – Zarko Apr 25 '18 at 12:10
0

If I understand your question correctly, this is what you want:

\begin{tabular}{|llrrrrrr|}

The change will create a left and right border outline.

See also this question for more info on table formatting: Table Border Options

  • Welcome to the site! It's generally preferred to include full examples with screen shots, if appropriate. Zarko's answer follows this model, for example – cmhughes Apr 25 '18 at 10:24

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.