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.

Now I run into a problem with frameboxes. Why is the following not valid LaTeX code?

\framebox{
The following text was taken from:
\begin{quote}
Erik Pickles: How it will end
\end{quote}
}

I get the following error:

something's wrong -- maybe an missing item?

share|improve this question
add comment

4 Answers

Framebox doesn't like have an environment inside it. You could consider using the framed package.

\documentclass{article}
\usepackage{framed}
\begin{document}
\begin{framed}
Here is text
\begin{quote}
Here is quote
\end{quote}
\end{framed}
\end{document
share|improve this answer
1  
"Framebox doesn't like have an environment inside it." Isn't correct like that. The issue isn't that quote is an environment but that \framebox forces horizontal mode for its content and quote likes to open a new paragraph and list which doesn't work in that mode. –  Martin Scharrer Sep 27 '11 at 20:55
add comment

If you do not want to use a package as pointed out by Seamus you can use a minipage to do the trick.

\documentclass[11pt]{article} 
\begin{document}
  \framebox{%
   \begin{minipage}{6cm}
    The following text was taken from:
    \begin{quote}
    Erik Pickles: How it will end
    \end{quote}
   \end{minipage}
  }
\end{document}
share|improve this answer
    
This version has the advantage that the frame box doesn't extend all the way to the end of the frame. It does however have the disadvantage that you have to set the width manually... –  Seamus Nov 30 '10 at 18:02
    
@Seamus You're right, but you can always adapt to the default version of the command by changing the {6m} to {\textwidth} –  Yiannis Lazarides Nov 30 '10 at 19:26
    
or you could do some fancy \settowidth magic to get the box to just surround the text you have... I actually think that would be a pretty elegant solution, but I can't work out how to make it into a macro easily... –  Seamus Dec 1 '10 at 11:22
add comment

With package varwidth you do not have to know the width of the box

\documentclass[11pt]{article} 
\usepackage{varwidth}
\begin{document}
  \framebox{%
   \begin{varwidth}{\textwidth}% the greatest possible line width
    The following text was taken from:
    \begin{quote}
    Erik Pickles: How it will end
    \end{quote}
   \end{varwidth}%
  }
\end{document}
share|improve this answer
add comment

If you don't need to have it break across pages you can use the following.

\documentclass{article} 
\usepackage{adjustbox}
\begin{document}
    \begin{adjustbox}{minipage=\linewidth,fbox}
    The following text was taken from:
    \begin{quote}
    Erik Pickles: How it will end
    \end{quote}
    \end{adjustbox}
\end{document}

Otherwise use framed as Seamus suggested. Herbert's solution to use varwidth is also very good if you have not much text and want a tight frame around it.

share|improve this answer
add comment

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.