# LaTeX: multi-page table with centered cell' s content and adapted to column width

I am using Overleaf and need to create a multi-page table (longtable), composed by n rows and 3 columns, that has the following characteristics:

1. table width adapted to page width (column width);
2. first and second columns' cells content vertically and horizontally centered;
3. third columns' cells text wrapped.

Here is an example to better explain the format type I want to obtain:

I' ve made several attempts with these packages, but didn' t work quite well for all these characteristics:

• \begin{longtabu} to \columnwidth {|c|c|X|} not solving point 2 and generating a terrible row spacing;
• \begin{tabularx}{\columnwidth}{|c|c|X|} with \renewcommand{\tabularxcolumn}[1]{>{\arraybackslash}m{#1}} in the preamble (to vertically center the cells' content) works just fine but won't return a multi-page table.

• you can just use a normal longtable, with three p (or m) columns. You can set the column widths so the table is full width. – David Carlisle Jan 5 at 21:07

You could use xltabular for a table that automaticaly adapts to the textwidth and can span multiple pages. However, please be aware that page breaks can only occur between table rows, not within them.

\documentclass{article}
\usepackage{xltabular}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\usepackage[x11names,table]{xcolor}
\usepackage{makecell}

\usepackage{lipsum}
\begin{document}
\begin{xltabular}{\textwidth}{|>{\ttfamily}l|l|X|}
\caption{a caption text} \label{key}\\
\hline
\hline
text & text & \lipsum[4] \\
\hline
text & text & \lipsum[4] \\
\hline
text & text & \lipsum[4] \\
\hline
text & text & \lipsum[4] \\
\hline
text & text & \lipsum[4] \\
\hline
\end{xltabular}
\end{document}

• Thanks very much! How to add a caption? It gives me an error... – Luca Giovanni Voglino Jan 5 at 21:45
• @LucaGiovanniVoglino: I ahve updated my answer to also inlcude a caption. – leandriis Jan 5 at 21:49
• So appreciated, thx! – Luca Giovanni Voglino Jan 5 at 21:51