I would like a tabular
environment with fully justified columns. I my best guess of how to make this happen is to use a tabularx
environment (so the tabular knows how wide to be) and then put \hilll
(for some appropriate repetition of the letter l
) between all adjacent columns. However, that didn't work. See the MWE below.
\documentclass{article}
\usepackage{tabularx}
\begin{document}
Text before. Text before. Text before. Text before. Text before. Text before. Text before.
\begin{tabularx}{\textwidth}{l@{\hfill}c@{\hfill}r}
On the LEFT & In the middle & On the RIGHT
\end{tabularx}
Text between. Text between. Text between. Text between. Text between. Text between. Text between.
\def\magicNumber{50pt}
\begin{tabularx}{\textwidth}{lcr}
On the LEFT & \hspace*{\magicNumber} In the middle \hspace*{\magicNumber} & On the RIGHT
\end{tabularx}
Text after. Text after. Text after. Text after. Text after. Text after. Text after. Text after.
\end{document}
The first tabularx
environment is my failed attempt. The second tabularx
environment is typeset (approximately) correct but is a hack using magic numbers.
Question:
How can one properly use infinite glues (like \hfill
) to specify the space between tabularx
columns? More generally, how can one obtain a tabular
environment with fully justified columns?
Best Answer
tabularx
only works when you use anX
-column. What you're interested in is probably setting\extracolsep{\fill}
, as suggested in Column and row padding in tables:Note that the above doesn't represent "fully justified" columns. For that you could use
If needed, you can modify the justification for the columns using the
array
package.