2

I created a theorem environment for examples and I want to have them boxed underneath the heading.

\documentclass{book}
\usepackage{amsmath}
\usepackage{amsthm}

\newtheoremstyle{break}                                                                 
{5mm}                                                                                   
{5mm}                                                                                   
{}                                                                                      
{}                                                                                      
{\bfseries}                                                                         
{}                                                                                      
{\newline}                                                                              
{}                                                      
\theoremstyle{break}                                                                    
\newtheorem{exmp}{Example}

\begin{document}

\begin{exmp}
This text should be framed in a box, but not the heading "Example".
\end{exmp}

\end{document}

Can I add an \fbox{} into this newtheorenstyle so I can use \begin{exmp} Text text text \end{exmp} and the "Text text text" will be inside of a frame box?

1
1

This accomplished it:

\documentclass{book}
\usepackage{amsmath}
\usepackage{amsthm}

\newtheoremstyle{break}                                                                 
{5mm}                                                                                   
{5mm}                                                                                   
{}                                                                                      
{}                                                                                      
{\bfseries}                                                                         
{}                                                                                      
{\newline}                                                                              
{}                                                      
\theoremstyle{break}                                                                    
\newtheorem{exmp}{Example}

\newcommand{\example}[1]{%
\begin{exmp}\framebox[\textwidth][l]{#1}%
\end{exmp}}

\begin{document}

\example{Text text text}

\end{document}

The frame is the width of the main body and the example inside is left-justified.

1
  • My understanding is that oframed in the framed package allows these frames to naturally break across pages, but I could not get that to work. Would this be a new question?
    – E2R0NS
    May 11 '20 at 13:35
1

I strongly encourage you to have a look at thmbox which was created precisely for that kind of purpose.

The following:

\documentclass{book}
\usepackage{amsmath}
\usepackage{amsthm}

\usepackage%[nounderline]
{thmbox}
\newtheorem[L]{thm}{Theorem}[section]
\newtheorem[L]{ex}[thm]{Example}


\begin{document}

\begin{ex}
Some text, some more text, a sufficient amount to get a full box with several lines.
\end{ex}

\vspace{45em}

\begin{ex}
Some text, some more text, a sufficient amount to get a full box with several lines.
Some text, some more text, a sufficient amount to get a full box with several lines.
Some text, some more text, a sufficient amount to get a full box with several lines.
Some text, some more text, a sufficient amount to get a full box with several lines.
Some text, some more text, a sufficient amount to get a full box with several lines.
Some text, some more text, a sufficient amount to get a full box with several lines.
\end{ex}



\end{document}



\end{document}

produces almost what you want:

enter image description here

and breaks nicely:

enter image description here

Refer to the manual for more tweaking option, but I believe that this will be more elegant than your "hand-made" solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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