Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

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}
share|improve this answer
    
Thank you for suggestion the floatrow package. That provided the tools I needed! –  Ben Dec 28 '10 at 1:37
add comment
up vote 2 down vote accepted

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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