为什么在使用带有“X”列类型的“\multicolumn”时会出现不必要的空白?

为什么在使用带有“X”列类型的“\multicolumn”时会出现不必要的空白?

我使用宏\newcolumntype{C}{>{ \arraybackslash \Centering }X}来创建新的列类型,但是当使用这种类型的列时,\multicolumn我需要一个特殊的宏来解决兼容性问题,如下所述如何在使用命令时强制类型X列包装其内容?\multicolumn。Zarko 提供的答案有效,但现在我似乎遇到了一些不必要的空间问题

在此处输入图片描述

\documentclass{IEEEtran}


\usepackage{multirow}
\usepackage{caption}
\usepackage{ragged2e}
\usepackage{tabularx}
\newcolumntype{C}{ >{ \arraybackslash \Centering } X }
\newcommand{\multcolhsize}[1]{\dimexpr #1\hsize + #1\tabcolsep + \tabcolsep \relax}

\usepackage{booktabs}
\usepackage{makecell}
\usepackage[defaultmathsizes, subdued, italic, LGRgreek, symbolre, symbolmisc]{mathastext}



\usepackage{adjustbox}



\begin{document}


\newcommand{\RERInteractionSumm}{\sum_{j \in \mathnormalbold{R}, \thinspace j \neq i} P_{R, \thinspace j}^{\adjustbox{raise=0.1\baselineskip}{*}} \thinspace w_{ij}}

\begin{table*}[htb]

    % Table options

        % Caption
        \caption{Comparison of SDSCR obtained by [ref] (full) and [ref] (approximate) for bus 27}
        \label{table:SDSCR_full_v_app_27}

        % Center the table
        \centering


    \begin{tabularx}{\textwidth}{>{\hsize=0.9\hsize}C |>{\hsize=0.9\hsize}C |>{\hsize=0.9\hsize}C |>{\hsize=1.35\hsize}C |>{\hsize=1.35\hsize}C |>{\hsize=0.9\hsize}C |>{\hsize=0.9\hsize}C |>{\hsize=0.9\hsize}C |>{\hsize=0.9\hsize}C}

        \toprule


        $\left| V_{R, \thinspace i} \right|^{2}$ &  $\left| Z_{RR, \thinspace ii} \right|$& $P_{R, \thinspace i}^{\adjustbox{raise=0.05\baselineskip}{*}}$
        & \multicolumn{2}{>{\hsize=\multcolhsize{2}}C|}{
                        $ \displaystyle \RERInteractionSumm$
                                                    }
        & \multicolumn{2}{>{\hsize=\multcolhsize{2}}C|}{
                        $\left| S_{eq, \thinspace i}^{\adjustbox{raise=0.05\baselineskip}{*}} \right|$
                                                        }
        & \multicolumn{2}{>{\hsize=\multcolhsize{2}}C}{$SDSCR_{i}$}
        \\
        \Xhline{0.2mm}


        $0.992$ & $0.0941$ & $3$ & $-1.05-0.095j$ & $-0.95-0.513j$ & $1.95$ & $2.11$ & $5.41$ & $4.99$
        \\


        $0.995$ & $0.0921$ & $3$ & $-1.08-0.108j$ & $-0.97-0.529j$ & $1.92$ & $2.10$ & $5.62$ & $5.16$
        \\


        $0.997$ & $0.0910$ & $3$ & $-1.09-0.115j$ & $-0.98-0.537j$ & $1.91$ & $2.09$ & $5.73$ & $5.25$
        \\

        $0.999$ & $0.0900$ & $3$ & $-1.11-0.124j$ & $-1.00-0.547j$ & $1.90$ & $2.08$ & $5.86$ & $5.35$
        \\


        $1.001$ & $0.0886$ & $3$ & $-1.12-0.132j$ & $-1.01-0.557j$ & $1.88$ & $2.07$ & $6.01$ & $5.46$
        \\

        $1.003$ & $0.0872$ & $3$ & $-1.14-0.143j$ & $-1.02-0.569j$ & $1.86$ & $2.06$ & $6.16$ & $5.58$
        \\

        $1.005$ & $0.0858$ & $3$ & $-1.16-0.154j$ & $-1.04-0.582j$ & $1.85$ & $2.05$ & $6.34$ & $5.72$
        \\

        $1.007$ & $0.0843$ & $3$ & $-1.18-0.166j$ & $-1.06-0.596j$ & $1.83$ & $2.04$ & $6.54$ & $5.87$
        \\

        $1.009$ & $0.0827$ & $3$ & $-1.21-0.180j$ & $-1.07-0.612j$ & $1.80$ & $2.02$ & $6.77$ & $6.04$
        \\

        $1.011$ & $0.0809$ & $3$ & $-1.23-0.196j$ & $-1.09-0.630j$ & $1.78$ & $2.01$ & $7.02$ & $6.23$
        \\

        \bottomrule



    \end{tabularx}

\end{table*}

\end{document}

答案1

在我看来,在这种情况下,使用环境tabular*而不是tabularx环境会更好。不过,更好的办法是不要强制表格占据文本块的整个宽度……

请考虑以下两个屏幕截图:

在此处输入图片描述

在此处输入图片描述

\documentclass{IEEEtran}

%\usepackage{multirow}
\usepackage{caption}
\usepackage{ragged2e}
\usepackage{tabularx}
\newcolumntype{C}{ >{\Centering\arraybackslash}X }
\newcommand{\multcolhsize}[1]{\dimexpr #1\hsize + #1\tabcolsep + \tabcolsep \relax}

\usepackage{booktabs,makecell}
\usepackage[defaultmathsizes, subdued, italic, LGRgreek, symbolre, symbolmisc]{mathastext}
\usepackage{adjustbox}

\newcommand{\RERInteractionSumm}{\sum_{j \in \mathnormalbold{R}, \thinspace j \neq i} P_{R, \thinspace j}^{\adjustbox{raise=0.1\baselineskip}{*}} \thinspace w_{ij}}

\begin{document}

\begin{table*}[ht!]
% Table options
% Caption
\caption{Version with \texttt{tabularx}}
\label{table:tabularx}

% Center the table
\centering

\begin{tabularx}{\textwidth}{
  >{\hsize=0.9\hsize}C |>{\hsize=0.9\hsize}C |
  >{\hsize=0.9\hsize}C |>{\hsize=1.35\hsize}C|
  >{\hsize=1.35\hsize}C|>{\hsize=0.9\hsize}C |
  >{\hsize=0.9\hsize}C |>{\hsize=0.9\hsize}C |
  >{\hsize=0.9\hsize}C}
\toprule
$\left| V_{R, \thinspace i} \right|^{2}$ &  
$\left| Z_{RR, \thinspace ii} \right|$& 
$P_{R, \thinspace i}^{\adjustbox{ raise=0.05\baselineskip}{*}}$& 
\multicolumn{2}{>{\hsize=\multcolhsize{2}}C|}{
$ \displaystyle \RERInteractionSumm$}
& \multicolumn{2}{>{\hsize=\multcolhsize{2}}C|}{
    $\left| S_{eq, \thinspace i}^{\adjustbox{ raise=0.05\baselineskip}{*}} \right|$}& 
\multicolumn{2}{>{\hsize=\multcolhsize{2}}C}{$SDSCR_{i}$}
 \\
\Xhline{0.2mm}
$0.992$ & $0.0941$ & $3$ & $-1.05-0.095j$ & $-0.95-0.513j$ & $1.95$ & $2.11$ & $5.41$ & $4.99$ \\
$0.995$ & $0.0921$ & $3$ & $-1.08-0.108j$ & $-0.97-0.529j$ & $1.92$ & $2.10$ & $5.62$ & $5.16$ \\
$0.997$ & $0.0910$ & $3$ & $-1.09-0.115j$ & $-0.98-0.537j$ & $1.91$ & $2.09$ & $5.73$ & $5.25$ \\
$0.999$ & $0.0900$ & $3$ & $-1.11-0.124j$ & $-1.00-0.547j$ & $1.90$ & $2.08$ & $5.86$ & $5.35$ \\
$1.001$ & $0.0886$ & $3$ & $-1.12-0.132j$ & $-1.01-0.557j$ & $1.88$ & $2.07$ & $6.01$ & $5.46$ \\
$1.003$ & $0.0872$ & $3$ & $-1.14-0.143j$ & $-1.02-0.569j$ & $1.86$ & $2.06$ & $6.16$ & $5.58$ \\
$1.005$ & $0.0858$ & $3$ & $-1.16-0.154j$ & $-1.04-0.582j$ & $1.85$ & $2.05$ & $6.34$ & $5.72$ \\
$1.007$ & $0.0843$ & $3$ & $-1.18-0.166j$ & $-1.06-0.596j$ & $1.83$ & $2.04$ & $6.54$ & $5.87$ \\
$1.009$ & $0.0827$ & $3$ & $-1.21-0.180j$ & $-1.07-0.612j$ & $1.80$ & $2.02$ & $6.77$ & $6.04$ \\
$1.011$ & $0.0809$ & $3$ & $-1.23-0.196j$ & $-1.09-0.630j$ & $1.78$ & $2.01$ & $7.02$ & $6.23$ \\
\bottomrule
\end{tabularx}
\end{table*}

%%%% version with tabular* %%%%

\begin{table*}[h!]
\caption{Version with \texttt{tabular*} and without vertical lines}
\label{table:tabular*}

% Let LaTeX do the work of setting the intercolumn whitespace
\setlength\tabcolsep{0pt}

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{9}{>{$}c<{$}} }
\toprule
| V_{R, i} |^{2} & | Z_{RR, ii} | & P_{R, i}^{*} & 
\multicolumn{2}{>{$\displaystyle}c<{$}}{\RERInteractionSumm} & 
\multicolumn{2}{>{}c<{$}}{ | S_{eq, i}^{*} |}& 
\multicolumn{2}{>{}c<{$}}{\mathit{SDSCR}_{i}} \\
\cmidrule{4-5} \cmidrule{6-7} \cmidrule{8-9} 
\addlinespace
0.992 & 0.0941 & 3 & -1.05-0.095j & -0.95-0.513j & 1.95 & 2.11 & 5.41 & 4.99 \\
0.995 & 0.0921 & 3 & -1.08-0.108j & -0.97-0.529j & 1.92 & 2.10 & 5.62 & 5.16 \\
0.997 & 0.0910 & 3 & -1.09-0.115j & -0.98-0.537j & 1.91 & 2.09 & 5.73 & 5.25 \\
0.999 & 0.0900 & 3 & -1.11-0.124j & -1.00-0.547j & 1.90 & 2.08 & 5.86 & 5.35 \\
1.001 & 0.0886 & 3 & -1.12-0.132j & -1.01-0.557j & 1.88 & 2.07 & 6.01 & 5.46 \\
\addlinespace % for a bit of visual rhythm
1.003 & 0.0872 & 3 & -1.14-0.143j & -1.02-0.569j & 1.86 & 2.06 & 6.16 & 5.58 \\
1.005 & 0.0858 & 3 & -1.16-0.154j & -1.04-0.582j & 1.85 & 2.05 & 6.34 & 5.72 \\
1.007 & 0.0843 & 3 & -1.18-0.166j & -1.06-0.596j & 1.83 & 2.04 & 6.54 & 5.87 \\
1.009 & 0.0827 & 3 & -1.21-0.180j & -1.07-0.612j & 1.80 & 2.02 & 6.77 & 6.04 \\
1.011 & 0.0809 & 3 & -1.23-0.196j & -1.09-0.630j & 1.78 & 2.01 & 7.02 & 6.23 \\
\bottomrule
\end{tabular*}
\end{table*}

\end{document}

附录:如上所述,让表格占据文本块的整个宽度似乎是不必要的,甚至是不幸的(从印刷的角度来看)。事实上,无需太多额外的努力,就可以将表格材料放入双列文档类的单个列中IEEEtran

对于以下屏幕截图,主要变化(相对于上面的第二个屏幕截图)是从 更改为\begin{tabular*}{\textwidth}{...}\begin{tabular*}{\columnwidth}{...}其他变化包括从(文档类\small的默认值)切换到,减少 的值,并将数字的虚部从 3 位四舍五入为 2 位。IEEEtran\footnotesize\medmuskip

[备注:系统目前似乎不允许我上传截图。我今天晚些时候会再试一次。]

\documentclass{IEEEtran}
\usepackage{newtxmath} % optional (to match the Times Roman text font)
\usepackage{array}     % for '\newcolumntype' macro
\newcolumntype{C}{ >{$}c<{$} }  % centered, automatically in math mode

\usepackage{booktabs,mathtools,bm,caption}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert} % abs. value/modulus
\newcommand{\RERInteractionSumm}{\displaystyle%
   \smashoperator{\sum_{j\in\bm{R},j\ne i}} P_{\!R,j}^{*} w_{ij}} 
