How to insert title in mdframed?

How to insert title in mdframed? In my example does not work.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[framemethod=TikZ]{mdframed}

\begin{document}

\section{mdframed}

\begin{mdframed}[numbers=left,frame=single,framesep=5mm,label=Title]
text

text

text

text

text

text

text
\end{mdframed}

\end{document}


I need

------------title------------

And here tytle vertical position?

-
I think \mdfsetup{frametitlealignment=\center} might help. :) –  Paulo Cereda Aug 28 '12 at 15:08
You are using some keys which don't belong to mdframed (numbers, frame, framesep); those are keys for lstlistings from the listings package and not for mdframed. –  Gonzalo Medina Aug 28 '12 at 15:20
See for example file mdframed-example-default.pdf -> example 6 –  Marco Daniel Aug 28 '12 at 16:20

In your example code you are using some keys which don't belong to mdframed; numbers, frame, framesep are keys for lstlistings from the listings package and not for mdframed; with mdframed, you need frametitle:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[framemethod=TikZ]{mdframed}

\mdfsetup{frametitlealignment=\center}

\begin{document}

\section{mdframed}

\begin{mdframed}[frametitle={The title of the frame}]
text
\end{mdframed}

\end{document}


After the edit to the original question, here's a possible solution:

\documentclass{article}
\usepackage{mdframed}
\usepackage{lipsum}

\newenvironment{myenv}[1]
{\mdfsetup{
frametitle={\colorbox{white}{\space#1\space}},
innertopmargin=10pt,
frametitleaboveskip=-\ht\strutbox,
frametitlealignment=\center
}
\begin{mdframed}%
}
{\end{mdframed}}

\begin{document}

\begin{myenv}{The frame title}
\lipsum[2]
\end{myenv}

\end{document}


-
Your answers is perfect, but and the vertical position, with figure above? –  Regis da Silva Aug 28 '12 at 16:11
@RegisdaSilva I updated my answer with a new example code. Is it something like that what you need? –  Gonzalo Medina Aug 28 '12 at 16:41
Yes, Gonzalo Medina, perfect. Thanks. –  Regis da Silva Aug 28 '12 at 16:58
@RegisdaSilva You're welcome! I'm glad I could help. –  Gonzalo Medina Aug 28 '12 at 17:15
You become a mdframed master ;-) –  Marco Daniel Aug 28 '12 at 17:31
show 1 more comment