![将目标列置于页面中央](https://linux22.com/image/438480/%E5%B0%86%E7%9B%AE%E6%A0%87%E5%88%97%E7%BD%AE%E4%BA%8E%E9%A1%B5%E9%9D%A2%E4%B8%AD%E5%A4%AE.png)
答案1
{NiceTabular}
这是使用 的自动解决方案nicematrix
。
\documentclass[a4paper]{article}
\usepackage{nicematrix}
\ExplSyntaxOn
\NewDocumentCommand \CenterColumn { m }
{
\cs_if_exist:cT { NiceMatrixSpace _ \NiceMatrixLastEnv }
{ \skip_horizontal:n { \use:c { NiceMatrixSpace _ \NiceMatrixLastEnv } } }
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgfextractx \l_tmpa_dim
{
\pgfpointdiff
{
\pgfpointadd
{ \pgfpointanchor { nm - \NiceMatrixLastEnv - 1 } { center } }
{ \pgfpointanchor { nm - \NiceMatrixLastEnv - last } { center } }
}
{
\pgfpointadd
{ \pgfpointanchor { nm - \NiceMatrixLastEnv - #1 } { center } }
{ \pgfpointanchor { nm - \NiceMatrixLastEnv - \int_eval:n { #1 + 1 } } { center } }
}
}
\iow_now:cx { @mainaux }
{
\exp_not:N \expandafter
\gdef
\exp_not:N \csname NiceMatrixSpace _ \NiceMatrixLastEnv \exp_not:N \endcsname
{ \dim_use:N \l_tmpa_dim }
}
\endpgfpicture
}
\ExplSyntaxOff
\begin{document}
\begin{table}[t]
\centering
\begin{NiceTabular}{cccc}
Abc & ~~ & Abc & Abc \\
efg & ~~ & efg & efg \\
\end{NiceTabular}
\CenterColumn{2}
\caption{Caption}
\end{table}
\begin{table}[t]
\centering
\begin{NiceTabular}{ccccc}
Abc & ~~ & Abc & Abc & extra \\
efg & ~~ & efg & efg & something \\
\end{NiceTabular}
\CenterColumn{2}
\caption{Caption}
\label{tab:my_label}
\end{table}
\begin{table}[t]
\centering
\begin{NiceTabular}{ccccc}
extra & Abc & ~~ & Abc & Abc \\
something & efg & ~~ & efg & efg \\
\end{NiceTabular}
\CenterColumn{3}
\caption{Caption}
\label{tab:my_label}
\end{table}
\end{document}
您需要多次编译(因为信息写在aux
文件中)。