5

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?

6

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
2

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}
1

To use a sans serif font in an individual table, use \sffamily inside the table environment.

\documentclass{article}
\begin{document}
\begin{table}
    \sffamily
    \begin{tabular} {| c | c | c |}
    \hline
    sans serif & inside table & :) \\
    \hline
    \end{tabular}
\end{table}
\noindent Default text outside table
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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