表格对齐

表格对齐

考虑以下表格在此处输入图片描述使用代码

 \documentclass[a4paper,10pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{diagbox,amsmath,amssymb}

\begin{document}

\newcommand{\on}[1]{\ensuremath{\operatorname{#1}}}
    \begin{table}[h]
      \begin{center}
        \begin{tabular}{c|c|c}
          \diagbox{b}{d}&1&2\\ \hline
          1&$-(x_{a2}x_{c2}+\on{Re}(z_{n+a}\overline{z_{n+c}}))$&\\ 
          2&$2(x_{a1}x_{c2}+\on{Im}(z_{n+a}\overline{z_{n+c}}))$&$-(x_{a1}x_{c1}+\on{Re}(z_{n+a}\overline{z_{n+c}}))$\\
          3&$-2(x_{a4}x_{c2}-\on{Re}(z_{a}\overline{z_{n+c}}))$&$2(x_{a4}x_{c1}+\on{Im}(z_a\overline{z_{n+c}}))$\\
          4&$2(x_{a3}x_{c2}-\on{Im}(z_a\overline{z_{n+c}}))$&$-2(x_{a3}x_{c1}-\on{Re}(z_a\overline{z_{n+c}}))$
        \end{tabular}
      \end{center}
      \caption{Values of $\lambda_{abcd}$ for $d\in\{1,2\}$}
      \end{table}

\end{document}

是否可以将单元格彼此对齐,以便实部和虚部(以及它们前面的符号)对齐?在此先感谢您的帮助。

答案1

我怀疑你喜欢按如下方式对齐数学术语的实部和虚部:

在此处输入图片描述

\documentclass[a4paper,10pt]{scrartcl}
\usepackage{diagbox,amsmath,amssymb}
\usepackage{array}
\newcommand{\on}[1]{\ensuremath{\operatorname{#1}}}

\begin{document}
\begin{table}[h]
\centering
\renewcommand\arraystretch{1.5}
\begin{tabular}{ c|>{$}r<{$}@{\,}>{$}l<{$} | >{$}r<{$}@{\,}>{$}l<{$} }
  \diagbox{b}{d}
    & \multicolumn{2}{c|}{1} & \multicolumn{2}{c}{2}    \\ \hline
  1 & -(x_{a2}x_{c2}    & +\on{Re}(z_{n+a}\overline{z_{n+c}}))     &&  \\
  2 & 2(x_{a1}x_{c2}    & +\on{Im}(z_{n+a}\overline{z_{n+c}}))
        & -(x_{a1}x_{c1}    & +\on{Re}(z_{n+a}\overline{z_{n+c}}))  \\
  3 & -2(x_{a4}x_{c2}   & -\on{Re}(z_{a}\overline{z_{n+c}}))
        & 2(x_{a4}x_{c1}    & +\on{Im}(z_a\overline{z_{n+c}}))      \\
  4 & 2(x_{a3}x_{c2}    &  -\on{Im}(z_a\overline{z_{n+c}}))
        & -2(x_{a3}x_{c1}   & -\on{Re}(z_a\overline{z_{n+c}}))
\end{tabular}
\caption{Values of $\lambda_{abcd}$ for $d\in\{1,2\}$}
\end{table}
\end{document}

相关内容