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

enter image description 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[framed, amsthm]{ntheorem}

  \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]%
    \node [thmbox] (box){%
  \node[fancytitle, right=10pt] at (box.north west) {\textbf{Theorem \thetheorem}%


And in the body:

  • 3
    Example four of the file mdframed-example-tikz.pdf Jan 28, 2012 at 15:58
  • @MarcoDaniel I think that's an answer :)
    – cmhughes
    Jan 28, 2012 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, 2012 at 0:03
  • @egreg: I will change the settings of listings. You are completely right. Jan 29, 2012 at 9:23
  • @MarcoDaniel An answer would be nice. :-)
    – lockstep
    Mar 3, 2012 at 22:25

1 Answer 1


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.


      \node[anchor=west,rounded corners,draw,thick,shading=axis,left color=blue!20,xshift=1cm,minimum height=.7cm,minimum width=2cm] at (P-|O) 
tikzsetting={shading=axis,top color=gray!20},

\begin{theorem}[Title of the Theorem]

This results in:

enter image description here

You must log in to answer this question.

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