
%%$Id: mdframed.dtx 375 2012-04-08 10:52:22Z marco $
\setcounter{errorcontextlines}{999}
\documentclass[parskip=false,english,11pt,ltxlipsum]{ltxmdf}
\ltxmdfsetifoot  $Id: mdframed.dtx 375 2012-04-08 10:52:22Z marco $

\usepackage{showexpl}
\lstset{style=lstltxmdf,explpreset={pos=b,rframe={}},}
\usepackage{tikz}
\usetikzlibrary{calc,arrows}
\newcommand\Loadedframemethod{tikz}
\usepackage[framemethod=\Loadedframemethod]{mdframed}

\title{The \Pack{mdframed} package}
\subtitle{Examples for \Opt{framemethod=\Loadedframemethod}}
\author{\href{mailto:marco.daniel@mada-nada.de}{Marco Daniel}}
\date{\mdfdateID$Id: mdframed.dtx 375 2012-04-08 10:52:22Z marco $}
\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} width 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 the package \Pack{showexpl}.}

\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{Package listings}
The example below is inspired by the following post on StackExchange \href{http://tex.stackexchange.com/questions/27673/background-overflows-when-using-rounded-corners-for-listings-package-listings}{Background overflows when using rounded corners for listings (package: `listings`)}

Here the solution which can be decorate as usual.

\begin{tltxmdfexample}[moretexcs={BeforeBeginEnvironment,AfterEndEnvironment},morekeywords={lstlisting}]
\BeforeBeginEnvironment{lstlisting}{%
    \begin{mdframed}[<modification>]%
    \vspace{-0.7em}}
\AfterEndEnvironment{lstlisting}{%
    \vspace{-0.5em}%
    \end{mdframed}}
\end{tltxmdfexample}

With the new command \Cmd{surroundwithmdframed} you can use
\begin{tltxmdfexample}[moretexcs={BeforeBeginEnvironment,AfterEndEnvironment},morekeywords={lstlisting}]
\surroundwithmdframed{listings}
\end{tltxmdfexample}

\Examplesec{Package multicol}
How I wrote in \enquote{Known Problems} you can't combine \Pack{multicol}  with \Pack{mdframed}. In a simple way without any breaks you can use:
\begin{LTXexample}
\begin{multicols}{2}
\lipsum[1]
\begin{mdframed}
\ExampleText
\end{mdframed}
\lipsum[2]
\end{multicols}
\end{LTXexample}
\clearpage
\twocolumn[\Examplesec{Working in twocolumn mode}]
\begin{tltxmdfexample}
\twocolumn[%
  \Examplesec{Working in
          twocolumn mode}]
\lipsum[1]\lipsum[2]
\begin{mdframed}[%
   leftmargin=10pt,%
   rightmargin=10pt,%
   linecolor=red,
   backgroundcolor=yellow]
\ExampleText
\end{mdframed}
\lipsum[2]
\end{tltxmdfexample}
\lipsum[1]\lipsum[2]
\begin{mdframed}[leftmargin=10pt,%
                 rightmargin=10pt,%
                 linecolor=red,
                 backgroundcolor=yellow]
\ExampleText
\end{mdframed}
\lipsum[2]
\clearpage
\onecolumn
\Examplesec{Working inside enumerate}
\begin{LTXexample}
Text Text Text Text Text Text Text Text
\begin{enumerate}
\item in the following \ldots
      \begin{mdframed}[linecolor=blue,linewidth=2]
         \ExampleText
      \end{mdframed}
\item \lipsum[2]
\end{enumerate}
Text Text Text Text Text Text
\end{LTXexample}
\clearpage
\Examplesec{digression-environement inspired by Tobias Schwan}
\begin{lstlisting}
\usetikzlibrary{calc,arrows}
\tikzset{
   excursus arrow/.style={%
      line width=2pt,
      draw=gray!40,
      rounded corners=2ex,
   },
   excursus head/.style={
      fill=white,
      font=\bfseries\sffamily,
      text=gray!80,
      anchor=base west,
   },
}
\mdfdefinestyle{digressionarrows}{%
 singleextra={%
      \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
      \path let \p1=(Q), \p2=(O) in (\x1,{(\y1-\y2)/2}) coordinate (M);
      \path [excursus arrow, round cap-to]
         ($(O)+(5em,0ex)$) -| (M) |- %
         ($(Q)+(12em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
         ++(23em,2ex);
      \node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {Digression};},
 firstextra={%
      \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
      \path [excursus arrow,-to]
         (O) |- %
         ($(Q)+(12em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
         ++(23em,2ex);
      \node [excursus head] at ($(Q)+(2.5em,-2pt)$) {Digression};},
 secondextra={%
      \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
      \path [excursus arrow,round cap-]
         ($(O)+(5em,0ex)$) -| (Q);},
 middleextra={%
      \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
      \path [excursus arrow]
         (O) -- (Q);},
   middlelinewidth=2.5em,middlelinecolor=white,
   hidealllines=true,topline=true,
   innertopmargin=0.5ex,
   innerbottommargin=2.5ex,
   innerrightmargin=2pt,
   innerleftmargin=2ex,
   skipabove=0.87\baselineskip,
   skipbelow=0.62\baselineskip,
}

\begin{mdframed}[style=digressionarrows]
         \ExampleText
\end{mdframed}
\end{lstlisting}

\tikzset{
   excursus arrow/.style={%
      line width=2pt,
      draw=gray!40,
      rounded corners=2ex,
   },
   excursus head/.style={
      fill=white,
      font=\bfseries\sffamily,
      text=gray!80,
      anchor=base west,
   },
}
\mdfdefinestyle{digressionarrows}{%
 singleextra={%
      \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
      \path let \p1=(Q), \p2=(O) in (\x1,{(\y1-\y2)/2}) coordinate (M);
      \path [excursus arrow, round cap-to]
         ($(O)+(5em,0ex)$) -| (M) |- %
         ($(Q)+(12em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
         ++(23em,2ex);
      \node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {Digression};},
 firstextra={%
      \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
      \path [excursus arrow,-to]
         (O) |- %
         ($(Q)+(12em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
         ++(23em,2ex);
      \node [excursus head] at ($(Q)+(2.5em,-2pt)$) {Digression};},
 secondextra={%
      \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
      \path [excursus arrow,round cap-]
         ($(O)+(5em,0ex)$) -| (Q);},
 middleextra={%
      \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
      \path [excursus arrow]
         (O) -- (Q);},
   middlelinewidth=2.5em,middlelinecolor=white,
   hidealllines=true,topline=true,
   innertopmargin=0.5ex,
   innerbottommargin=2.5ex,
   innerrightmargin=2pt,
   innerleftmargin=2ex,
   skipabove=0.87\baselineskip,
   skipbelow=0.62\baselineskip,
}

\begin{mdframed}[style=digressionarrows]
         \ExampleText
\end{mdframed}
\end{document}
 \endinput

