# Two columns with longtables created with xltabular

So I have this two column book which has long tables that span multiple pages. They work well, expect, of course, that long tables don't work with two column documents. I therefore have to resort to introducing \onecolumn and \twocolumn before and after said long table to make it work, sort of, as the trick introduces page breaks after the table.

So, I've been experimenting with the xltabular package to try and find a solution around this problem of page breaks, but it doesn't seem to work.

Am I condemned to having page breaks after my long tables in my two column book, whether they are create with longtable or xltablular ? (and yes, some of my long tables have foot notes).

% 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

\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}

• unrelated but your font usage is wrong. You are using \usepackage{fontspec} so you must be using xetex or luatex so you should not be using 8bit T1 encoded fonts, so should not have \usepackage[T1]{fontenc} or \usepackage{newpxtext} – David Carlisle Apr 29 at 19:30
• I've been made aware of the issue you raise in previous questions of mine, but I forgot about it until your note. I shall post a question about the problem asap. Thank you. – CyanideBaby Apr 29 at 22:02

A tabular in twocolumn mode is only possible with package 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}

• Thank you @Red-Cloud. I explained myself poorly it seems as I'm not looking to have my tables laid out in two columns. The text is laid out in two columns, but the tables themselves are laid out over the whole width of the page -- they actually could never work as two column tables as they are too large. So, I guess that leaves me with no choice but to live with those page breaks then. – CyanideBaby Apr 29 at 21:54