TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

share|improve this question
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
up vote 1 down vote accepted

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.