修改问题以增加清晰度

修改问题以增加清晰度

修改问题以增加清晰度

当尝试将宽(比 更宽\columnwidth)的长表格 ( longtblr)合并到twocolumn像 这样的文档类中时article,表格会溢出到下一列而不是下一页。我该如何克服这个问题?

这是一个 MWE(改编自包(v2023A)longtblr第 4 章中的示例tablurarray):

\documentclass[twocolumn]{article}
\usepackage{xcolor}
\usepackage{tabularray}

\begin{document}

\begin{longtblr}[
  caption = {A Long Long Long Long Long Long Long Table},
  entry = {Short Caption},
  label = {tblr:test},
  note{a} = {It is the first footnote.},
  note{$\dag$} = {It is the second long long long long long long footnote.},
  remark{Note} = {Some general note. Some general note. Some general note.},
  remark{Source} = {Made up by myself. Made up by myself. Made up by myself.},
]{
  colspec = {lll},
  rowhead = 2, rowfoot = 1,
  row{odd} = {gray9}, row{even} = {brown9},
  row{1-2} = {purple7}, row{Z} = {blue7},
}
\hline
 Head    & Head  & Head    \\
\hline
 Head    & Head  & Head    \\
\hline
 Alpha Alpha Alpha Alpha   & Beta Beta Beta Beta  & Gamma Gamma Gamma Gamma   \\
\hline
 Epsilon & Zeta\TblrNote{a}       & Eta    \\
\hline
 Iota    & Kappa\TblrNote{$\dag$} & Lambda \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha Alpha Alpha Alpha   & Beta Beta Beta Beta  & Gamma Gamma Gamma Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha Alpha Alpha Alpha   & Beta Beta Beta Beta  & Gamma Gamma Gamma Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha Alpha Alpha Alpha   & Beta Beta Beta Beta  & Gamma Gamma Gamma Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha Alpha Alpha Alpha   & Beta Beta Beta Beta  & Gamma Gamma Gamma Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha Alpha Alpha Alpha   & Beta Beta Beta Beta  & Gamma Gamma Gamma Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha Alpha Alpha Alpha   & Beta Beta Beta Beta  & Gamma Gamma Gamma Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Foot    & Foot  & Foot    \\
\hline
\end{longtblr}

\end{document}

这将产生以下输出:

宽而长的桌子的问题

原始问题

我有一个两列(或双列)模板,我想在其中使用 longtblr 来制作表格。我非常喜欢 tabularray(其中定义了 longtblr)的工作方式。它简单易用,最重要的是,它看起来非常漂亮(我的主观意见)。我将其用于单列文档,也用于带有小表格的两列文档。但是,我不太了解如何正确使用它来制作横跨两列的宽表格。以下是一个例子:

\documentclass[twocolumn]{article}
\usepackage{xcolor}
\usepackage{tabularray}
\NewTblrTheme{TC}{%
\DefTblrTemplate{contfoot-text}{default}{Continued on next column/page}
\SetTblrStyle{contfoot-text}{font=\footnotesize\itshape, fg=black!80}
}
\usepackage{lipsum}

\begin{document}
\lipsum[1-2]

    \begin{longtblr}[
    theme = TC,
    caption = {Long table caption.},
    label = {table:ips},
    ]{
        hlines, vlines,
        colspec = { X[l] X[2,l] X[3,l]},
        rowhead = 2,
        %   colsep = 3pt,
        row{even} = {gray9},
        row{1} = {blue!30},
        row{2} = {font=\small\bfseries, c}
    }
    \SetCell[c=3]{c}        A nice Table
    &               &               \\
    Part A  &   Part B      &   Part C      \\
    Hmmm    & This is not & what I want \\
    Hmmm    & This is not & what I want \\
    Hmmm    & This is not & what I want \\
    Hmmm    & This is not & what I want \\
    Hmmm    & This is not & what I want \\
    Hmmm    & This is not & what I want \\
    Hmmm    & This is not & what I want \\
    Hmmm    & This is not & what I want \\
    Hmmm    & This is not & what I want \\
    Hmmm    & This is not & what I want \\
\end{longtblr}
\lipsum[3-4]

