Skip to content

Other ways to distribute space for X columns #365

Closed

Description

@lvjr

Discussed in #362

Originally posted by note286 February 4, 2023

\documentclass{article}
\usepackage{showframe}
\usepackage{tabularray}
\begin{document}
\begin{table}
\centering
\caption{title}
\begin{tblr}
{
colspec = {*{6}{l}},
% colsep  = 7.5pt,
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    \\
proident  & sunt       & in           & culpa   & qui     & officia     \\
\end{tblr}
\end{table}
\end{document}

image

In the table above, we set colsep = 0pt. I hope tblr can automatically complete the setting of colsep so that the table width is the specified width, such as \textwidth.

image

I try to set colsep = 7.5pt to 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 as width = \textwidth, colsep = autofill, it will be even better.

I know the existence of the X column 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 the X column format. All I want is to set colsep automatically.

Activity

  1. lvjr commented on Feb 11, 2023

    @lvjr
    CollaboratorAuthor

    Issue #100 (about X columns with both co and wd settings) is related.

  2. added
    Awaiting DecisionMaintainers are coming to a consensus to finalise a decision
    on Feb 11, 2023
  3. lvjr commented on Feb 11, 2023

    @lvjr
    CollaboratorAuthor

    @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}

    image

  4. lvjr commented on Feb 11, 2023

    @lvjr
    CollaboratorAuthor

    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.

  5. note286 commented on Feb 11, 2023

    @note286

    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}

    image


    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}

    image

    Question

    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}

    image


    Finally, I'm looking forward to the new inner key hspacing.

  6. lvjr commented on Feb 13, 2023

    @lvjr
    CollaboratorAuthor

    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.

  7. lvjr commented on Feb 15, 2023

    @lvjr
    CollaboratorAuthor

    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.

  8. removed
    Awaiting DecisionMaintainers are coming to a consensus to finalise a decision
    on Feb 15, 2023
  9. changed the title [-]Other ways to distribute extra space for X columns[/-] [+]Other ways to distribute space for X columns[/+] on Feb 15, 2023
  10. lvjr commented on Apr 19, 2023

    @lvjr
    CollaboratorAuthor

    We can also consider what tabulary package does: distributing widths according to natural widths of columns. See discussion #397.

  11. fredrikpaues commented on Apr 21, 2023

    @fredrikpaues

    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?

  12. HolgerGerhardt commented on Mar 26, 2025

    @HolgerGerhardt

    Finally, I'm looking forward to the new inner key hspacing.

    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 hspacing option.

    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 X columns to separate the actual columns.

    This yields exactly the same spacing as the traditional tabular* environment with @{\extracolsep{\fill}}. By contrast, using X[-1] columns leads to slightly different spacing, as @lvjr already pointed out:

    \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}
    Image
  13. HolgerGerhardt commented on Mar 26, 2025

    @HolgerGerhardt

    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 X columns to separate the actual columns.

    I have to correct myself. Here is an approach that does not mess with the number of columns in the table:

    \documentclass[a4paper]{article}
    
    
    \usepackage{newtx}
    \usepackage[T1]{fontenc}
    
    \usepackage[margin = 3cm]{geometry}
    
    \usepackage{calc}
    
    \usepackage{tabularray}
    \UseTblrLibrary{booktabs}
    
    \setlength{\parindent}{0pt}
    
    
    \begin{document}
    
    {\color{blue} Rule to visualize the \texttt{\textbackslash textwidth} \\
    \rule{\textwidth}{0.2cm}}
    
    \newlength{\TblrNaturalWidth}
    \newlength{\TblrTotalColSep}
    \settowidth{\TblrNaturalWidth}{%
      \begin{booktabs}{
        colspec = {*{8}{l}},
        colsep = 0pt,
      }
        \toprule
        Test & Test 1 & Test 12 & Test 123 & Test 1234 & Test 12345 & Test 123456 & Test 1234567 \\
        \bottomrule
      \end{booktabs}%
    }
    \setlength{\TblrTotalColSep}{\textwidth - \TblrNaturalWidth}
    
    \bigskip
    
    \texttt{tblr} (\texttt{booktabs}) environment with \texttt{colsep} calculated from the difference between its natural width and \texttt{\textbackslash textwidth}:
    
    \bigskip
    
    \begin{booktabs}{
      colspec = {*{8}{l}},
      colsep = \TblrTotalColSep / 14,
      column{1} = {leftsep = 0pt},
      column{Z} = {rightsep = 0pt},
    }
      \toprule
      Test & Test 1 & Test 12 & Test 123 & Test 1234 & Test 12345 & Test 123456 & Test 1234567 \\
      \bottomrule
    \end{booktabs}%
    
    \bigskip
    
    For comparison, \texttt{tabular*} environment with \texttt{@\{\textbackslash extracolsep\{\textbackslash fill\}\}}:
    
    \bigskip
    
    \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{8}{l} @{}}
      \toprule
      Test & Test 1 & Test 12 & Test 123 & Test 1234 & Test 12345 & Test 123456 & Test 1234567 \\
      \bottomrule
    \end{tabular*}
    
    \end{document}

    This yields:

    Image
  14. HolgerGerhardt commented on Mar 26, 2025

    @HolgerGerhardt

    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 \booktabsTextwidth:

    \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*}
    Image
  15. lvjr commented on Jul 23, 2025

    @lvjr
    CollaboratorAuthor

    There is one problem if we want to follow what tabular* does: if the natural width of a table is larger than \textwidth, the table will overflow. Should we do something to prevent the overflow in this case?

  16. pratap120431 commented on Jul 25, 2025

    @pratap120431

    Hi Ivjr, Is there any possibility to handle equal intercolumn space for the Table column with more content?

    Example Table body with more content:
    \toprule
    Test Test Test Test Test Test Test Test Test Test & Test Test Test Test Test Test Test Test Test Test Test 1 & Test Test Test Test Test Test Test Test Test Test Test 12 & Test Test Test Test Test Test Test Test Test Test Test 123 & Test Test Test Test Test Test Test Test Test Test Test 1234 & Test Test Test Test Test Test Test Test Test Test Test 12345 & Test Test Test Test Test Test Test Test Test Test Test 123456 & Test Test Test Test Test Test Test Test Test Test Test 1234567 \
    \bottomrule

  17. HolgerGerhardt commented on Aug 16, 2025

    @HolgerGerhardt

    There is one problem if we want to follow what tabular* does: if the natural width of a table is larger than \textwidth, the table will overflow. Should we do something to prevent the overflow in this case?

    Good catch!

    With the code that I suggested, tblr does not generate an overflowing table (while tabular* does). Instead, the code reduces colsep and thereby makes the columns move closer to each other—which I find quite nice, actually.

    Of course, if the natural width exceeds the target width by too much, the columns will not be visually separated anymore or even overlap. I would thus suggest to issue a warning message in the case that colsep becomes negative (or, say, less than 1em).

    Here’s an illustration of what I describe above:

    Image

    And here’s the code for that example:

    \documentclass{article}
    
    
    \usepackage{calc}
    \usepackage[margin = 3cm]{geometry}
    \usepackage{newtx}
    \usepackage[T1]{fontenc}
    
    \usepackage{tabularray}
    \UseTblrLibrary{booktabs}
    \newlength{\TblrNaturalWidth}
    \newlength{\TblrTotalColSep}
    \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}%
    }
    
    
    \begin{document}
    
    
    \section{Various Tests}
    
    \setlength{\parindent}{0pt}
    
    {\color{blue} Rule to visualize the \texttt{\textbackslash textwidth} \\
    \rule{\textwidth}{0.2cm}}
    
    \bigskip
    
    \BooktabsToWidth{7}{
      colspec = {*{7}{|l|}},
    }{%
      \toprule
      Test & Test 1 & Test 12 & Test 123 & Test 1234 & Test 12345 & Test 123456 \\
      \bottomrule
    }
    
    \bigskip
    
    Now without any vertical rules:
    
    \medskip
    
    \BooktabsToWidth{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
    }
    
    \medskip
    
    \BooktabsToWidth{6}{
      colspec = {@{} *{7}{l} @{}},
    }{%
      \toprule
      Test & Test 1 & Test 12 & Test 123 & Test 1234 & Test 12345 & Test 123456 \\
      \bottomrule
    }
    
    \bigskip
    
    For comparison, \texttt{tabular*} environment with \texttt{@\{\textbackslash extracolsep\{\textbackslash fill\}\}}:
    
    \medskip
    
    \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{7}{l} @{}}
      \toprule
      Test & Test 1 & Test 12 & Test 123 & Test 1234 & Test 12345 & Test 123456 \\
      \bottomrule
    \end{tabular*}
    
    \section{Overflow Tests}
    
    \subsection{Slight Overflow}
    
    With \texttt{\textbackslash BooktabsToWidth[\textbackslash textwidth]\{6\}\{colspec = \{@\{\} *\{7\}\{l\} @\{\}\}\}\{...\}}:
    
    \medskip
    
    \BooktabsToWidth[\textwidth]{6}{
      colspec = {@{} *{7}{l} @{}},
    }{%
      \toprule
      Test Test & Test Test 01 & Test Test 012 & Test Test 0123 & Test Test 01234 & Test Test 012345 & Test Test 0123456 \\
      \midrule
      I & II & III & IV & V & VI & VII \\
      \bottomrule
    }
    
    \bigskip
    
    For comparison, \texttt{tabular*} environment with \texttt{@\{\textbackslash extracolsep\{\textbackslash fill\}\}}:
    
    \medskip
    
    \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{7}{l} @{}}
      \toprule
      Test Test & Test Test 01 & Test Test 012 & Test Test 0123 & Test Test 01234 & Test Test 012345 & Test Test 0123456
      \\
      \midrule
      I & II & III & IV & V & VI & VII \\
      \bottomrule
    \end{tabular*}
    
    \subsection{Substantial Overflow}
    
    With \texttt{\textbackslash BooktabsToWidth[\textbackslash textwidth]\{6\}\{colspec = \{@\{\} *\{7\}\{l\} @\{\}\}\}\{...\}}:
    
    \medskip
    
    \BooktabsToWidth[\textwidth]{6}{
      colspec = {@{} *{7}{l} @{}},
    }{%
      \toprule
      Test Test Test & Test Test Test 1 & Test Test Test 12 & Test Test Test 123 & Test Test Test 1234 & Test Test Test 12345 & Test Test Test 123456 \\
      \midrule
      I & II & III & IV & V & VI & VII \\
      \bottomrule
    }
    
    \bigskip
    
    For comparison, \texttt{tabular*} environment with \texttt{@\{\textbackslash extracolsep\{\textbackslash fill\}\}}:
    
    \medskip
    
    \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{7}{l} @{}}
      \toprule
      Test Test Test & Test Test Test 1 & Test Test Test 12 & Test Test Test 123 & Test Test Test 1234 & Test Test Test 12345 & Test Test Test 123456 \\
      \midrule
      I & II & III & IV & V & VI & VII \\
      \bottomrule
    \end{tabular*}
    
    
    \end{document}
  18. HolgerGerhardt commented on Aug 16, 2025

    @HolgerGerhardt

    Hi Ivjr, Is there any possibility to handle equal intercolumn space for the Table column with more content?

    Example Table body with more content: \toprule Test Test Test Test Test Test Test Test Test Test & Test Test Test Test Test Test Test Test Test Test Test 1 & Test Test Test Test Test Test Test Test Test Test Test 12 & Test Test Test Test Test Test Test Test Test Test Test 123 & Test Test Test Test Test Test Test Test Test Test Test 1234 & Test Test Test Test Test Test Test Test Test Test Test 12345 & Test Test Test Test Test Test Test Test Test Test Test 123456 & Test Test Test Test Test Test Test Test Test Test Test 1234567 \ \bottomrule

    The following actually works pretty well (I would say):

    \BooktabsToWidth[\textwidth]{7}{
      colspec = {@{} *{8}{X[-1, l]} @{}},
    }{%
      \toprule
      I & II & III & IV & V & VI & VII & VIII \\
      \midrule
      Test 1 &
      Test~Test~Test~2 &
      Test Test Test Test Test Test Test Test Test Test Test 3 &
      Test Test Test Test Test Test Test Test Test Test Test 4 &
      Test Test Test Test Test Test Test Test Test Test Test 5 &
      Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test 6 &
      Test Test Test Test Test Test Test Test Test Test Test 7 &
      Test Test Test Test Test Test Test Test Test Test Test 8 \\
      Next row & Next row & Next row & Next row & Next row & Next row & Next row & Next row \\
      \bottomrule
    }

    Here’s the output:

    Image

    I would assume that such complicated tables—in which some cells span a single line, while others span multiple lines—will almost always require manual adjustments by the author of the manuscript.

    After all, one can have different objectives in mind:

    • One could want all columns to have (approximately) the same width (for aesthetic reasons and because it makes the columns easily identifiable). This will result in different cell heights (see above).
    • Alternatively, one might want all cells to have (approximately) the same height (to minimize the height of the table and to make the table rows easily identifiable). Then the columns need to be of different widths.
    • And in many cases, one will have to find a compromise between these two objectives.

    An algorithm that is supposed to determine the column widths for the author will need to know which objective the author pursues.

  19. pratap120431 commented on Sep 2, 2025

    @pratap120431

    Hi Holger Gerhardt,
    Thank you for the solution. In the given sample, all columns are distributed equally. Is there a way to automatically allocate more width to Column VI (which contains more text) by using options in the table preamble, such as X[-1,l], X[l], etc.

    In addition to this, When i use longtblr (from tabularray) with rowspan, the table cannot break across pages inside a spanning cell.
    A rowspan cell is treated as a single vertical box, so TeX cannot split it between pages. is there any possibility to capture each row height. Thank you

  20. locked and limited conversation to collaborators on May 10, 2026
  21. converted this issue into a discussion #656 on May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions