Awhile ago, @robintw asked a practical question: Make first row of table all bold
It uses the array package to cleverly inject formatting code into the header row columns.
Clever Table Row Formatting Solution
\usepackage{array}
\newcolumntype{$}{>{\global\let\currentrowstyle\relax}} % Always set currentrowstyle to \relax in case no \rowstyle is used
\newcolumntype{^}{>{\currentrowstyle}} % set \currentrowstyle to \bfseries or whatever (>{\bfseries}c)
\newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}% set global definition for \currentrowstyle
#1\ignorespaces
}
The Problematic Code
I'd like to see multicolumn and multirow support. I tried the following based on https://tex.stackexchange.com/a/4816/13552, which does not work.
\documentclass{article}
\usepackage{array}
\newcolumntype{$}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
#1\ignorespaces
}
\begin{document}
\begin{tabular}{$l^c^c^r}
\rowstyle{\bfseries}
%\multicolumn{2}{^l}{span2} & \multicolumn{2}{^r}{span2} \\ % Uncomment this to see problem
col1 & col2 & col3 & col4 \\
dat1 & dat2 & dat3 & dat4 \\
\end{tabular}
\end{document}

\rowstyle{\bfseries}– touhami Apr 25 '15 at 08:36pdflatex), and produces the desired result. What error do you get? – anderstood Jun 09 '15 at 15:41! Misplaced \omit. \multispan ->\omit \@multispanwith This is XeTeX, Version 3.14159265-2.6-0.99991 (TeX Live 2014) (preloaded format=xelatex) – Jonathan Komar Jun 11 '15 at 12:11