\usepackage{lipsum}  % for filler text
\begin{document}

\addtocounter{table}{2} % just for this example
\lipsum[1]  % filler text

\begin{table}[ht!]
\caption{Version with width set to columnwidth}
\label{table:tabular-columnwidth}
\footnotesize % default: \small
\setlength\tabcolsep{0pt} % make LaTeX figure out vert. whitespace
\medmuskip=1mu   % default: 4mu

    \begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}} *{9}{C} }
    \toprule
    \abs{V_{\!R, i}}^{2} & \abs{Z_{\mathit{RR}, ii}} & P_{\!R, i}^{*} & 
    \multicolumn{2}{C}{\RERInteractionSumm} & 
    \multicolumn{2}{C}{\abs{S_{\mathit{eq}, i}^{*}}}& 
    \multicolumn{2}{C}{\mathit{SDSCR}_{i}} \\
    \cmidrule{4-5} \cmidrule{6-7} \cmidrule{8-9} 
    \addlinespace
    0.992 & 0.0941 & 3 & -1.05-0.10j & -0.95-0.51j & 1.95 & 2.11 & 5.41 & 4.99 \\
    0.995 & 0.0921 & 3 & -1.08-0.11j & -0.97-0.53j & 1.92 & 2.10 & 5.62 & 5.16 \\
    0.997 & 0.0910 & 3 & -1.09-0.12j & -0.98-0.54j & 1.91 & 2.09 & 5.73 & 5.25 \\
    0.999 & 0.0900 & 3 & -1.11-0.12j & -1.00-0.55j & 1.90 & 2.08 & 5.86 & 5.35 \\
    1.001 & 0.0886 & 3 & -1.12-0.13j & -1.01-0.56j & 1.88 & 2.07 & 6.01 & 5.46 \\
    \addlinespace
    1.003 & 0.0872 & 3 & -1.14-0.14j & -1.02-0.57j & 1.86 & 2.06 & 6.16 & 5.58 \\
    1.005 & 0.0858 & 3 & -1.16-0.15j & -1.04-0.58j & 1.85 & 2.05 & 6.34 & 5.72 \\
    1.007 & 0.0843 & 3 & -1.18-0.17j & -1.06-0.60j & 1.83 & 2.04 & 6.54 & 5.87 \\
    1.009 & 0.0827 & 3 & -1.21-0.18j & -1.07-0.61j & 1.80 & 2.02 & 6.77 & 6.04 \\
    1.011 & 0.0809 & 3 & -1.23-0.20j & -1.09-0.63j & 1.78 & 2.01 & 7.02 & 6.23 \\
    \bottomrule
    \end{tabular*}
