1

I've got this neat little snippet from question Make first row of table all bold:

\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^r}
\rowstyle{\bfseries}
a & a & a \\
b & b & b \\
c & c & c \\
\end{tabular}
\end{document}

It works perfectly fine in text mode. However, if I've got a math mode in my table like in the following snippet, this won't work.

\begin{tabular}{$l^c^r}
\rowstyle{\bfseries}
a & $1.33*10^5$ & a \\
b & b           & b \\
c & c           & c \\
\end{tabular}

The two a are bold, but the equation isn't bold. However if I'm using

\begin{tabular}{$l^c^r}
\rowstyle{\bfseries}
a & \textbf{$1.33*10^5$} & a \\
b & b                    & b \\
c & c                    & c \\
\end{tabular}

the equation is rendered bold just perfectly. Do I need another command for this to work? I've trying to typeset one row with ~17 columns (12 math mode) bold in about 20 tables. I would really like not to put every equation in a \textbf.


Using

\begin{tabular}{$l^c^r}
\rowstyle{\textbf}
a & $1.33*10^5$ & a \\
b & b           & b \\
c & c           & c \\
\end{tabular}

Ends in an error You can't use a prefix with `\aftergroup' in the next line.

3

That was quick, I am a dimwit. The solution is to add \boldmath:

\begin{tabular}{$l^c^r}
\rowstyle{\boldmath\textbf}
a & $1.33*10^5$ & a \\
b & b           & b \\
c & c           & c \\
\end{tabular}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.