使用 xltabular 创建带有长表的两列

使用 xltabular 创建带有长表的两列

我有一本两栏的书,里面有跨多页的长表格。它们工作得很好,当然,长表格不适用于两栏文档。因此,我不得不求助于在长表格前后引入\onecolumn\twocolumn来使其工作,就像这个技巧在表格后引入分页符一样。

因此,我一直在试验这个xltabular软件包,试图找到解决分页符问题的方法,但似乎没有效果。

我是否注定要在双栏书中的长表格后添加分页符,不管它们是用longtable还是创建的xltablular?(是的,我的一些长表格有脚注)。

% PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[oneside,centered,twocolumn]{book}
%\documentclass[a4paper,oneside,centered,twocolumn]{book}
\special{papersize=215.9mm,279.4mm}
%\usepackage[top=3cm, bottom=3.2cm, left=2.5cm, right=2.5cm]{geometry}

\usepackage[english]{babel}
\usepackage{tocloft} % Customization of TOC LOF LOT
\usepackage[table,xcdraw]{xcolor} % For shading in tables
\usepackage{pdfcolmk}
\usepackage{multirow}
\usepackage{xltabular}

%\usepackage{lscape} %to put the long table of dwellings sideways
%\usepackage{wallpaper}
\usepackage{showframe}

\usepackage{textcomp}
\usepackage{pdfpages}
\usepackage{ltablex}
\usepackage{nicefrac} % to write fractions
\usepackage{attrib} % For source of quotations
\usepackage{lettrine} % For NewThought formatting
\usepackage{array} % To define width of columns in long table
\usepackage{booktabs} % Nicer spacing in columns
\usepackage{siunitx} % To write Celsius, etc.
\usepackage{enumitem} % To create item lists
\usepackage{caption} % To change way captions are labelled
\usepackage{scrextend}
\usepackage{threeparttable} % For table notes + To allow footnote material to stay with the tabular environment
\usepackage{etoolbox} % To make table footnote font smaller
\usepackage{threeparttablex}
\appto\TPTnoteSettings{\footnotesize}
\usepackage{textcomp} % For Numero symbol
\usepackage[T1]{fontenc}
\usepackage{titlesec,color}
\usepackage{blindtext}
\usepackage[linguistics,edges]{forest}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{titling}
\usepackage{fontspec}
\usepackage{newpxtext} % Font for document instead of obsolete Palatino

\usepackage{hyperref} % Hyperlinks

\newcommand{\mysplit}[1]{%
    \begin{tabular}[t]{@{}l@{}}   %% remove [t] if you need vertical centered things.
        #1
    \end{tabular}
}

\begin{document}

\onecolumn
\begin{xltabular}[l]{0.75\linewidth}{@{} lX @{}}
    \caption{The \texttt{xltabular} environment with \texttt{longtable} propertyand left aligned by setting the optional argument.}\\[\belowcaptionskip]
    \hline
    Left column & At first a line with some nonsense text to show how long this line is.The caption has the same width as the text.\\
    left column & \blindtext\\
    left column & \blindtext\\
    left column & \blindtext\\
    left column & \blindtext\\
    left column & \blindtext\\
    \hline
\end{xltabular}
\twocolumn

\blindtext

\end{document}

答案1

只有使用包才能实现双列模式的表格supertabular

\documentclass[twocolumn]{book}
\usepackage[english]{babel}
\usepackage{showframe}
\usepackage{array,supertabular}
\usepackage{booktabs} % Nicer spacing in columns
\usepackage{blindtext}
\newsavebox\WBox

\begin{document}

\sbox\WBox{Left column}% The widest entry in the l column   
\topcaption{The \texttt{xltabular} environment with \texttt{longtable} propertyand left aligned by 
    setting the optional argument.}
\begin{supertabular}{
  @{} 
  p{\wd\WBox}
  p{\dimexpr\columnwidth-\wd\WBox-2\tabcolsep\relax}
  @{}}\toprule
    Left column & At first a line with some nonsense text to show how long this line is.The caption has 
    the same width as the text.\\
    left column & \blindtext\\
    left column & \blindtext\\
    left column & \blindtext\\
    left column & \blindtext\\
    left column & \blindtext\\
\bottomrule
\end{supertabular}

\blindtext

\end{document}

相关内容