# A better way to achieve sans-serif typeface in figure and table environments

For some of my style files, I would like to have a sans-serif typeface within my figures. I have code which seems to be working,

\makeatletter
\renewenvironment{figure}[1][\fps@figure]{
\edef\@tempa{\noexpand\@float{figure}[#1]}
\@tempa
\sf
}{
\end@float
}
\renewenvironment{table}[1][\fps@table]{
\edef\@tempa{\noexpand\@float{table}[#1]}
\@tempa
\sf
}{
\end@float
}
\makeatother


but surely there's a better way?

-

I would use

1. the caption package to control the font of (float) captions;
2. the floatrow package to control the font of other float content (i.e. tabular material).

\documentclass{article}

\usepackage[font=sf]{caption}
\usepackage[font=sf]{floatrow}

\begin{document}

\begin{table}
% \centering% Default for floatrow package
\begin{tabular}{cc} \hline
Author & Title \\ \hline
Knuth & The \TeX book \\
Lamport & \LaTeX \\ \hline
\end{tabular}
\caption{A table}
\end{table}

\begin{figure}
% \centering% Default for floatrow package
\rule{1cm}{1cm}
\caption{A figure}
\end{figure}

\end{document}

-
Thank you for suggestion the floatrow package. That provided the tools I needed! – Ben Dec 28 '10 at 1:37

lockstep suggested to use the floatrow package. Since I wanted to do a bit more than just \sf, I thought I'd post my solution here.

\usepackage{floatrow}
\DeclareFloatFont{ben}{\somecommand\anothercommand}
\floatsetup[figure]{font=ben}
\floatsetup[table]{font=ben}

-