# mdframed digressionarrows style with custom header

Using the mdframed package, I've been trying to figure out how to add an option for changing the header in their digression-environment (example 6 here: http://cloud.github.com/downloads/marcodaniel/mdframed/mdframed-example-texsx.pdf).

I imagine using the package like this

\begin{mdframed}[style=digressionarrows]{Header of the environment}


Does anyone know how customize the digressionarrows style to allow that?

-
I can only see 5 examples in the link you provided- can you clarify? –  cmhughes May 7 '12 at 10:37
Sorry, I linked to the wrong PDF. It's corrected now. –  Tommy Jakobsen May 7 '12 at 10:47

Instead of redefining the environment mdframed I suggest the following.

The definition of a new key is very simple. So I recommend the definition of a new key e.g. digressiontitle This can be done by:

\mdf@do@stringoption{digressiontitle=={Digression}}


whereby the word Digression is the default value. You can change it.

The value of this option is saved in the macro \mdf@digressiontitle and can be used inside the definition of the style. This is done in the example.

In the next step I suggest the using of \newmdenv with a specific digressiontitle. (For more information about the command \newmdenv see the documentation.

So you can write:

\newmdenv[style=digressionarrows,digressiontitle=Info]{info}
\newmdenv[style=digressionarrows,digressiontitle=Side note]{sidenote}


And use:

\begin{info}
\lipsum[1]
\end{info}

\begin{sidenote}
\lipsum[1]
\end{sidenote}


which leads to the following output:

\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
\usetikzlibrary{calc,arrows}
\makeatletter
\mdf@do@stringoption{digressiontitle=={Digression}}
\tikzset{
excursus arrow/.style={%
line width=2pt,
draw=gray!40,
rounded corners=2ex,
},
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)$) {\mdf@digressiontitle};},
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)$) {\mdf@digressiontitle};},
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,
}
\makeatother

\newmdenv[style=digressionarrows,digressiontitle=Info]{info}
\newmdenv[style=digressionarrows,digressiontitle=Side note]{sidenote}

\usepackage{lipsum}
\begin{document}

\begin{info}
\lipsum[1]
\end{info}

\begin{sidenote}
\lipsum[1]
\end{sidenote}
\end{document}

-
Thank you Marco. Is it because it's alot more complicated to redefine the environment that you suggest this solution? Because we have alot of places where we would like a custom header, so it would be easier if we didn't have to define the environments using the \newmdenv command. –  Tommy Jakobsen May 7 '12 at 16:22
@TommyJakobsen: Based on this solution you can use: \begin{mdframed}[style=digressionarrows,digressiontitle=Info] –  Marco Daniel May 7 '12 at 16:24
Ah, I missed that one. It's just perfect then. Thanks again Marco :-) –  Tommy Jakobsen May 7 '12 at 21:09