24

Is it possible to use tabularx inside a longtable environment?

If not, is there any way I can get the "X" funcionality of tabularx with the option of long tables ---In order for me to be able to break them in two pages? Using longtabu is not an option, as stated by @jon here:

I would recommend staying away from tabu as the package author is still fiddling with things and explicitly promised that there would not be backwards compatibility. See here for the discussion.

UPDATE:

Using the package ltxtable suggested by @Alan Munn (Writeen by @David Carlisle) I have the current Minimal Non-Working Example

Main File:

\documentclass{article}

\usepackage{array}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{ltxtable}

\begin{document}
Hello.

\LTXtable{\textwidth}{VersionOne}

\end{document}  

Where the file VersionOne goes:

\begin{longtable}{XX}
\caption{A very long table}\\
WHO                 & \hspace{5mm} World Health Organization\\[1mm]
GDP                 & \hspace{5mm} Gross Domestic Product\\[1mm]
PPP                 & \hspace{5mm} Purchasing Power Parities\\[1mm]
\label{tab:LongtableOne}
\end{longtable}

When I try to run this code, I get a Emergency Stop and a fatal error. Am I writing this correctly?

Moriambar
  • 11,466
Mario S. E.
  • 18,609

2 Answers2

13

As stated in the comments for ltxtable the longtable has to be in a separate file. Processing the updated example (twice) with pdflatex produces

enter image description here

David Carlisle
  • 757,742
3

The new LaTeX3 package tabularray is an alternative to the outdated tabu package. You can use X columns in longtblr environment:

\documentclass{article}

\usepackage{tabularray} \UseTblrLibrary{booktabs}

\begin{document}

\begin{longtblr}[ caption = {A very long table}, label = {tab:LongtableOne}, ]{X[1]X[2]} \toprule WHO & World Health Organization \ GDP & Gross Domestic Product \ PPP & Purchasing Power Parities \ \bottomrule \end{longtblr}

\end{document}

enter image description here

L.J.R.
  • 10,932