TransWikia.com

Make ltablex inline rather than centered across textwidth

TeX - LaTeX Asked by David Purton on March 26, 2021

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

One Answer

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}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%

begin{document}

begin{enumerate}
  item Some text.
    {
    setlengthLTleftfill
    setlengthLTright{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

Correct answer by Zarko on March 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP