Skip to content

LaTeX: The “framed minipage”

October 8, 2009

I can’t remember if I’ve written this down at some point in the past, but I needed to produce a “framed” version of the minipage enviromment in \LaTeX to put some figures on an exam in boxes. Here’s some good code to define such a thing. Maybe there’s an easier way (there always is), but this works well. The code defines a new environment called “fmpage” which takes one argument (the same argument that minipage takes).


\newsavebox{\fmbox}
\newenvironment{fmpage}[1]
{\begin{lrbox}{\fmbox}\begin{minipage}{#1}}
{\end{minipage}\end{lrbox}\fbox{\usebox{\fmbox}}}

Example:


\begin{fmpage}{0.5\linewidth}
$$ P(t) = 180 \cdot (1.1150)^t $$ Note: Population is measured here in millions and t=0 corresponds to Jan. 1, 2000.
\caption{Population Model \#1}
\label{fig:figure1}
\end{fmpage}

Produces:

Framed minipage

Advertisements

From → latex, technical

One Comment
  1. Hi Bruno,

    nice piece of code! Just for completeness, there’s a float environment needed around the fmpage environment to make \caption work.

    Stefan

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: