[Tex/LaTex] current column width in a tabu table

horizontal alignmenttabu

Is there some way of getting the current column width in a tabu table in the same way that one can refer to \columnwidth in a multicol?

For example, the following gallery works but its a bit ugly since the column content had to know its width. i.e. we had to specify [width=.45\textwidth] whereas we would prefer not to have to do that. If this were a multicol then we could have just used [width=\columnwidth] in its place.

I searched through the tabu documentation looking for all occurrences of width but did not find it.

\documentclass{article}
\usepackage{graphicx}
\usepackage{tabu}

\begin{document}

\begin{tabu}{XX}
\framebox{\includegraphics[width=.45\textwidth]{myfig}} &
\framebox{\includegraphics[width=.45\textwidth]{myfig}} \\
Some text.  & Some more Text.  \\
\end{tabu}

\end{document}

Best Answer

I don't know if it's documented, but you can always refer to the current width of a parbox by \linewidth:

\documentclass{article}
\usepackage{graphicx}
\usepackage{tabu}

\begin{document}

\begin{tabu}{XX}
\framebox{\includegraphics[width=\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax]{myfig}} &
\framebox{\includegraphics[width=\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax]{myfig}} \\
Some text.  & Some more Text.  \\
\end{tabu}

\end{document}

Just say \linewidth instead of the complicated \dimexpr...\relax if you don't want the frame.

Of course the \linewidth would change in a nested list based environment; in this case you can always use \hsize (this is surely undocumented).

Related Question