0

When I typeset some tabular or array in the following way :

begin{tabular}{c}
a \\
ab \\
abc \\
\end{tabular}

the width of the column adjusts to the maximum cell width. For example, assuming all letters a, b, c are 5mm wide, the width of the column will be 15mm (ignoring extra \tabcolsep).

I guess the tabular environment keeps the max width encountered until then. For example,

  • when treating the first cell, max_width would be 0
  • when treating the second cell, max_width would be 5mm (width of the first cell)
  • when treating the third cell, max_width would be 10mm
  • at the end, max_width would be 15mm, the actual width

Is there a way to get this max_width at some point in the tabular so that I can do stuff with it ?

begin{tabular}{c}
a \\
ab \\
abc \\
\doSomethingWithMaxWidth \\
\end{tabular}
Fred
  • 161
  • Probably some background infor on what exactly you want to do with the width afterwards would be helpful. – leandriis Jul 13 '20 at 09:38
  • https://tex.stackexchange.com/a/152838/134144 could be related – leandriis Jul 13 '20 at 09:39
  • I'm trying to fix an issue in my custom package for typesetting variations tables. To put it simply, when my cells are : c \ | \ a | b, the |s must be aligned with the c, so I centered the column. But sometimes, a is empty and the cells are c \ | \ | b. If I center the column, an unwanted space is needed at the left of the second | to balance, so I change it to a l column, but I need to add some space before the |s to align, depending on the width of c. Thanks for the link, seems related indeed. – Fred Jul 13 '20 at 10:01
  • Probably one of the following two suggestions could alos hlep you with your task:`\begin{tabular}{c} c \ | \ \phantom{a} | b \end{tabular}

    \begin{tabular}{l|r} \multicolumn{2}{c}{c} \ & \ a & b \end{tabular}`

    – leandriis Jul 13 '20 at 10:19
  • The first doesn't fix the unwanted space at left (the \hphantom). The 2nd is interesting but the c is not centered. I'm thinking about it, thanks ! – Fred Jul 13 '20 at 10:38

0 Answers0