\end{table}

\lipsum[2-7] % more filler text

\end{document}

答案2

您不需要处理以下事情\hsize

\documentclass{IEEEtran}

\usepackage{amsmath,bm}
\usepackage{booktabs,array}

\begin{document}


\newcommand{\RERInteractionSumm}{%
  \sum_{\substack{j \in \bm{R} \\ j \neq i}} P_{R,j}^{*} w_{ij}%
}

\begin{table*}

% Caption
\caption{Comparison of SDSCR obtained by [ref] (full) and [ref] 
  (approximate) for bus 27}
\label{table:SDSCR_full_v_app_27}

% Center the table
\centering

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  >{$}c<{$}
  >{$}c<{$}
  >{$}c<{$}
  >{$}c<{$}
  @{\extracolsep{4\tabcolsep}}
  >{$}c<{$}
  @{\extracolsep{\fill}}
  >{$}c<{$}
  @{\extracolsep{4\tabcolsep}}
  >{$}c<{$}
  @{\extracolsep{\fill}}
  >{$}c<{$}
  @{\extracolsep{4\tabcolsep}}
  >{$}c<{$}
  @{}
 }
\toprule
|V_{R,i}|^{2} & |Z_{RR,ii}| & P_{R,i}^{*}
  & \multicolumn{2}{c}{$\displaystyle\RERInteractionSumm$}
  & \multicolumn{2}{c}{$|S_{\mathrm{eq},i}^{*}|$}
  & \multicolumn{2}{c}{$\mathrm{SDSCR}_{i}$}
