I would like to put a text and a math formula inside a \fbox, but I got an error:ERROR: LaTeX Error: Something's wrong--perhaps a missing \item. Also the\\ did not work, so the text and the formula are still in one line.

\begin{figure}[htbp]
\centering
\fbox{%
text\\
$\begin{cases} abcdefghijklmn\\ cdefg \end{cases}$
\caption{a_caption}
\label{a_label}
\end{figure}


Another question is that it seems that the width of the frame is up to the width of what I put inside fbox, what to do if I want the width to be the width of the page?

Could anyone help? Thank you very much!

-
You don't seem to have closed your \fbox! –  Joseph Wright Aug 11 '11 at 20:43
Few issues: You are using inline math with the  and yet trying to insert a newline \\. Also the underscores will need to be escaped as in a\_caption. –  Peter Grill Aug 11 '11 at 20:49
Only in the caption, in the label it doesn't hurt. –  Herbert Aug 11 '11 at 21:07
@Herbert: I get Missing $inserted. if I don't escape the underscores. – Peter Grill Aug 11 '11 at 21:08 yes, for the caption, but not for the label. – Herbert Aug 11 '11 at 21:12 ## 2 Answers • Regarding \fbox, as Joseph said: there's a closing brace missing, determining the end of the argument. • For the whole text width you could use the framed package and its environment with the same name, such as \usepackage{framed} ... \begin{figure}[htbp] \begin{framed} \centering text\\$\begin{cases}
abcdefghijklmn\\
cdefg
\end{cases}$\end{framed} \caption{a caption} \label{a_label} \end{figure}  • Another option is the improved version mdframed. • For framing math environments, there's the \boxed command of amsmath. - you have to use a parbox if you want a linebreak inside fbox. E.g. with package varwidth: \fbox{\varwidth{\linewidth}% text\\$\begin{cases}
abcdefghijklmn\\
cdefg
\end{cases}\$\endvarwidth}


-