\setcounter{errorcontextlines}{999}
\documentclass[parskip=false,english,11pt]{ltxmdf}

\lstset{style=lstltxmdf}

\newcommand\Loadedframemethod{default}
\usepackage[framemethod=\Loadedframemethod]{mdframed}

\surroundwithmdframed[middlelinecolor=ltxmdfblue,middlelinewidth=1pt,%
                      roundcorner=10pt,innertopmargin=0pt,%
                      leftmargin=1cm,rightmargin=1cm,%
                      innerleftmargin=-15pt,innerrightmargin=-15pt,%
                      ignorelastdescenders,%
                      settings={\lstset{resetmargins}},%
                      skipbelow=\topskip,skipabove=\topskip,%
                      innerbottommargin=0pt,backgroundcolor=gray!10]%
                     {tltxmdfexample}

\newmdenv[middlelinecolor=ltxmdfblue,middlelinewidth=1pt,%
                      roundcorner=10pt,innertopmargin=0pt,%
                      leftmargin=1cm,rightmargin=1cm,%
                      innerleftmargin=-15pt,innerrightmargin=-15pt,%
                      ignorelastdescenders,%
                      settings={\lstset{resetmargins}},%
                      skipbelow=\topskip,skipabove=\topskip,%
                      innerbottommargin=0pt,backgroundcolor=gray!10]%
                     {tltxmdfhighlight}
\def\highlightinputenv{tltxmdfhighlight}

\title{The \Pack{mdframed} package}
\subtitle{Examples for \Opt{framemethod=\Loadedframemethod}}
\author{\href{mailto:marco.daniel@mada-nada.de}{Marco Daniel}}
\date{\mdfmaindate}
\version{\mdversion}
\introduction{In this document I collect various examples for
              \Opt{framemethod=\Loadedframemethod}.
              Some presented examples are more or less exorbitant.}

\mdfsetup{skipabove=\topskip,skipbelow=\topskip}
\newrobustcmd\ExampleText{%
        An \textit{inhomogeneous linear} differential equation has the form
         \begin{align}
            L[v ] = f,
         \end{align}
        where $L$ is a linear differential operator, $v$ is
        the dependent variable, and $f$ is a given non-zero
        function of the independent variables alone.
}

