# Beautify ugly tabu table

I use tabu package to generate a table. The tabu package provides superb features such as fixing table column width, but I happen to have some ugly table in a narrow page column.

\documentclass[10pt, twocolumn]{article}
\usepackage{tabu}
\usepackage{booktabs}
\usepackage{multirow}

\begin{document}

\begin{table}[hbtp]
\begin{tabu} to \linewidth{X[c] | X[c]X[c]X[c]X[c]X[c]}
\toprule
{\bf Strategy} & {\bf Size} & {\bf Energy} & {\bf Expressiveness} & {\bf Flexibility} & {\bf Data Quality} \\
\hline
HCHQ & $-$ & $-$ & + & + & + \\
LCLF & + & + & $-$ & $-$ & + \\
Tunable & + & + & + & + & $-$\\
Tunable with hints & + & + & + & + & + \\
\bottomrule
\end{tabu}
\end{table}

\end{document}


I tried this second version:

\begin{table}[hbtp]
\caption{Strategies and tradeoff factors (E1 = Energy, E2 = Expressiveness, F = Flexibility, D = Data Quality)}\label{tab:factors}

\begin{tabu} to \linewidth{c | X[c]X[c]X[c]X[c]X[c]}
\toprule
{\bf Strategy} & {\bf Size} & {\bf E1} & {\bf E2} & {\bf F} & {\bf D} \\
\hline
HCHQ & $-$ & $-$ & + & + & + \\
LCLF & + & + & $-$ & $-$ & + \\
Tunable & + & + & + & + & $-$\\
Tunable with hints & + & + & + & + & + \\
\bottomrule
\end{tabu}
\end{table}


However, I think the label is too long and also ugly.

Is there a better way to make the tabu table look better (making the first column a little bit longer, automatic hyphenation, centering in multiple rows from the hyphenation, and such)?

• Off-topic: \bf and friends have been deprecated for 20+ years for use in LaTeX. Use \bfseries or \textbf{} instead. On-topic: don't use tabu in any document which matters unless you are sure you won't need to compile it (or a modified version of it) in the future. If it is just a one-off throw-away document and you really want to, tabu should be OK if the bugs don't bite you. But avoid it for anything long term, certainly. Documents which rely on it will break and the package is buggy in the meantime.
– cfr
Oct 6, 2016 at 1:41

Note, I replaced tabu by tabularx, just because I am not familiar with tabu at all.

\documentclass[10pt, twocolumn]{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{multirow}

\begin{document}

\begin{table}[hbtp]
\begin{tabularx}{\linewidth}{@{}l *4{>{\centering\arraybackslash}X}@{}}
\toprule
& \textbf{HCHQ} & \textbf{LCLF} & \multicolumn{2}{c}{\textbf{Tunable}} \\
&      &      & w/o hints & with hints \\ \midrule
Size            & - & + & + & + \\
Energy          & - & + & + & + \\
Expressiveness  & + & - & + & + \\
Flexibility     & + & - & + & + \\
Data Quality    & + & + & - & + \\
\bottomrule
\end{tabularx}
\end{table}

\end{document}

• The tabu definition would not be much different: \begin{tabu} to \linewidth {@{}X[-1,l] *4{X[c]}@{}}. You can specify additional options to the X column type in between []. the -1 option specify a free sizing X column which still allows for line breaks Oct 5, 2016 at 22:58
• @ArTourter Perhaps, but avoiding tabu is highly recommended.
– cfr
Oct 6, 2016 at 1:37
• @cfr well I just wanted to add the tabu solution and didn't feel it required a new answer. Regarding tabu as a whole, we have been waiting for the update that will break every thing for several years now and I am still hoping for it but not holding my breath. Old code is always hard to ensure long term compatibility, the latest update to luatex is an example. it is safer to assume that in general, things will break sooner or later. Oct 6, 2016 at 9:38
• @ArTourter LuaTeX is different because it is advertised as beta and subject to change. There are ways of mitigating the impact of backwards-incompatible changes on users which tabu's author refuses to countenance. Moreover, there is the refusal to fix serious easy-to-fix bugs in the current code in the meantime. The point is that the author appears to think that breaking existing code is simply irrelevant and an awful lot of users are going to be in trouble if the threatened improvements ever come.
– cfr
Oct 6, 2016 at 19:28

There is no need to artificially enlarge a table.

\documentclass{article}
\usepackage{booktabs,caption,makecell}

\begin{document}

\begin{table}[hbtp]
\centering

\caption
[Strategies and tradeoff factors]% for the list of figures
(E1:~Energy; E2:~Expressiveness,
F:~Flexibility, D:~Data Quality)}
\label{tab:factors}

\begin{tabular} {@{}*{6}{c}@{}}
\toprule
\bfseries Strategy &
\bfseries Size &
\bfseries E1 &
\bfseries E2 &
\bfseries F &
\bfseries D \\
\midrule
HCHQ & $-$ & $-$ & + & + & + \\
LCLF & + & + & $-$ & $-$ & + \\
Tunable & + & + & + & + & $-$\\
\makecell{Tunable \\ with hints} & + & + & + & + & + \\
\bottomrule
\end{tabular}
\end{table}

\begin{table}[hbtp]
\centering

\caption
[Strategies and tradeoff factors]% for the list of figures
(E1:~Energy; E2:~Expressiveness,
F:~Flexibility, D:~Data Quality)}
\label{tab:factors-2}

\begin{tabular} {@{}l*{5}{c}@{}}
\toprule
\multicolumn{1}{c}\bfseries Strategy} &
\bfseries Size &
\bfseries E1 &
\bfseries E2 &
\bfseries F &
\bfseries D \\
\midrule
HCHQ & $-$ & $-$ & + & + & + \\
LCLF & + & + & $-$ & $-$ & + \\
Tunable & + & + & + & + & $-$\\
Tunable with hints & + & + & + & + & + \\
\bottomrule
\end{tabular}
\end{table}

\end{document}