Open lvjr opened 1 year ago
Issue #100 (about X columns with both co
and wd
settings) is related.
@note286 You can use X
columns with negative coefficients. The result is similar (but not totally the same) to that of manually setting colsep=7.5pt
. See the documentaion of tabu
package for how extra space is distributed among X
columns.
Also you can use traditional tabular*
environment to fill extra spaces. But when there are vertical lines the result is not ideal.
\documentclass{article}
\usepackage{showframe}
\usepackage{tabularray}
\begin{document}
\section{\texttt{tabularray}: minimal width}
\begin{center}
\begin{tblr}{
colspec = {*{6}{l}},
colsep = 0pt,
hlines,vlines
}
Lorem & ipsum & dolor & sit & amet & consectetur \\
tempor & incididunt & ut & labore & et & dolore \\
quis & nostrud & exercitation & ullamco & laboris & nisi \\
consequat & Duis & aute & irure & dolor & in \\
cillum & dolore & eu & fugiat & nulla & pariatur \\
\end{tblr}
\end{center}
\section{\texttt{tabularray}: calculated \texttt{colsep}}
\begin{center}
\begin{tblr}{
colspec = {*{6}{l}},
colsep = 7.5pt,
hlines,vlines
}
Lorem & ipsum & dolor & sit & amet & consectetur \\
tempor & incididunt & ut & labore & et & dolore \\
quis & nostrud & exercitation & ullamco & laboris & nisi \\
consequat & Duis & aute & irure & dolor & in \\
cillum & dolore & eu & fugiat & nulla & pariatur \\
\end{tblr}
\end{center}
\section{\texttt{tabularray}: \texttt{X[-1]} columns}
\begin{center}
\begin{tblr}{
colspec = {*{6}{X[l,-1]}},
hlines,vlines
}
Lorem & ipsum & dolor & sit & amet & consectetur \\
tempor & incididunt & ut & labore & et & dolore \\
quis & nostrud & exercitation & ullamco & laboris & nisi \\
consequat & Duis & aute & irure & dolor & in \\
cillum & dolore & eu & fugiat & nulla & pariatur \\
\end{tblr}
\end{center}
\section{\texttt{tabular*}: \texttt{\string\extracolsep}}
\begin{center}
%\setlength\tabcolsep{0pt}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|*{6}{l|}}
\hline
Lorem & ipsum & dolor & sit & amet & consectetur \\
\hline
tempor & incididunt & ut & labore & et & dolore \\
\hline
quis & nostrud & exercitation & ullamco & laboris & nisi \\
\hline
consequat & Duis & aute & irure & dolor & in \\
\hline
cillum & dolore & eu & fugiat & nulla & pariatur \\
\hline
\end{tabular*}
\end{center}
\end{document}
I am planning to add a new inner key hspacing
which takes the following possible values:
default
: distribute total available space to the widths of X
columns.fixed
: similar to default
, but colseps and borders are included into column widths in calculation (#292).colsep
: distribute extra space to the colseps of X
columns (#362).When hspacing=fixed
, users can only use positive coefficients and it is better to make sure rules=smash
is also applied (#215). We first subtract half of the widths of the first and last vborders from total width and then distribute remaining width to all columns in proportion to their coefficients.
When hspacing=colsep
, users can only use positive coefficients and all cell text must be short.
If change the width of paper, I found X[-1]
is not not working correctly.
\documentclass{article}
\usepackage[margin=5mm]{geometry}
\usepackage{showframe}
\usepackage{tabularray}
\begin{document}
\section{\texttt{tabularray}: \texttt{X[-1]} columns}
\begin{center}
\begin{tblr}{
colspec = {*{6}{X[l,-1]}},
hlines,vlines
}
Lorem & ipsum & dolor & sit & amet & consectetur \\
tempor & incididunt & ut & labore & et & dolore \\
quis & nostrud & exercitation & ullamco & laboris & nisi \\
consequat & Duis & aute & irure & dolor & in \\
cillum & dolore & eu & fugiat & nulla & pariatur \\
\end{tblr}
\end{center}
\end{document}
I read the tabu
document and got a certain understanding of using negative number in column X
. A positive number means that the column width is fixed, but in the case of a negative number, if the column content width is less than the set width, the natural width will be displayed. This is a example:
\documentclass{article}
\usepackage[margin=5mm]{geometry}
\usepackage{showframe}
\usepackage{tabularray}
\begin{document}
\begin{center}
\begin{tblr}{colspec={X[-1]X[-2]X[1]},hlines,vlines,colsep=0pt}
Lorem ipsum dolor sit amet & consectetur adipisicing elit sed do eiusmod & tempor incididunt ut \\
\end{tblr}
\end{center}
\begin{center}
\begin{tblr}{colspec={X[-1]X[-2]X[1]},hlines,vlines,colsep=0pt}
Lorem ipsum & consectetur adipisicing elit sed do eiusmod labore et dolore magna aliqua Ut enim ad minim veniam & tempor incididunt ut \\
\end{tblr}
\end{center}
\end{document}
When there are positive X
columns, everything can be understood. When all column formats are negative, how is the width of each column allocated? For example, the following example makes me very confused.
\documentclass{article}
\usepackage[margin=5mm]{geometry}
\usepackage{showframe}
\usepackage{tabularray}
\begin{document}
\begin{center}
\begin{tblr}{colspec={X[-1]X[-1]X[-1]},hlines,vlines,colsep=0pt}
Lorem ipsum & Lorem ipsum Lorem ipsum & Lorem ipsum \\
\end{tblr}
\end{center}
\end{document}
Finally, I'm looking forward to the new inner key hspacing
.
When all column formats are negative, how is the width of each column allocated?
Columns with larger natural widths get more extra space.
You could read chapter 11 of tabu
documentation if you are still confused.
A positive number means that the column width is fixed
Sorry, it turns out that my memory on X
columns is inaccurate: when all coefficents of X
columns are positive, the column widths are fixed. I have updated my comments above accordingly.
We can also consider what tabulary
package does: distributing widths according to natural widths of columns. See discussion https://github.com/lvjr/tabularray/discussions/397.
We can also consider what
tabulary
package does: distributing widths according to natural widths of columns. See discussion #397.
Perhaps the column types of the tabulary
are so different as to warrant a separate letter? Y
?
Discussed in https://github.com/lvjr/tabularray/discussions/362