Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.?

share|improve this question
2  
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

3 Answers 3

up vote 9 down vote accepted

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}
share|improve this answer
3  
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.)

share|improve this answer
    
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
  \item{3.} And 2em padding}}
\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
  }%
}%

enter image description here

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.