[Tex/LaTex] Caption label font: will sc and bf conflict with each other

captionsfontstables

I want both bold and small capital effect for my table caption label. Could anybody tell me what's wrong with my code? Why doesn't it work? Thanks

\documentclass{beamer}
\mode<presentation> {
\usetheme{CambridgeUS}
}

\usepackage[T1]{fontenc}
\usepackage{caption}
\captionsetup[table]{labelfont={scriptsize,bf,sc},textfont={it,scriptsize}}

\begin{document}

\begin{frame}[t]
\frametitle{Tables Testing}
\begin{table}[htdp]
\caption{default}
\begin{center}
\begin{tabular}{|cc|}
\hline
column A & column B \\ \hline
line1 & line2 \\ \hline
\end{tabular}
\end{center}
\label{default}
\end{table}%
\end{frame}

\end{document} 

Best Answer

As the warning message now reports, caption does not know about what beamer is doing, and as a result, gives up.

But beamer already has hooks to the caption label/text fonts that we can use directly to achieve the same result:

\setbeamerfont{caption}{size=\scriptsize,shape=\itshape}
\setbeamerfont{caption name}{size=\scriptsize,shape=\scshape,series=\bfseries}

I put the changes inside \AtBeginEnvironment{table}{<...>} from etoolbox to keep the changes local to tables only; the captions for figures are unaffected, as illustrated below.

Of course, we need a font that has all the required combinations; I chose libertine as suggested in the comments, but you may have a better idea of what you want to use.

\documentclass{beamer}
\mode<presentation> {
\usetheme{CambridgeUS}
}

\usepackage{libertine} % so that we have all the required fonts
\usepackage{etoolbox}  % for patching the table environment
\AtBeginEnvironment{table}{% change the caption fonts only inside table (figure unaffected)
  \setbeamerfont{caption}{size=\scriptsize,shape=\itshape}
  \setbeamerfont{caption name}{size=\scriptsize,shape=\scshape,series=\bfseries}
}

\begin{document}

\begin{frame}[t]
\frametitle{Tables Testing}
\begin{table}[htbp]
\centering
\caption{default}
\begin{tabular}{|cc|}
\hline
column A & column B \\ \hline
line1 & line2 \\ \hline
\end{tabular}
\label{default}
\end{table}%
\begin{figure}
  \centering
  Test figure.
  \caption{Test figure caption.}
\end{figure}
\end{frame}

\end{document}

enter image description here

Related Question