Replies: 16 comments 1 reply
-
|
Issue #100 (about X columns with both |
Beta Was this translation helpful? Give feedback.
-
|
@note286 You can use Also you can use traditional \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} |
Beta Was this translation helpful? Give feedback.
-
|
I am planning to add a new inner key
When When |
Beta Was this translation helpful? Give feedback.
-
|
If change the width of paper, I found \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 \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}QuestionWhen there are positive \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 |
Beta Was this translation helpful? Give feedback.
-
Columns with larger natural widths get more extra space. You could read chapter 11 of |
Beta Was this translation helpful? Give feedback.
-
Sorry, it turns out that my memory on |
Beta Was this translation helpful? Give feedback.
-
|
We can also consider what |
Beta Was this translation helpful? Give feedback.
-
Perhaps the column types of the |
Beta Was this translation helpful? Give feedback.
-
I know I’m a bit late to the party, but I started using the (awesome!) tabularray package only recently. I realized that I would also appreciate having the envisioned Currently, there seems to be a single workaround to automatically achieve a uniform distribution of space between columns of natural width when using tabularray-only environments: inserting artificial, empty This yields exactly the same spacing as the traditional \documentclass[11pt, a4paper]{article}
\usepackage{newtx}
\usepackage[T1]{fontenc}
\usepackage[margin = 3cm]{geometry}
\usepackage{caption}
\captionsetup[table]{position = above}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}
\UseTblrLibrary{booktabs}
\SetTblrInner[booktabs]{
hline{1} = {\heavyrulewidth, solid},
hborder{1} = {abovespace = \abovetopsep, belowspace = \belowrulesep},
cells = {font = \small},
hline{Z} = {\heavyrulewidth, solid},
hborder{Z} = {abovespace = \aboverulesep, belowspace = \belowbottomsep},
column{1} = {leftsep = 0pt},
column{Z} = {rightsep = 0pt},
width = \textwidth,
}
\begin{document}
\begin{table}[h]
\caption{A~\texttt{tblr} table with natural-width \texttt{X[-1]}~columns}
\begin{booktabs}{*{7}{X[-1, l]} l}
Test & Test 1 & Test 12 & Test 123 & Test 1234 & Test 12345 & Test 123456 & Test 1234567
\end{booktabs}
\end{table}
\begin{table}[h]
\caption{A~\texttt{tblr} table with artificial, empty \texttt{X}~columns inserted between actual columns}
\begin{booktabs}{
colspec = {l *{7}{X l}},
colsep = 0pt,
}
Test & & Test 1 & & Test 12 & & Test 123 & & Test 1234 & & Test 12345 & & Test 123456 & & Test 1234567
\end{booktabs}
\end{table}
\begin{table}[h]
\caption{A~traditional \texttt{tabular*} table with \texttt{@\{\textbackslash extracolsep\{\textbackslash fill\}\}}}
\begin{booktabs}{X}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{7}{l} l @{}}
Test & Test 1 & Test 12 & Test 123 & Test 1234 & Test 12345 & Test 123456 & Test 1234567
\end{tabular*}
\end{booktabs}
\end{table}
\end{document}
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
You can, of course, also put this in a command (requires the calc package) such as \newlength{\TblrNaturalWidth}
\newlength{\TblrTotalColSep}
\newcommand{\booktabsTextwidth}[3]{%
% Argument 1: #columns across which to distribute the space
% Argument 2: Layout specifications such as colspec, row, cells, etc.
% Argument 3: Contents of the table
\settowidth{\TblrNaturalWidth}{%
\begin{booktabs}{#2}
#3
\end{booktabs}%
}%
\setlength{\TblrTotalColSep}{\textwidth - \TblrNaturalWidth}%
\begin{booktabs}{column{1-Z} = {colsep+ = 0.5\TblrTotalColSep / #1}, #2}
#3
\end{booktabs}%
}Or, even more flexibly: \newcommand{\BooktabsToWidth}[4][\textwidth]{%
% Optional argument (#1): desired width, default: \textwidth
% Mandatory argument (#2): #columns across which to distribute the space
% Mandatory argument (#3): specifications such as colspec, row, cells, etc.
% Mandatory argument (#4): contents of the table
\settowidth{\TblrNaturalWidth}{%
\begin{booktabs}{#3}
#4
\end{booktabs}%
}%
\setlength{\TblrTotalColSep}{#1 - \TblrNaturalWidth}%
\begin{booktabs}{column{1-Z} = {colsep+ = 0.5\TblrTotalColSep / #2}, #3}
#4
\end{booktabs}%
}Here are a few examples typeset with \setlength{\parindent}{0pt}
{\color{blue} Rule to visualize the \texttt{\textbackslash textwidth} \\
\rule{\textwidth}{0.2cm}}
\bigskip
\booktabsTextwidth{7}{
colspec = {*{7}{|l|}},
}{%
\toprule
Test & Test 1 & Test 12 & Test 123 & Test 1234 & Test 12345 & Test 123456 \\
\bottomrule
}
\bigskip
\booktabsTextwidth{6}{
colspec = {*{7}{l}},
column{1} = {leftsep = 0pt},
column{Z} = {rightsep = 0pt},
row{2} = {valign = m},
}{
\toprule
Test & Test 1 & Test 12 & Test 123 & Test 1234 & Test 12345 & Test 123456 \\
\midrule
$f(x)$ & $\displaystyle\frac{\sqrt{3}}{n}$ & Test & \SetCell[c=3]{c} Content spanning multiple cells & & & {Row~1 \\ Row~2} \\
\bottomrule
}
\bigskip
For comparison, \texttt{tabular*} environment with \texttt{@\{\textbackslash extracolsep\{\textbackslash fill\}\}}:
\bigskip
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{7}{l} @{}}
\toprule
Test & Test 1 & Test 12 & Test 123 & Test 1234 & Test 12345 & Test 123456 \\
\bottomrule
\end{tabular*}
|
Beta Was this translation helpful? Give feedback.
-
|
There is one problem if we want to follow what |
Beta Was this translation helpful? Give feedback.
-
|
Hi Ivjr, Is there any possibility to handle equal intercolumn space for the Table column with more content? Example Table body with more content: |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Hi Holger Gerhardt, In addition to this, When i use longtblr (from tabularray) with rowspan, the table cannot break across pages inside a spanning cell. |
Beta Was this translation helpful? Give feedback.










Uh oh!
There was an error while loading. Please reload this page.
-
Discussed in #362
Originally posted by note286 February 4, 2023
In the table above, we set
colsep = 0pt. I hope tblr can automatically complete the setting ofcolsepso that the table width is the specified width, such as\textwidth.I try to set
colsep = 7.5ptto meet the demand in this example. But this is inconvenient and not accurate. Whether there is a method to automatically complete this step. If you can provide an interface, such aswidth = \textwidth, colsep = autofill, it will be even better.I know the existence of the
Xcolumn format, but I don't want this. In many cases, the proportion between columns is not easy to see, so it is not very convenient to use theXcolumn format. All I want is to setcolsepautomatically.Beta Was this translation helpful? Give feedback.
All reactions