# Is there a package for automatically managing table headers and formatting?

Is there a package for automatically managing table headers and formatting?

For example I don't want to have to manually embolden every header entry individually, not to mention the extra clutter that would introduce.

This is a general question, but if you prefer to have compilable example to apply the solution to, suppose I want the table headers of row 1 to be automatically emboldened:

\documentclass{article}
\usepackages{booktabs}
\usepackage[T1]{fontenc}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{l l l l}
\toprule
Experiment  &   Enzyme              &   Substrate   &       Enzyme inhibitor\\
\midrule
A           &   Trypsin             &   Casein      &       Trypsin inhibitor\\
B           &   Chymotrypsin        &   Casein      &       Trypsin inhibitor\\
C           &   Chymotrypsinogen    &   Casein      &       Trypsin inihibitor\\
\bottomrule
\end{tabular}
\end{table}
\end{document}


Edit: this question is very similar to Make first row of table all bold but is subtly different, since I don't want to have to create new definitions or engage in any kind of programming. I just want a package that will handle that if possible, thanks.

-
What would constitute "engaging in programming"? To most people, any kind of LaTeX writing would count... It's not clear what you're trying to avoid, and why the solutions to the linked question aren't satisfactory – Seamus Jun 22 '11 at 8:24
Fair point. I guess I just looked at the linked solution \usepackage{array} \newcolumntype{\$}{>{\global\let\currentrowstyle\relax}} \newcolumntype{^}{>{\currentrowstyle}} \newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}% #1\ignorespaces } and I got kind of turned off. I simply didn't understand it, and needed a memorable short-term solution which I could pull out at any time. Also, I'd be tempted to just manually embolden the header entries if it took that much work to get the desired effect - it'd certainly be quicker for small tables. Did that help to clarify my motives...? – ptrcao Jun 22 '11 at 9:12

The tabu package is your friend. Not only does it bundle many features from packages such as tabularx, longtable, ragged2e, it also comes with a \rowfont macro. Your example with the first line bold:

\documentclass{article}
\usepackage{booktabs,tabu}
\usepackage[T1]{fontenc}
\begin{document}
\begin{table}[h]
\centering
\begin{tabu}{l l l l}
\toprule
\rowfont[l]{\bfseries}
Experiment & Enzyme           & Substrate & Enzyme  inhibitor \\
\midrule
A          & Trypsin          & Casein    & Trypsin inhibitor \\
B          & Chymotrypsin     & Casein    & Trypsin inhibitor \\
C          & Chymotrypsinogen & Casein    & Trypsin inhibitor \\
\bottomrule
\end{tabu}
\end{table}
\end{document}

-
Ah, good old tabu (or "new" tabu I should say). I came by this package some time ago but dismissed it, because I felt insecure about various bugs and incompatibilities with other packages I might be using and felt it safer to stick to the traditional table macros. Perhaps time I give it a chance. The first thing I need to figure out is how to use the tabularx equivalent of tabu... – ptrcao Jun 22 '11 at 10:12
What package is \rowfont native to btw? – ptrcao Jun 22 '11 at 10:16
@patrco \rowfont is provided by tabu, I am not aware that this is used elsewhere. The tabu equivalent of tabularx is \begin{tabu} to \textwidth {X} ... \end{tabu}. The package was released beginning of the year, I didn't know it had a history... – Martin H Jun 22 '11 at 11:51
Yeah, I stumbled upon in it earlier this year myself, so it doesn't have a very long history. Thanks for clarifying on tabularx. – ptrcao Jun 22 '11 at 13:19
– cfr Jun 14 '15 at 23:11