\newcounter{examplecount}
\setcounter{examplecount}{0}
\renewcommand\thesubsection{}
\newcommand\Examplesec[1]{%
\stepcounter{examplecount}%
\subsection{Example~\arabic{examplecount}~--~#1\relax}%
}

\begin{document}
\maketitle
\section{Loading}
In the preamble only the package \Pack{mdframed} with the option
\Opt{framemethod=\Loadedframemethod} is loaded. All other modifications will be
done by \Cmd{mdfdefinestyle} or \Cmd{mdfsetup}.

{\large\color{red!50!black}
\NOTE Every \Cmd{global} inside the examples is necessary to work with my own
created environment \Env{tltxmdfexample*}.}

\section{Examples}
All examples have the following settings:

\begin{tltxmdfexample}
\mdfsetup{skipabove=\topskip,skipbelow=\topskip}
\newrobustcmd\ExampleText{%
  An \textit{inhomogeneous linear} differential equation has the form
  \begin{align}
      L[v ] = f,
  \end{align}
  where $L$ is a linear differential operator, $v$ is the dependent
  variable, and $f$ is a given non-zero function of the independent
  variables alone.
}
\end{tltxmdfexample}

\clearpage
\Examplesec{very simple}
\begin{tltxmdfexample*}
\global\mdfdefinestyle{exampledefault}{%
     linecolor=red,linewidth=3pt,%
     leftmargin=1cm,rightmargin=1cm
}
\begin{mdframed}[style=exampledefault]
\ExampleText
\end{mdframed}
\end{tltxmdfexample*}

\Examplesec{hidden line + frame title}
\begin{tltxmdfexample*}
\global\mdfapptodefinestyle{exampledefault}{%
 topline=false,bottomline=false}
\begin{mdframed}[style=exampledefault,frametitle={Inhomogeneous linear}]
\ExampleText
\end{mdframed}
\end{tltxmdfexample*}

\Examplesec{colored frame title}
\begin{tltxmdfexample*}

\global\mdfapptodefinestyle{exampledefault}{%
   rightline=true,innerleftmargin=10,innerrightmargin=10,
   frametitlerule=true,frametitlerulecolor=green,
   frametitlebackgroundcolor=yellow,
   frametitlerulewidth=2pt}
\begin{mdframed}[style=exampledefault,frametitle={Inhomogeneous linear}]
\ExampleText
\end{mdframed}
\end{tltxmdfexample*}

\Examplesec{framed picture which is centered}
\begin{tltxmdfexample*}[morekeywords=width]
\begin{mdframed}[userdefinedwidth=6cm,align=center,
                 linecolor=blue,linewidth=4pt]
\textit{CTAN lion drawing by Duane Bibby; thanks to \url{www.ctan.org}}
\IfFileExists{ctan-lion.png}%
 {\includegraphics[width=\linewidth]{ctan-lion.png}}%
 {\rule{\linewidth}{4cm}}%
\end{mdframed}
\end{tltxmdfexample*}

\Examplesec{Theorem environments}
\begin{tltxmdfexample*}[morekeywords={theoremstyle,definition}]
\mdfdefinestyle{theoremstyle}{%
     linecolor=red,linewidth=2pt,%
     frametitlerule=true,%
     frametitlebackgroundcolor=gray!20,
     innertopmargin=\topskip,
   }
\mdtheorem[style=theoremstyle]{definition}{Definition}
\begin{definition}
\ExampleText
\end{definition}
\begin{definition}[Inhomogeneous linear]
\ExampleText
\end{definition}
\begin{definition*}[Inhomogeneous linear]
\ExampleText
\end{definition*}
\end{tltxmdfexample*}

\Examplesec{theorem with separate header and the help of TikZ (complex)}
\begin{tltxmdfexample*}[%
  morekeywords={theo,baseline,anchor,outer,sep,current,bounding,box,east},%
  moretexcs=tikz]
\newcounter{theo}[section]
\newenvironment{theo}[1][]{%
 \stepcounter{theo}%
  \ifstrempty{#1}%
  {\mdfsetup{%
    frametitle={%
       \tikz[baseline=(current bounding box.east),outer sep=0pt]
        \node[anchor=east,rectangle,fill=blue!20]
        {\strut Theorem~\thetheo};}}
  }%
  {\mdfsetup{%
     frametitle={%
       \tikz[baseline=(current bounding box.east),outer sep=0pt]
        \node[anchor=east,rectangle,fill=blue!20]
        {\strut Theorem~\thetheo:~#1};}}%
   }%
   \mdfsetup{innertopmargin=10pt,linecolor=blue!20,%
             linewidth=2pt,topline=true,
             frametitleaboveskip=\dimexpr-\ht\strutbox\relax,}
   \begin{mdframed}[]\relax%
   }{\end{mdframed}}
\begin{theo}[Inhomogeneous Linear]
\ExampleText
\end{theo}

\begin{theo}
\ExampleText
\end{theo}
\end{tltxmdfexample*}

\Examplesec{hide only a part of a line}
The example below is inspired by the following post on StackExchange
\href{http://tex.stackexchange.com/questions/24101/theorem-decorations^^A
      -that-stay-with-theorem-environment}%
     {Theorem decorations that stay with theorem environment}
\begin{tltxmdfexample*}[morekeywords={mdf@frame@leftline@single,mdf@frame@rightline@single,%
                     mdf@frame@leftline@first,mdf@frame@rightline@first,%
                     mdf@frame@leftline@second,mdf@frame@rightline@second,%
                     mdf@frame@leftline@middle,mdf@frame@rightline@middle,%
                     mdfboundingboxdepth,mdfboundingboxtotalheight,%
                    mdf@topline,ifbool,interruptrule,everyline}]
\makeatletter
\newlength{\interruptlength}
\newrobustcmd\interruptrule[3]{%
 \color{#1}%
 \hspace*{\dimexpr\mdfboundingboxwidth+
             \mdf@innerrightmargin@length\relax}%
 \rule[\dimexpr-\mdfboundingboxdepth+
               #2\interruptlength\relax]%
      {\mdf@middlelinewidth@length}%
      {\dimexpr\mdfboundingboxtotalheight-#3\interruptlength\relax}%
}
\newrobustcmd\overlaplines[2][white]{%
 \mdfsetup{everyline=false}%
 \setlength{\interruptlength}{#2}
 \appto\mdf@frame@leftline@single{\llap{\interruptrule{#1}{1}{2}}}
 \appto\mdf@frame@rightline@single{\rlap{\interruptrule{#1}{1}{2}}}
 \appto\mdf@frame@leftline@first{\llap{\interruptrule{#1}{0}{1}}}
 \appto\mdf@frame@rightline@first{\rlap{\interruptrule{#1}{0}{1}}}
 \appto\mdf@frame@leftline@second{\llap{\interruptrule{#1}{1}{1}}}
 \appto\mdf@frame@rightline@second{\rlap{\interruptrule{#1}{1}{1}}}
 \appto\mdf@frame@leftline@middle{\llap{\interruptrule{#1}{0}{0}}}
 \appto\mdf@frame@rightline@middle{\rlap{\interruptrule{#1}{0}{0}}}
}
\makeatother

\overlaplines{2.5ex}
\begin{mdframed}[linecolor=blue,linewidth=8pt]
\ExampleText
\end{mdframed}
\overlaplines[blue!70!black!20]{2.5ex}
\begin{mdframed}[linecolor=blue,linewidth=8pt]
\ExampleText
\end{mdframed}
\end{tltxmdfexample*}
\end{document}
 \endinput