\begin{table*}
\begin{longtblr}[
    theme = TC,
    caption = {Long table caption.},
    label = {table:ips},
    ]{
        hlines, vlines,
        colspec = { X[l] X[2,l] X[3,l]},
        rowhead = 2,
        %   colsep = 3pt,
        row{even} = {gray9},
        row{1} = {blue!30},
        row{2} = {font=\small\bfseries, c}
    }
    \SetCell[c=3]{c}        A nice Table
    &               &               \\
    Part A  &   Part B      &   Part C      \\
    With a table* around longtblr environment    & it seems to work partially & but then it duplicates the table \\
    With a table* around longtblr environment    & it seems to work partially & but then it duplicates the table \\

\end{longtblr}
\end{table*}

\lipsum[5-12]


\end{document}

由此产生了如下结果: 所需表格解释

我的问题:我怎样才能使这个表跨越两列?非常感谢。

如果这不可能,我如何使用另一个可以运行的包来复制类似的表格?(注意行之间的交替颜色)

编辑:添加了一个最小示例。感谢 Zarko。

答案1

纯粹猜测你想要什么:

\documentclass[twocolumn]{article}
\usepackage{xcolor}
\usepackage{tabularray}
\NewTblrTheme{TC}{%
    \DefTblrTemplate{contfoot-text}{default}{Continued on next column/page}
       \SetTblrStyle{contfoot-text}{font=\footnotesize\itshape, fg=black!80}
                  }
\usepackage{lipsum}

\begin{document}
\lipsum[1-2]

\begin{longtblr}[
  theme = TC,
caption = {Long table caption.},
label = {table:ips},
                ]{
  hlines, vlines,
  colspec = { X[l] X[2,l] X[3,l]},
  rowhead = 2,
%   colsep = 3pt,
row{even} = {gray9},
   row{1} = {blue!30},
   row{2} = {font=\small\bfseries, c}
                }
\SetCell[c=3]{c}        A nice Table
        &               &               \\
Part A  &   Part B      &   Part C      \\
Hmmm    & This is not   & how I want it \\
It is   & not clear     & what you want \\
Hmmm    & This is not   & how I want it \\
It is   & not clear     & what you want \\
Hmmm    & This is not   & how I want it \\
It is   & not clear     & what you want \\
Hmmm    & This is not   & how I want it \\
It is   & not clear     & what you want \\
Hmmm    & This is not   & how I want it \\
It is   & not clear     & what you want \\
Hmmm    & This is not   & how I want it \\
It is   & not clear     & what you want \\
Hmmm    & This is not   & how I want it \\
It is   & not clear     & what you want \\
Hmmm    & This is not   & how I want it \\
It is   & not clear     & what you want \\
\end{longtblr}

\lipsum[3-4]
\end{document}

在此处输入图片描述

编辑: 仍然不清楚您的问题是什么以及您的表格有多大。从编辑的问题中可以得出结论,您不需要长表格,但您希望它跨越两列。我说得对吗?

如果是这种情况,请尝试以下操作:

\documentclass[twocolumn]{article}
\usepackage{xcolor}
\usepackage{tabularray}

\usepackage{lipsum}

\begin{document}
\lipsum[1-5]

    \begin{table*}[t]
    \caption{Long table caption.}
    \label{table:ips}
\begin{tblr}{
  hlines, vlines,
  colspec = { X[l] X[2,l] X[3,l] },
  rowhead = 2,
row{even} = {gray9},
   row{1} = {blue!30},
   row{2} = {font=\small\bfseries, c}
            }
\SetCell[c=3]{c}        A nice Table
        &               &               \\
Part A  &   Part B      &   Part C      \\
Hmmm    & This is not   & how I want it \\
It is   & not clear     & what you want \\
Hmmm    & This is not   & how I want it \\
It is   & not clear     & what you want \\
Hmmm    & This is not   & how I want it \\
It is   & not clear     & what you want \\
Hmmm    & This is not   & how I want it \\
It is   & not clear     & what you want \\
Hmmm    & This is not   & how I want it \\
It is   & not clear     & what you want \\
Hmmm    & This is not   & how I want it \\
It is   & not clear     & what you want \\
Hmmm    & This is not   & how I want it \\
It is   & not clear     & what you want \\
Hmmm    & This is not   & how I want it \\
It is   & not clear     & what you want \\
\end{tblr}
    \end{table*}
