Since the future of tabu is not that safe I’m trying to define an own \rowfont macro. This is what I’ve got so far:
\documentclass{article}
\usepackage{array,tabularx}
\usepackage[table]{xcolor}
\usepackage{xparse,etoolbox}
\ExplSyntaxOn\makeatletter
\int_new:N \l_@@_last_rownum_int
\cs_new_nopar:Npn \@@_current_rowfont: { }
\NewDocumentCommand { \rowfont } { m } {
\cs_gset_nopar:Npn \@@_current_rowfont: { #1 }
#1
}
\newcolumntype { L } {
>{
\int_compare:nNnTF { \int_use:N \l_@@_last_rownum_int } = { \number \rownum } {
\@@_current_rowfont:
} {
\cs_gset_nopar:Npn \@@_current_rowfont: { }
\@@_current_rowfont:
}
}
l
<{
\int_gset:Nn \l_@@_last_rownum_int { \number \rownum }
}
}
\newcolumntype { x } {
>{
\int_compare:nNnTF { \int_use:N \l_@@_last_rownum_int } = { \number \rownum } {
\@@_current_rowfont:
} {
\cs_gset_nopar:Npn \@@_current_rowfont: { }
\@@_current_rowfont:
}
}
X
<{
\int_gset:Nn \l_@@_last_rownum_int { \number \rownum }
}
}
\rowcolors { 0 } { } { }
\ExplSyntaxOff\makeatother
\begin{document}
tabular:
\begin{tabular}{LLL}
\rowcolor{black}\rowfont{\color{red}}
1 & 2 & 3 \\
1 & 2 & 3 \\
\end{tabular}
\bigskip
tabularx:
\begin{tabularx}{0.5\textwidth}{xxx}
\rowcolor{black}\rowfont{\sffamily\footnotesize\color{red}}
1 & 2 & 3 \\
1 & 2 & 3 \\
\end{tabularx}
\end{document}

Problems
- In
{tabularx}the row using\rowfontgets enlarged when the argument of\rowfontcontains\color. - It only works when using
\rowcolors. - It can be used with special column types only.
Maybe it is possible to solve the problems with another definition …
tabucodes it? I guess that I'm not understanding the question. Is the point to do this inl3syntax because the current code will be incompatible with LaTeX 3? (This is just a guess which tries to make sense of the motivation for the question. If that's the case, doubtless others less ignorant than me will not need the clarification.) – cfr May 13 '14 at 02:39tabuis not easy, because it redefines the cell-handling by adding hooks for\rowfont– Tobi May 13 '14 at 07:44