2

Commented code generates Fig. 2, while active code generates the wanted output in Fig. 1

\documentclass{article}
\usepackage{amsmath}

\begin{document}    
% http://tex.stackexchange.com/a/4816/13173
%\begin{table}
%\begin{tabular}{| +p{3cm} | ^p{3cm} | }
%\rowstyle{\bfseries}
%Count \texorpdfstring{$P_{st}(G)$} & Hello \\ \hline
% Output: wrong

\begin{table}
\begin{tabular}{| p{3cm} | p{3cm} | }
% Output: ok but not generic
\hline
\textbf{Count \texorpdfstring{$P_{st}(G)$}} & \textbf{Hello} \\ \hline
1           & 2 \\ \hline
\end{tabular}
\end{table}
\end{document}

Fig. 1 Wanted output (done with \textbf), Fig. 2 Output of the \bfseries approach with Math symbols

enter image description here enter image description here

System: Linux Ubuntu 16.04
TexLive: 2015

2 Answers2

4

I suggest you replace

\textbf{Count \texorpdfstring{$P_{st}(G)$}}

with

\bfseries\mathversion{bold} Count \texorpdfstring{$P_{st}(G)$}{}

enter image description here

Mico
  • 506,678
1

Both ways work adding \boldmath:

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}

\newcolumntype{+}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
  #1\ignorespaces
}
\usepackage{hyperref}

 \begin{document}
% http://tex.stackexchange.com/a/4816/13173
\begin{table}[!htb]
\begin{tabular}{| +p{3cm} | ^p{3cm} | }
\hline
\rowstyle{\bfseries\boldmath}
Count \texorpdfstring{$P_{st}(G)$} & Hello \\ \hline
1 & 2 \\ \hline
\end{tabular}
\end{table}

\begin{table}[!htb]
\begin{tabular}{| p{3cm} | p{3cm} | }
\hline
\textbf{\boldmath Count \texorpdfstring{$P_{st}(G)$}} & \textbf{Hello} \\ \hline
1 & 2 \\ \hline
\end{tabular}
\end{table}

\end{document} 

enter image description here

Bernard
  • 271,350