2

I have this code from this question answered by David Carlisle.
I don't fully understand what it's doing. I would like both tables to be full width.
Below is a minimal example where i would like the first table to be full width. The second table acts properly.

\documentclass[10pt,a4paper,oneside,onecolumn,openany]{report}

\usepackage{tabulary} \usepackage{tabularx} \usepackage{ltablex} \usepackage{ragged2e} \usepackage{longtable}

\usepackage[showframe]{geometry}

\makeatletter

\def\ltabulary{% \def\endfirsthead{\}% \def\endhead{\}% \def\endfoot{\}% \def\endlastfoot{\}% \def\tabulary{% \def\TY@final{% \def\endfirsthead{\LT@end@hd@ft\LT@firsthead}% \def\endhead{\LT@end@hd@ft\LT@head}% \def\endfoot{\LT@end@hd@ft\LT@foot}% \def\endlastfoot{\LT@end@hd@ft\LT@lastfoot}% \longtable}% \let\endTY@final\endlongtable \TY@tabular}% \tabulary}

\def\endltabulary{\endtabulary}

\makeatother

\begin{document}

\hspace*{0pt}\tymin=50pt\tymax=400pt\begin{ltabulary}{\textwidth}{|L|L|} \hline

\rule{0pt}{4mm}\textbf{\hspace{0pt}Fuz} & \textbf{\hspace{0pt}Baz} \ \hline

\rule{0pt}{4mm}A & B \ \hline \rule{0pt}{4mm}C & D \ \hline

\end{ltabulary}

\hspace*{0pt}\tymin=50pt\tymax=400pt\begin{ltabulary}{\textwidth}{|L|L|} \hline

\rule{0pt}{4mm}\textbf{\hspace{0pt}Fuz} & \textbf{\hspace{0pt}Baz} \ \hline

\rule{0pt}{4mm}AAAAAAAAAA & BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB \ \hline \rule{0pt}{4mm}C & D \ \hline

\end{ltabulary}

\end{document}

Output:

enter image description here

Thanks.

  • have alook athe answer below adapted from -- https://tex.stackexchange.com/a/574443/197451 -- the width of the two columns are equal the left column width can be changed to choice by usin dimension iin cms in {0.5\textwidth} -- the double XX athe end are only to demonstrate expansion to textwidth and can be safely removed – js bibra Dec 10 '20 at 15:34

2 Answers2

1

enter image description here

Just because it seemed like a good idea at the time TY doesn't ever stretch a table, if its natural width is less than the target width it is set natural size.

There is no easy way to change that design choice in the code, so the easiest thing to do if that occurs, but you want to force the target width, is to add a space (more or less arbitrary) to the cells to make the natural cell width wider (the space will be dropped at the end of the paragraph anyway so the exact amount isn't too important. I just gave width to B here but you could add some to A as well if you want to stretch both columns.

So in the first table, use

\rule{0pt}{4mm}A & B\hspace{\textwidth} \\ \hline
David Carlisle
  • 757,742
0

enter image description here

\documentclass{article}
\usepackage{tabularx,ragged2e,booktabs,lipsum}
\newcommand\mydesc[2]{#1 & #2 \\ \addlinespace}
\begin{document}
\noindent % <-- may be omitted if `\parindent` is equal to 0pt
\begin{tabularx}{\textwidth}{@{} w{l}{0.5\textwidth} >{\RaggedRight}X @{}}
    \toprule
    \multicolumn{1}{c}{\textbf{Fuz}}& \multicolumn{1}{c}{\textbf{Baz}}\\
    \midrule
    {Lorem}&{\lipsum[1][1-4]}\\
    \midrule
    {Ipsum}&{\lipsum[2][1-3]}\\
    \bottomrule
\end{tabularx}

X\hrulefill X \end{document}

js bibra
  • 21,280
  • This is not exactly what im looking for. I want the columns to adjust according to their content. So the Fuz column should be way smaller than the Bar one. – Leon Bartz Dec 10 '20 at 15:54