5

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} 
5
  • 3
    In the log file you'll find: LaTeX Font Warning: Font shape `T1/cmss/bx/sc' undefined using `T1/cmss/bx/n' instead: this means the font does not have bold small caps. Indeed, if you use a font that has them (e.g. libertine you'll see that the caption setup works as it is supposed to.
    – cgnieder
    Sep 30, 2013 at 18:32
  • 1
    \usepackage{libertine} I'm not sure it's a font well suited for presentations, though. Maybe Helvetica (\usepackage[scaled]{helvet})? BTW you may be interested in tug.dk/FontCatalogue
    – cgnieder
    Sep 30, 2013 at 18:46
  • I don't think this is at all unclear. It is just answered in the comments. If it is not a duplicate, perhaps @cgnieder could write an answer?
    – cfr
    Oct 4, 2014 at 23:05
  • @cfr My answer no longer holds: with an up to date TL14 the example gives Package caption Warning: \caption will not be redefined since it's already redefined by a document class or package which is unknown to the caption package. See the caption package documentation for explanation.
    – cgnieder
    Oct 6, 2014 at 7:17
  • @cgnieder Good to know. In that case, I think it is not unclear and not answered in the comments ;).
    – cfr
    Oct 6, 2014 at 11:08

1 Answer 1

4

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .