Consider the following
TEXT TEXT TEXT TEXT Figure~\ref{fig:foo} TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT
\begin{figure}
\centering
\includegraphics[width=\textwidth]{foo}
\caption{This is foo.}
\label{fig:foo}
\end{figure}
Now I would like to put a frame around the text and the figure. Ofcourse one could remove the figure
-environment and wrap everything with the fbox
-environment but I need to keep the caption and label (the latter for dynamic referencing):
\fbox{
TEXT TEXT TEXT TEXT Figure~1 TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT
\includegraphics[width=\textwidth]{foo}
}
I tried the following code but it seems not work:
\fbox{
\parbox[c]{\textwidth}{
TEXT TEXT TEXT TEXT Figure~\ref{fig:foo} TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT
}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{foo}
\caption{This is foo.}
\label{fig:foo}
\end{figure}
}
figure
is a floating environment which means it can always move away fromTEXT
. This means there is no way it can be put into a box together withTEXT
. Look at thecaption
package. Among others it offers the\captionof
command which allows to have a caption without a floating environment.