# How can you change the font for the contents of all tables in a document

Is there a simple way to set the default font for all tables in a document?

-
add comment

## 2 Answers

Either amend the definition of \table directly or use the floatrow package and its \floatsetup macro. (Note: floatrow by default also centers the content of floats.)

\documentclass{article}

\makeatletter
\g@addto@macro{\table}{\sffamily}
\makeatother

\begin{document}

\begin{table}
(Table contents)
\end{table}

Some text outside a table.

\end{document}


\documentclass{article}

\usepackage{floatrow}
\floatsetup[table]{font=sf}

\begin{document}

\begin{table}
(Table contents)
\end{table}

Some text outside a table.

\end{document}

-
Thanks, I've got the captions under more control. –  Darling Oct 7 '11 at 9:14
add comment

The memoir document class provides a means to set a default formatting for floats (if this is what you mean by "tables") via the \setfloatadjustment{<float>}{<adjustment>} macro. This would add <adjustment> to <float> whenever it is used. For example,

\setfloatadjustment{figure}{\centering}
\setfloatadjustment{table}{\small\centering}


Alternatively, you could use the etoolbox package to patch certain commands/environments. By patching here, it could append code to the start/end of an environment that would change (say) the font/alignment, as in the above setup.

-
I've been looking at the memoir class as I'm currntly using the book class and it seems like the next step. Is it worth the leap? –  Darling Oct 7 '11 at 9:13
I can recommend it. I've been using memoir for quite some time now. –  Werner Oct 7 '11 at 9:17
add comment