# Make all figures and tables framed by default? [duplicate]

Possible Duplicate:
Rounded corner colored box around figure

I'm interested in having all of my \begin{figure} and \begin{table} environments automatically get framed. Is there any way to do this? I know that I can use the solution in Border or frame around figure, but that doesn't change the default behavior. Is there any way to do that?

-

## marked as duplicate by Marco Daniel, Peter Grill, lockstep, Leo Liu, Joseph Wright♦Dec 2 '11 at 8:03

\documentclass{article}
\begin{document}

\begin{figure}
foo\caption{bar}
\end{figure}

\begin{table}
foo\caption{bar}
\end{table}

\end{document}


-

The following is a reproduction of my answer to the recently-posted question, Border or frame around figure.

I suggest you use the float package and, in particular, its \floatstyle{boxed} and \restylefloat commands, to get frames drawn around all floats by default. See the code below for an example.

A sometimes (but not always!) helpful feature of the float package is that it provides the H location specifier -- as in "I really want this float HERE and nowhere else". (The reason I say "sometimes but not always" is that the placement of floats on a page is frequently very difficult to get "just right." There are quite a few parameters that affect the float placement mechanism, and overriding LaTeX's mechanism with a H specifier can amount to treating symptoms rather than solving the real problems, which in this case are inadequate settings for some of the parameters that guide the mechanism.)

Two idiosyncracies of the "boxed" float style are (i) the width of the boxes is that of \textwidth (plus a small fudge factor, so that an object of full \textwidth width will fit inside the frame box) and (ii) captions of table and figure floats will always be placed below the respective objects. To change this behavior, one would have to delve quite deeply into the innards of the code of the float package. Specifically, the contents of the command \fs@boxed would have to be changed. Unfortunately, this command uses a lot of low-level TeX commands that I'm not comfortable manipulating. Maybe somebody else has a good idea how to reset, say, the frame box's width?

Aside: if you set tables with the "boxed" float style, you'll definitely want to use as few \hline commands as possible or, even better, you'll use no horizontal lines at all.

\documentclass{article}
\usepackage{float,lipsum}
\floatstyle{boxed}
\restylefloat{table}
\restylefloat{figure}
\begin{document}
\lipsum[1]
\begin{figure}[H]
\centering
ABCDEFG
\caption{A very simple figure}
\end{figure}

\bigskip
\begin{table}[h]
\caption{An equally simple table}
\begin{tabular*}{\textwidth}{@{}l@{\extracolsep{\fill}}rlrlr@{}}
Here & There & Here & There & Here & There
\end{tabular*}
\end{table}

\lipsum[2]
\end{document}


-
That's pretty cool except for the box width. Any way to fix that? Also, how do you include TeX output on this blog? Thanks. –  vy32 Oct 23 '11 at 16:11
To include the output of a compile tex document, as I did in my answer, you click on the little blue rectangular "box" (sixth icon from left) in the row above the box where one posts one's question or answer. –  Mico Oct 23 '11 at 16:35
+1, but [H] is not a nice feature. :) –  egreg Oct 23 '11 at 18:05
@egreg: I've changed the adjective "nice" to "sometimes but not always useful," and I've noted that use of the H placement can amount to treating symptoms rather than solving the real problems, which generally have to do with inadequate settings for the parameters that guide LaTeX's float placement process. –  Mico Oct 24 '11 at 10:33
You make me happy. :) –  egreg Oct 24 '11 at 10:45