I am trying to create an environment that I can use to include "figures" within a framed environment. Because floats aren't allowed inside framed environments, I want to create a new environment fixedfigure that I can use within my framed environment. For style reasons, I want my fixedfigure environment to look as much like a figure environment as possible from the user's viewpoint. I have something that mostly works, but I have a couple of features that I couldn't quite get working. Also, if you notice something that I already have is wrong, I'm always anxious to learn more about best practices.
What is the best way to get some vertical space around the
fixedfigure? I tried adding a\newlineat the beginning of myfixedfigureenvironment, but got an error because there was no line to end.I want to be able to create my captions in a
fixedfigureusing thecaptioncommand (the same thing I use to create captions in a normalfigure). Unfortunately, I couldn't find a way to temporarily redefinecaptionwithin thefixedfigureenvironment. I think I need something like\newcommand{\caption}[1]{\captionof{figure}{#1}}, but this isn't quite right. I also put a feeble attempt usingletin the example below (commented out).
\documentclass{article}
\usepackage{caption}
\newenvironment{fixedfigure}
{
% \let\caption\captionof
\noindent
\begin{minipage}{\textwidth}
}
{
\end{minipage}
}
\begin{document}
blah blah blah blah blah
blah blah blah blah blah
blah blah blah blah blah
blah blah blah blah blah
blah blah blah blah blah
blah blah blah blah blah
\begin{figure}
\centering
the contents of the figure
\caption{the caption of the figure}
\end{figure}
blah blah blah blah blah
blah blah blah blah blah
blah blah blah blah blah
blah blah blah blah blah
blah blah blah blah blah
\begin{fixedfigure}
\centering
the contents of the figure
% \caption{the caption of the figure}
\captionof{figure}{the caption of the figure}
\end{fixedfigure}
blah blah blah blah blah
blah blah blah blah blah
blah blah blah blah blah
blah blah blah blah blah
blah blah blah blah blah
\end{document}