# Justification in table

How to justify a table column like:

\begin{table}{j j}
ab cd & ef gh\\
ij kl & mn op
\end{table}


where j stands for justified column, i.e. both right and left are aligned.

Thanks...

-

A simple readymade solution is to use David Carlisle'’s tabulary-package. As a free bonus, you can specify the width of the tabular, and the width of the column is tailored to the width of the text.

The J-column gives you justified columns. You can also fine tune the appearance with the lengths \tymin and \tymax controlling the minimum and maximum widths of the columns, see the manual page 4.

A MWE

\documentclass{article}
\usepackage{booktabs,tabulary}
\begin{document}
\begin{tabulary}{.3\linewidth}{JJ}\toprule
ab cd ... & ef gh ...\\
ij kl ...& mn op ...\\
\bottomrule
\end{tabulary}
\end{document}

-

For this you need to specify a fixed-width column, like p{<len>}, where <len> is a known TeX length. For example,

\begin{tabular}{p{4cm}p{5cm}}
ab cd ... & ef gh ... \\
ij kl ... & mn op ...
\end{tabular}


Note that I use tabular and not table. The former is the structure to create the table, while the latter is a float that allows the structure to move around in your document.

Another alternative would be to place the contents of the cells inside a "justified" box, like a \parbox. However, this also requires you to specify the width:

\begin{tabular}{ll}
\parbox{4cm}{ab cd ...} & \parbox{5cm}{ef gh ...} \\
ij kl & mn op
\end{tabular}

-