# How to draw a frame box around an arbitrary large piece of text/figures/whatever?

The command fbox{...} can be used to draw a box around a piece of text, and apparently also a figure. However, I've not been able to use it if the "text" contains environments such as minipages and center.

So, how does one draw a framed box around an arbitrary text which contains more than just text, such as figures, tables, environments, etc.?

-
Also see the framed package, which you seem to have included as a tag for your question :-) – Will Robertson Feb 19 '11 at 8:52
@Will: Do you know if fancybox supports page breaks? If so it should be also mentioned. – Martin Scharrer Feb 19 '11 at 9:11
@Martin -- I don't think it does, no. – Will Robertson Feb 19 '11 at 10:59

use package mdframed, it also supports a pagebreak

\documentclass{article}

\usepackage[linewidth=1pt]{mdframed}
\usepackage{lipsum}

\begin{document}
\lipsum[2]

\begin{mdframed}
\lipsum[2]
\end{mdframed}

\lipsum[2]

\begin{mdframed}[leftmargin=10pt,rightmargin=10pt]
\lipsum[2]
\end{mdframed}

\lipsum[2]

\begin{mdframed}[leftmargin=-10pt,rightmargin=-10pt]
\lipsum[2]
\end{mdframed}

\end{document}

-
How does mdframed compare to the framed package? – Will Robertson Feb 19 '11 at 8:51

You need to use a \parbox or similar inside the \fbox for items that don't work For example

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\fbox{%
\parbox{\textwidth}{%
\begin{center}
\lipsum[1-3]
\end{center}
}%
}
\end{document}


but for minipage situation things work just fine:

\documentclass{article}
\usepackage{lipsum}

\begin{document}
\fbox{%
\begin{minipage}{\textwidth}
\lipsum[1-3]
\end{minipage}
}
\end{document}


(The lipsum package here is used purely to provide the filler text: it is not needed for the solution.)

-
Funny, why doesn't the minipage doesn't work without the parbox? Both are very similar anyway. – Martin Scharrer Feb 19 '11 at 9:05
@Martin: actually, it does! I'll update my answer – Joseph Wright Feb 19 '11 at 9:06
The OP writes "fbox doesn't work with minipages", which triggered some bell in my just awoken brain. – Martin Scharrer Feb 19 '11 at 9:08

Here is one using eplain:

\input eplain
\vsize=4.3in
\boxit{\halign{&\tabskip1em#\hfil\cr Some stuff & in a table & just to show \cr
\noalign{\smallskip\hrule\smallskip}
the frame & around the table \cr}}
\smallskip
\boxit{\vbox{\hsize=2in% just to keep the image smaller
Lorem ipsum dolor sit amet. This could go on and on and on until we hit the
edge of the page at which point there should be automatically another line}}
\smallskip \boxitspace=2em
\boxit{\vbox{\hsize=2in\item{1.} A list \item{2.} With list items
\smallskip \boxitspace=5pt
\boxit{\XeTeXpicfile "test-pattern.jpg"}
\footline={\boxit{\hbox{\tenrm\folio}}\hss}
\bye
% the boxit macro from eplain for completeness
% modified for stand-alone use (ehrule to hrule; evrule to vrule)
\newdimen\boxitspace \boxitspace = 3pt
\long\def\boxit#1{%
\vbox{%
\hrule
\hbox{%
\vrule
\kern\boxitspace
\vbox{\kern\boxitspace \parindent = 0pt #1\kern\boxitspace}%
\kern\boxitspace
\vrule
}%
\hrule
}%
}%


-
Could you please re-upload your picture? It is no longer appearing... – Vivi Jun 30 '11 at 23:39
@Vivi: thanks, done. – morbusg Jul 1 '11 at 4:25