\lipsum[6-12]
\end{document}

在此处输入图片描述

答案2

您可以使用包并在环境multicol中放置两列文本:multicols

\documentclass{article}

\usepackage{xcolor}
\usepackage{tabularray}
\usepackage{lipsum}
\usepackage{multicol}

\begin{document}

\begin{multicols}{2}
\lipsum[1]
\end{multicols}

\begin{longtblr}[
  caption = {Long Table Caption},
  label = {table:ips},
]{
  hlines, vlines,
  colspec = {X[l]X[2,l]X[3,l]},
  rowhead = 2,
  row{even} = {gray9},
  row{1} = {blue8},
  cell{1}{1} = {c=3}{c},
}
  A Nice Table &          &      \\
  Part A       & Part B & Part C \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
  Alpha        & Beta   & Gamma  \\
\end{longtblr}

\begin{multicols}{2}
\lipsum[2-3]
\end{multicols}

\end{document}

在此处输入图片描述

答案3

tabularray包定义了\TblrNewPage宏以解析为 LaTeX 的\newpage宏。因为\newpage在双列环境中,无论下一列是在同一页还是下一页,都会前进到下一列,所以您可以改为\TblrNewPage使用\clearpage

\renewcommand{\TblrNewPage}{\clearpage}

此 StackExchange 答案很好地解释了\newpage\clearpage。请注意,如果您随后需要缩小tabularray longtblr,则需要\TblrNewPage再次更新以将其更改回其默认的\newpage

以下是上述修改后的问题中更新后的 MWE:

\documentclass[twocolumn]{article}
\usepackage{xcolor}
\usepackage{tabularray}

\begin{document}

\renewcommand{\TblrNewPage}{\clearpage}  %% <--- Added this line only
\begin{longtblr}[
  caption = {A Long Long Long Long Long Long Long Table},
  entry = {Short Caption},
  label = {tblr:test},
  note{a} = {It is the first footnote.},
  note{$\dag$} = {It is the second long long long long long long footnote.},
  remark{Note} = {Some general note. Some general note. Some general note.},
  remark{Source} = {Made up by myself. Made up by myself. Made up by myself.},
]{
  colspec = {lll},
  rowhead = 2, rowfoot = 1,
  row{odd} = {gray9}, row{even} = {brown9},
  row{1-2} = {purple7}, row{Z} = {blue7},
}
\hline
 Head    & Head  & Head    \\
\hline
 Head    & Head  & Head    \\
\hline
 Alpha Alpha Alpha Alpha   & Beta Beta Beta Beta  & Gamma Gamma Gamma Gamma   \\
\hline
 Epsilon & Zeta\TblrNote{a}       & Eta    \\
\hline
 Iota    & Kappa\TblrNote{$\dag$} & Lambda \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha Alpha Alpha Alpha   & Beta Beta Beta Beta  & Gamma Gamma Gamma Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha Alpha Alpha Alpha   & Beta Beta Beta Beta  & Gamma Gamma Gamma Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha Alpha Alpha Alpha   & Beta Beta Beta Beta  & Gamma Gamma Gamma Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha Alpha Alpha Alpha   & Beta Beta Beta Beta  & Gamma Gamma Gamma Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha Alpha Alpha Alpha   & Beta Beta Beta Beta  & Gamma Gamma Gamma Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Alpha Alpha Alpha Alpha   & Beta Beta Beta Beta  & Gamma Gamma Gamma Gamma   \\
\hline
 Epsilon & Zeta  & Eta     \\
\hline
 Iota    & Kappa & Lambda  \\
\hline
 Nu      & Xi    & Omicron \\
\hline
 Rho     & Sigma & Tau     \\
\hline
 Phi     & Chi   & Psi     \\
\hline
 Foot    & Foot  & Foot    \\
\hline
\end{longtblr}

\end{document}

...以及生成的文档: 双列环境中的宽长表格,横跨两列

相关内容