4

I want to center the text in a table code given below in first column only just like the other two columns created by multi column centered the heading Dispersion Constant (R). I want the Algorithm heading in first column of table to be centered just like the Dispersion Constant (R) . The result of following code is given in figure below. Keep in mind I just want Algorithm to be centered not the content below(SCA,MCMA,etc) the Algorithm Heading. Thank You. Please help?

\begin{table}[h]
\centering
\caption{Dispersion Constant $(R)$ Values}
\begin{tabular}{|l|l|l|}
\hline
\centering
\textbf{Algorithm} & \multicolumn{2}{|c|}{\textbf{Dispersion Constant $(R)$}}\\
\hline
& \textbf{M=16} & \textbf{M=32}\\ \hline

SCA & R\textsubscript{SCA} = 123 & R\textsubscript{SCA} = 123 \\\hline
MCMA & R\textsubscript{MCMA} = 123 & R\textsubscript{MCMA} = 123\\\hline 
MCMA(Dual Mode) & R\textsubscript{MCMA}& R\textsubscript{MCMA}\\\hline 
DD-MCMA & R\textsubscript{DD-MCMA} = 123 & R\textsubscript{DD-MCMA} = 123\\\hline 
DD-MCMA(Dual Mode) & R\textsubscript{DD-MCMA}& R\textsubscript{DD-MCMA}\\\hline 
\end{tabular}
\end{table}

enter image description here

  • \multicolumn{1}{c}{Algorithm} might need | lines, not tested. No MWE. – Johannes_B Jul 9 '18 at 4:29
  • 2
    Have you ever thought about a more professional and modern table setup? Your table reminds me of a prison in an old western movie. – Johannes_B Jul 9 '18 at 4:30
  • No actually i m writing conference paper for IEEE and I need it for this purpose. – Faizan Zaheer Jul 9 '18 at 5:32
  • The \multicolumn{1}{c}{Algorithm} command centered it but the vertical line gets doubled – Faizan Zaheer Jul 9 '18 at 5:32
2

If you absolutely must employ the "prison look" for tables, but wish to lessen the visual oppressiveness, consider getting rid of the \hline directives in the body of the tabular material. And, load the array package and set \extrarowheight to a small non-zero length value. :-)

You should also make an effort to give the term "R" ("dispersion value") a consistent appearance. In your code, it shows up in math italics in the table's header but in upright ("Roman") in the body of the table. Do make the appearance of this variable name consistent. In the code below, I show how to make use of the math-italics method. And, while we're talking about consistency, I've made the M term employ (bold) math italics as well.

Finally, to center some material in a single cell of the first column, use a \multicolumn{1}{|c|}{...} "wrapper".

enter image description here

\documentclass{article}
\usepackage{array}    % for '\extrarowheight' macro
\usepackage{caption}  % for '\captionsetup' macro
\usepackage{amstext}  % for '\text' macro
\renewcommand{\thetable}{\Roman{table}} % just for this example

\begin{document}
\begin{table}%[h]
\captionsetup{font=bf,skip=0.5\baselineskip}
\setlength{\extrarowheight}{2pt}
\centering

\caption{\boldmath Values of Dispersion Constant ($R$)}
\begin{tabular}{|l|l|l|}
\hline
\multicolumn{1}{|c|}{\textbf{Algorithm}} & 
\multicolumn{2}{ c|}{\boldmath\textbf{Dispersion Constant ($R$)}}\\
\hline
& \boldmath $M=16$ & \boldmath $M=32$ \\ 
\hline

SCA & $R_{\text{SCA}} = 123$ & $R_{\text{SCA}} = 123$ \\ %\hline
MCMA & $R_{\text{MCMA}} = 123$ & $R_{\text{MCMA}} = 123$\\ %\hline 
MCMA(Dual Mode) & $R_{\text{MCMA}}$ & $R_{\text{MCMA}}$\\ %\hline 
DD-MCMA & $R_{\text{DD-MCMA}} = 123$ & $R_{\text{DD-MCMA}} = 123$\\%\hline 
DD-MCMA(Dual Mode) & $R_{\text{DD-MCMA}}$& $R_{\text{DD-MCMA}}$\\
\hline 
\end{tabular}
\end{table}
\end{document} 
4

faizanTabular

\documentclass{article}
\usepackage{booktabs}
\usepackage{caption}
\begin{document}
\begin{table}%[h]%bad style
\centering
\caption{Dispersion Constant $(R)$ Values}
\begin{tabular}{lll}
\toprule
\multicolumn{1}{c}{\textbf{Algorithm}} & \multicolumn{2}{c}{\textbf{Dispersion Constant $(R)$}}\\
\cmidrule(lr){1-1}
\cmidrule(lr){2-3}
& \textbf{M=16} & \textbf{M=32}\\ 

SCA & R\textsubscript{SCA} = 123 & R\textsubscript{SCA} = 123 \\
MCMA & R\textsubscript{MCMA} = 123 & R\textsubscript{MCMA} = 123\\ 
MCMA(Dual Mode) & R\textsubscript{MCMA}& R\textsubscript{MCMA}\\ 
DD-MCMA & R\textsubscript{DD-MCMA} = 123 & R\textsubscript{DD-MCMA} = 123\\ 
DD-MCMA(Dual Mode) & R\textsubscript{DD-MCMA}& R\textsubscript{DD-MCMA}\\ 
\bottomrule
\end{tabular}
\end{table}
\end{document}

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.