1

I'm using ltablex to make a long tablularx environment. I notice that it seems to centre the table across the page rather than putting it inline like tabularx does. This causes problems for me because I want the table as part of an enumerate list.

How can I make the table return to being set inline?

MWE

\documentclass{article}

\usepackage[a6paper,landscape,margin=3cm]{geometry}
\usepackage{booktabs,ltablex}
\keepXColumns

\begin{document}

\begin{enumerate}
  \item Some text.

    \begin{tabularx}{\linewidth}{XX}
      \toprule
      a & b \\
      \midrule
      a & b \\
      \midrule
      a & b \\
      \midrule
      a & b \\
      \midrule
      a & b \\
      \midrule
      a & b \\
      \midrule
      a & b \\
      \midrule
      a & b \\
      \midrule
      a & b \\
      \bottomrule
    \end{tabularx}

\end{enumerate}

\end{document}

Output

Page 1:

ltablex page 1

Page 2:

ltablex page 2

Output without ltablex for comparison

This was created just with \usepackage{booktabs,tabularx}. Notice that the table lines up with the text in the enumerate environment:

tabularx page 1

1
  • 2
    longtable are necessarily full width, to allow page breaking but you can set \LTleft to \leftmargin to get the same indent as the list. Commented Sep 21, 2020 at 7:18

1 Answer 1

2

Try the following:

\documentclass{article}
\usepackage[a6paper,landscape,margin=3cm]{geometry}
\usepackage{booktabs,ltablex}
\keepXColumns
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}

\begin{enumerate}
  \item Some text.
    {
    \setlength\LTleft\fill
    \setlength\LTright{0pt}
    \begin{tabularx}{\linewidth}{XX}
      \toprule
      a & b \\
      \midrule
      a & b \\
      \midrule
      a & b \\
      \midrule
      a & b \\
      \midrule
      a & b \\
      \midrule
      a & b \\
      \midrule
      a & b \\
      \midrule
      a & b \\
      \midrule
      a & b \\
      \bottomrule
    \end{tabularx}
    }
\end{enumerate}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .