# Two-columns table in tabularx with \textwidth

I have a problem with setting up a table, created in tabularx, to the text width of my article. What can I do?

Here is the dummy example:

\documentclass[12pt]{article}
\usepackage{ltablex,booktabs}
\usepackage{lipsum}

\begin{document}

\lipsum[100]
\begin{tabularx}{\textwidth}{lX}
\caption{cccc} \\
\toprule
\textbf{Definition} & \textbf{Counts} \\
\midrule

\textit{A}             &  68\\
\textit{B}             &  10\\
\textit{C}             &  10\\
\midrule
$\sum$                 &  88\\

\bottomrule
\end{tabularx}
\end{document}


The PDF view:

• At least one X column is required. – Bernard Oct 2 '18 at 15:25
• Could you post a full compilable code, not just a snippet? – Bernard Oct 2 '18 at 15:33
• (i) please provide complete small document with your table and image of table (your table has width of text).; (ii) off-topic: \caption should not be inside tabularx environment – Zarko Oct 2 '18 at 15:33
• Your code doesn't even load tabularx! – Bernard Oct 2 '18 at 15:55
• please always post a complete small document that shows the problem, I would guess you are using the ltablex package but you do not say. – David Carlisle Oct 2 '18 at 16:16

This is a ltablex "feature" which you can turn off as shown, however there is no reason to stretch the tabular, it just makes it harder to read, if you use a centered tabular it is fine.

\documentclass[12pt]{article}
\usepackage{ltablex,booktabs}
\keepXColumns
\begin{document}

\begin{tabularx}{\textwidth}{lX}
\caption{cccc} \\
\toprule
\textbf{Definition} & \textbf{Counts} \\
\midrule

\textit{A}             &  68\\
\textit{B}             &  10\\
\textit{C}             &  10\\
\midrule
$\sum$                 &  88\\

\bottomrule
\end{tabularx}

\end{document}

• Carlile: I found the solution! It looks it's not enough to add \keepXColumns, as you suggested, but I had to tweak a bit the line \begin{tabularx}{\textwidth}{lX} to the following one \begin{tabularx}{\linewidth}{Xr} – Jo-Achna Oct 2 '18 at 16:38