我需要完全证明表格内容,例如 RSCA、RR1、RR2 等值。有没有办法在表格中提供值充分合理水平方向不是左对齐例如我们提供的\begin{tabular}{|l|l|l|}
左对齐内容。
代码如下所示:
\def\arraystretch{1.3}%
\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
\justifying
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} = 0.75 and R\textsubscript{R2} = 2.55 & R\textsubscript{R1} = 0.75 and R\textsubscript{R2} = 2.55 \\
& R\textsubscript{I1} = 0.75 and R\textsubscript{I2} = 2.55 & R\textsubscript{I1} = 0.75 and R\textsubscript{I2} = 2.55 \\
\hline
\end{tabular}
\end{table}
我想让这部分代码看起来水平对齐
SCA & R\textsubscript{SCA} = 123 & R\textsubscript{SCA} = 123 \\\hline
\justifying
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} = 0.75 and R\textsubscript{R2}
= 2.55 & R\textsubscript{R1} = 0.75 and R\textsubscript{R2} = 2.55 \\
& R\textsubscript{I1} = 0.75 and R\textsubscript{I2} = 2.55 &
R\textsubscript{I1} = 0.75 and R\textsubscript{I2} = 2.55 \\
\hline
答案1
编辑1(回复评论):
列类型的解释(后的代码tabular
):
- 你
>{...}
可以告诉 LaTeX 做一些事情前<{...}
用一些东西写单元格内容后;您需要array
这些选项的包 - 告诉
S[table-format=1.2]
LaTeX 您有 1 个整数和 2 个小数,需要在小数点处对齐(siunitx
需要包) - 您
@{something}
可以插入something
而不是列间空格(array
包) - 您
!{something}
可以插入something
而不是|
(始终查看array
包装)。
\documentclass{article}
\usepackage{array}
\renewcommand{\arraystretch}{1.3}
\usepackage{siunitx}
\usepackage{caption}
\usepackage{amsmath}
\begin{document}
\begin{table}[h]
\centering\footnotesize
\caption{Values of Dispersion Constant ($R$)}
\begin{tabular}{
|l|
>{$}l<{$}@{${}={}$}S[table-format=1.2]
!{and}
>{$}l<{$}@{${}={}$}S[table-format=1.2]|
>{$}l<{$}@{${}={}$}S[table-format=1.2]
!{and}
>{$}l<{$}@{${}={}$}S[table-format=1.2]|
}
\hline
\multicolumn{1}{|c|}{\textbf{Algorithm}} & \multicolumn{8}{ c|}{{\boldmath\textbf{Dispersion Constant ($R$)}}}\\
\hline
& \multicolumn{4}{ c|}{\boldmath $M=16$} & \multicolumn{4}{ c|}{\boldmath $M=32$}\\ \hline
SCA & \multicolumn{4}{c|}{$R_{\text{SCA}}=123$} & \multicolumn{4}{c|}{$R_{\text{SCA}}=123$} \\\hline
MCMA & R_{\text{R}} & 2.55 & R_{\text{I}} & 2.55 & R_{\text{R}} & 2.55 & R_{\text{I}} & 2.55\\
\hline
DD-MCMA & R_\text{{R1}} & 0.75 & R_{\text{R2}} & 2.55 & R_{\text{R1}} & 0.75 & R_{\text{R2}} & 2.55 \\
& R_{\text{I1}} & 0.75 & R_{\text{I2}} & 2.55 & R_{\text{I1}} & 0.75 & R_{\text{I2}} & 2.55 \\
\hline
\end{tabular}
\end{table}
\end{document}
编辑 2(这是 OP 想要的,不是我喜欢的):
如果您想要 Word 对齐,请使用\hfill
:
\documentclass{article}
\usepackage{array}
\usepackage{siunitx}
\usepackage{caption}
\usepackage{amsmath}
\usepackage{multirow}
\begin{document}
\def\arraystretch{1.3}%
\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} \hfill = \hfill 123 & R\textsubscript{SCA} \hfill = \hfill 123 \\\hline
MCMA & R\textsubscript{R} \hfill = \hfill 2.55 \hfill and R\textsubscript{I} \hfill = \hfill 2.55 & R\textsubscript{R} \hfill = 2.55 \hfill and \hfill R\textsubscript{I} \hfill = \hfill 2.55\\
\hline
\multirow{2}*{DD-MCMA} & R\textsubscript{R1} \hfill = \hfill 0.75 \hfill and \hfill R\textsubscript{R2} \hfill = \hfill 2.55 & R\textsubscript{R1} \hfill = \hfill 0.75 \hfill and \hfill R\textsubscript{R2} \hfill = \hfill 2.55 \\
& R\textsubscript{I1} \hfill = \hfill 0.75 \hfill and \hfill R\textsubscript{I2} \hfill = \hfill 2.55 & R\textsubscript{I1} \hfill = 0.75 \hfill and \hfill R\textsubscript{I2} \hfill = \hfill 2.55 \\
\hline
\end{tabular}
\end{table}
\end{document}