\\
\cmidrule{4-5}\cmidrule{6-7}\cmidrule{8-9}
&&&
\text{full} & \text{appr.} &
\text{full} & \text{appr.} &
\text{full} & \text{appr.}
\\
\midrule
0.992 & 0.0941 & 3 & -1.05-0.095j & -0.95-0.513j & 1.95 & 2.11 & 5.41 & 4.99
\\
0.995 & 0.0921 & 3 & -1.08-0.108j & -0.97-0.529j & 1.92 & 2.10 & 5.62 & 5.16
\\
0.997 & 0.0910 & 3 & -1.09-0.115j & -0.98-0.537j & 1.91 & 2.09 & 5.73 & 5.25
\\
0.999 & 0.0900 & 3 & -1.11-0.124j & -1.00-0.547j & 1.90 & 2.08 & 5.86 & 5.35
\\
1.001 & 0.0886 & 3 & -1.12-0.132j & -1.01-0.557j & 1.88 & 2.07 & 6.01 & 5.46
\\
1.003 & 0.0872 & 3 & -1.14-0.143j & -1.02-0.569j & 1.86 & 2.06 & 6.16 & 5.58
\\
1.005 & 0.0858 & 3 & -1.16-0.154j & -1.04-0.582j & 1.85 & 2.05 & 6.34 & 5.72
\\
1.007 & 0.0843 & 3 & -1.18-0.166j & -1.06-0.596j & 1.83 & 2.04 & 6.54 & 5.87
\\
1.009 & 0.0827 & 3 & -1.21-0.180j & -1.07-0.612j & 1.80 & 2.02 & 6.77 & 6.04
\\
1.011 & 0.0809 & 3 & -1.23-0.196j & -1.09-0.630j & 1.78 & 2.01 & 7.02 & 6.23
\\
\bottomrule
\end{tabular*}

