0

I would like my table to have the size of the text in the columns, not fit the whole page as currently is in the example at the bottom. Anyone knows how to fix this?

enter image description here

Code below:

\documentclass{article}
\usepackage[letterpaper,margin=2.5cm]{geometry}
\usepackage{pdflscape}
\usepackage{xltabular} 
\usepackage{ragged2e}  
\newcolumntype{L}{>{\RaggedRight\hangafter1\hangindent1em}X}
\usepackage{booktabs}
\newlength\mylen
\setlength\mylen{\textheight}

\begin{document}


\begin{xltabular}{\textwidth}{@{} ll @{}}

\caption{xxxxxxxxx xxxxxxxxx xxxxx xxx xxxxx xxxxxxxxxxxxxxxx xxxxxxxxx xxxxx xxx xxxxx xxxxxxx xxxxxxxxx xxxxxxxxx xxxxx xxx xxxxx xxxxxxx}
\label{tab:my-table}\\
\toprule
\textbf{xxxxxxxxx} & \textbf{xxxxxxxxx} \\ 
\midrule
\endfirsthead

\multicolumn{2}{@{}p{\textwidth}@{}}
{Table \thetable: xxxxxxxxx xxxxxxxxx xxxxx xxx xxxxx xxxxxxxxxxxxxxxx xxxxxxxxx xxxxx xxx xxxxx xxxxxxx xxxxxxxxx xxxxxxxxx xxxxx xxx xxxxx xxxxxxx (Continued)} \\ \addlinespace[14.4pt]
\toprule
\textbf{xxxxxxxxx} & \textbf{xxxxxxxxx} \\ 
\midrule
\endhead

\bottomrule
\endlastfoot

%% body of table
\multicolumn{2}{@{}l}{\textbf{xxxxxxxxxxx}} \\[0.25ex]
xxxxxxxxxx xxxxxxxxxx xxxx xxxxx xxxxxxxx xxxxxxxxxxxx & zzzz zzzz zzzz \\
xxxxxxx xxxxxxxx xxxxxx xxxxxx xxxxxx xxxxx xxxxx xx & zzzz zzzz zzzz \\
xxxxxxx xxxxxx xxxxxxxxx xxxxxx xxxxxxxxxx xxxxxx & zzzz zzzz zzzz \\
xxxxxxx xxxxxx xxxxxxxxx xxxxxx xxxxxxxxxx xxxxxxxxxxxxx & zzzz zzzz zzzz \\
xxxxxxx xxxxxx xxxxxxxxx xxxxxx xxxxxxxxxx xxxx & zzzz zzzz zzzz \\

\addlinespace 
\multicolumn{2}{@{}l}{\textbf{xxxxxxxxxxxx}} \\[0.25ex]
xxxxxxx xxxxxx xxxxxxxxx xxxxxx xxxxxxxxxx xxxxx & zzzz zzzz zzzz \\
xxxxxx xxxxxx xxxxxxxxxx xxxxxxx & zzzz zzzz zzzz \\
xxxxxxx xxxxxx xxxxxxx & zzzz zzzz zzzz \\
xxxxxxx xxxxxx xxxxxxxxx xxxxxx xxxxxxxx & zzzz zzzz zzzz \\
xxxxxxx xxxxxx xxxxxxxxx xxxxxx xxxxxxxxxx xxxxx & zzzz zzzz zzzz \\
xxxxxx xxxxxx xxxxxxxxxx xxxxxxx & zzzz zzzz zzzz \\

%\hline
\end{xltabular}

\end{document}
8
  • 4
    you are forcing that with \begin{xltabular}{\textwidth}{@{} Lllll @{}} use a standard longtable instead ` Commented Jun 14, 2023 at 13:01
  • 2
    why are you using a table at all as every row only has one entry??? Commented Jun 14, 2023 at 13:02
  • 3
    xltabular is a minor extension of longtable that just adds the feature that you are asking to remove. Commented Jun 14, 2023 at 14:18
  • 1
    Does your real document -- as opposed to the test document shown above -- employ a two-column layout? If so, you should probably be thinking of using a supertabular environment, not an xltabular environment. Please advise.
    – Mico
    Commented Jun 14, 2023 at 15:40
  • 1
    Please clarify what your opening sentence, "I would like my table to have the size of the text in the columns", could mean. Which columns? What is "size of the text in the columns" supposed to mean?
    – Mico
    Commented Jun 14, 2023 at 21:16

0

You must log in to answer this question.

Browse other questions tagged .