表格中多列标题下第一行居中

表格中多列标题下第一行居中

我想将多列标题下的行居中。在下面的表格中,我想将米=16米=32下图中的内容布局不会受到影响。红色标记表示内容只需居中即可。

\begin{table}[h]
\centering
\caption{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
& \textbf{\centering M=16} & \textbf{\centering M=32}\\ \hline 
SCA & R\textsubscript{SCA} = 123 & R\textsubscript{SCA} = 123 \\\hline
\end{table}
MCMA & R\textsubscript{R}=2.55 and R\textsubscript{I}=2.55  & R\textsubscript{R}=2.55 and R\textsubscript{I}=2.55\\
\hline 
\multirow{2}*{DD-MCMA} & R\textsubscript{R1} = 123 and R\textsubscript{R2} = 123 & R\textsubscript{R1} = 123 and R\textsubscript{R2} = 123 \\
& R\textsubscript{R1} = 123 and R\textsubscript{R2} = 123 & R\textsubscript{R1} = 123 and R\textsubscript{R2} = 123 \\
\hline
\end{tabular}
\end{table}

在此处输入图片描述

答案1

只需将其\multicolumn{1}{c|}{...}用于您想要居中的单元格即可。

\documentclass{article}
\usepackage{array}
\renewcommand{\arraystretch}{1.2}
\usepackage{multirow}
\usepackage{caption}
\begin{document}

\begin{table}[h]
\centering
\caption{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
& \multicolumn{1}{c|}{\textbf{M=16}} & \multicolumn{1}{c|}{\textbf{M=32}}\\ \hline 
SCA & R\textsubscript{SCA} = 123 & R\textsubscript{SCA} = 123 \\\hline
MCMA & R\textsubscript{R}=2.55 and R\textsubscript{I}=2.55  & R\textsubscript{R}=2.55 and R\textsubscript{I}=2.55\\
\hline 
\multirow{2}*{DD-MCMA} & R\textsubscript{R1} = 123 and R\textsubscript{R2} = 123 & R\textsubscript{R1} = 123 and R\textsubscript{R2} = 123 \\
& R\textsubscript{R1} = 123 and R\textsubscript{R2} = 123 & R\textsubscript{R1} = 123 and R\textsubscript{R2} = 123 \\
\hline
\end{tabular}
\end{table}
\end{document}

在此处输入图片描述

相关内容