\end{table*}

\end{document}

我删除了所有不添加任何内容的垂直规则:大空间会更好地完成工作。但是,即使表格按其自然宽度排版,它们也不是必需的,见下文。

在此处输入图片描述

自然宽度的桌子:

\documentclass{IEEEtran}

\usepackage{amsmath,bm}
\usepackage{booktabs,array}

\begin{document}


\newcommand{\RERInteractionSumm}{%
  \sum_{\substack{j \in \bm{R} \\ j \neq i}} P_{R,j}^{*} w_{ij}%
}

\begin{table*}

% Caption
\caption{Comparison of SDSCR obtained by [ref] (full) and [ref] 
  (approximate) for bus 27}
\label{table:SDSCR_full_v_app_27}

% Center the table
\centering

\begin{tabular}{ @{} *{9}{ >{$}c<{$} } @{} }
\toprule
|V_{R,i}|^{2} & |Z_{RR,ii}| & P_{R,i}^{*}
  & \multicolumn{2}{c}{$\displaystyle\RERInteractionSumm$}
  & \multicolumn{2}{c}{$|S_{\mathrm{eq},i}^{*}|$}
  & \multicolumn{2}{c}{$\mathrm{SDSCR}_{i}$}
\\
\cmidrule(lr){4-5}\cmidrule(lr){6-7}\cmidrule(l){8-9}
&&&
\text{full} & \text{appr.} &
\text{full} & \text{appr.} &
\text{full} & \text{appr.}
\\
\midrule

0.992 & 0.0941 & 3 & -1.05-0.095j & -0.95-0.513j & 1.95 & 2.11 & 5.41 & 4.99
\\
0.995 & 0.0921 & 3 & -1.08-0.108j & -0.97-0.529j & 1.92 & 2.10 & 5.62 & 5.16
\\
0.997 & 0.0910 & 3 & -1.09-0.115j & -0.98-0.537j & 1.91 & 2.09 & 5.73 & 5.25
\\
0.999 & 0.0900 & 3 & -1.11-0.124j & -1.00-0.547j & 1.90 & 2.08 & 5.86 & 5.35
\\
1.001 & 0.0886 & 3 & -1.12-0.132j & -1.01-0.557j & 1.88 & 2.07 & 6.01 & 5.46
\\
1.003 & 0.0872 & 3 & -1.14-0.143j & -1.02-0.569j & 1.86 & 2.06 & 6.16 & 5.58
\\
1.005 & 0.0858 & 3 & -1.16-0.154j & -1.04-0.582j & 1.85 & 2.05 & 6.34 & 5.72
\\
1.007 & 0.0843 & 3 & -1.18-0.166j & -1.06-0.596j & 1.83 & 2.04 & 6.54 & 5.87
\\
1.009 & 0.0827 & 3 & -1.21-0.180j & -1.07-0.612j & 1.80 & 2.02 & 6.77 & 6.04
\\
1.011 & 0.0809 & 3 & -1.23-0.196j & -1.09-0.630j & 1.78 & 2.01 & 7.02 & 6.23
\\
\bottomrule
\end{tabular}

\end{table*}

\end{document}

在此处输入图片描述

还要注意的是caption与类不兼容IEEEtran。另外\thinspace也是文本命令;对于数学来说应该是这样的\,,但我不认为你应该在表格中的任何地方使用它。

相关内容