1

I created a theorem environment for examples where the content of the examples gets framed but not the heading "Example".

To allow such frames to break across pages I think I should use mdframed but I cannot get it to work in my predefined command or theorem.

Here is my code showing a framed example which does not break across the page:

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{lipsum}
\newtheoremstyle{break} % so the example begins under the heading                                                           
{5mm}                                                                                   
{5mm}                                                                                   
{}                                                                                      
{}                                                                                      
{\bfseries}                                                                         
{}                                                                                      
{\newline}                                                                              
{}                                                      
\theoremstyle{break}                                                                    
\newtheorem{exmp}{Example}

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

\example{\lipsum[2-8]}

\end{document}

To use mdframed inside my example I tried this:

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{mdframed}
\usepackage{lipsum}
\newtheoremstyle{break} % so the example begins under the heading                                                           
{5mm}                                                                                   
{5mm}                                                                                   
{}                                                                                      
{}                                                                                      
{\bfseries}                                                                         
{}                                                                                      
{\newline}                                                                              
{}                                                      
\theoremstyle{break}                                                                    
\newtheorem{exmp}{Example}

\newcommand{\example}[1]{%
\begin{exmp}\begin{mdframed}\end{mdframed}%
\end{exmp}}
\begin{document}

\example{\lipsum[2-8]}

\end{document}
2
  • 1
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – DG'
    May 11, 2020 at 15:12
  • I cannot come up with an MWE because I cannot get it to work which is why I'm here. It seems I can frame theorems with mdframed but I cannot see how to use mdframed within a predefined theorem.
    – E2R0NS
    May 11, 2020 at 16:41

1 Answer 1

1

You can try the theorem capabilities of tcolorbox:

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{mdframed}
\usepackage{lipsum}

\usepackage[most]{tcolorbox}
\newtcbtheorem{Example}{Example}{
  breakable,
  enhanced,
  sharp corners,
  attach boxed title to top left,
  colback=white,
  colframe=black,
  coltitle=black,
  fonttitle=\bfseries,
  boxed title style={
    sharp corners,
    size=small,
    colback=white,
    colframe=white,
  }
}{exmp}

\begin{document}

\begin{Example}{}{}
    \lipsum[2-8]
\end{Example}

\end{document}

enter image description here

2
  • Nice! What is the purpose of {exmp}? Also, is the package mdframed now not necessary?
    – E2R0NS
    May 11, 2020 at 20:48
  • It's the prefix of the automatically generated label.
    – DG'
    May 11, 2020 at 20:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .