# passing a theorem name using ntheorem

I'm looking for a way to style a theorem as shown here.

The code there works if I want the theorem number in the heading box, but I also want to be able to pass a custom theorem name to add to that heading box. The optional argument seems to be showing up as part of the #1, so how do I separate it so that I can put it elsewhere?

The code I'm currently using (from the same link given above)

\usepackage{graphicx,textpos, a4wide}
\usepackage{helvet, amssymb}

\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations}

\usepackage{framed}
\usepackage[framed, amsthm]{ntheorem}

\theoremclass{Theorem}
\theoremstyle{empty}
\newcommand{\thmbox}[1]{
\tikzstyle{thmbox} = [rectangle, rounded corners, draw=black, fill=gray!20, inner sep=15pt, drop shadow={fill=black, opacity=.5}]%
\tikzstyle{fancytitle} =[fill=white, text=black, rectangle, rounded corners, draw= black]%
\noindent%
\begin{tikzpicture}%
\node [thmbox] (box){%
\begin{minipage}{.91\textwidth}%
\textit{#1}%
\end{minipage}%
};%
\node[fancytitle, right=10pt] at (box.north west) {\textbf{Theorem \thetheorem}%
};%
\end{tikzpicture}}

\def\theoremframecommand{\thmbox}


And in the body:

\begin{theorem}[abc]
Hello
\end{theorem}

-
Example four of the file mdframed-example-tikz.pdf – Marco Daniel Jan 28 '12 at 15:58
@MarcoDaniel I think that's an answer :) – cmhughes Jan 28 '12 at 17:35
@MarcoDaniel Wouldn't it be better to use typewriter type and the listings option columns=fullflexible in the source code? As they are it's impossible to copy-paste the code (and it's unreadable). – egreg Jan 29 '12 at 0:03
@egreg: I will change the settings of listings. You are completely right. – Marco Daniel Jan 29 '12 at 9:23
@MarcoDaniel An answer would be nice. :-) – lockstep Mar 3 '12 at 22:25

Based of the comments I created an approach.

The important part of the code is the redefinition of \mdfcreateextratikz. The package provides this command to put extra material somewhere. The coordinates O and P are used internal. In the file md-frame-1.mdf you can find their meaning.

\documentclass{article}
\usepackage{xcolor}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}

\newcounter{theorem}
\renewcommand\thetheorem{Theorem~\arabic{theorem}}
\makeatletter
\mdf@dolist{\mdf@do@stringoption}{%
{theoremtitle=={}}%
}
\renewrobustcmd\mdfcreateextratikz{%
\node[anchor=west,rounded corners,draw,thick,shading=axis,left color=blue!20,xshift=1cm,minimum height=.7cm,minimum width=2cm] at (P-|O)
{~\mdf@frametitlefont{\thetheorem}%
\ifdefempty{\mdf@theoremtitle}%
{~}%
{:~\mdf@theoremtitle~}%
};
}
\makeatother
\mdfdefinestyle{theoremstyle}{%
outerlinewidth=1pt,
innerlinewidth=0pt,
roundcorner=2pt,
linecolor=black,
innertopmargin=1.2\baselineskip,
skipabove={\dimexpr0.5\baselineskip+\topskip\relax},
needspace=3\baselineskip,
frametitlefont=\sffamily\bfseries,
settings={\global\stepcounter{theorem}},
}
\newenvironment{theorem}[1][]
{\begin{mdframed}[style=theoremstyle,theoremtitle={#1}]\relax}{\end{mdframed}}

\begin{document}
\begin{theorem}
\lipsum[1]
\end{theorem}
\begin{theorem}[Title of the Theorem]
\lipsum[1]
\end{theorem}
\end{document}


This results in:

-