I need to use an example environment like the following.

\begin{example}[My Caption, mylabel]
My example text

It should show the text inside a verbatim environment, the caption (like a figure) Example 1: My Caption and the label mylabel to refer to the example.

Can anyone help me, please?

I tried with this, but it doesn't work with the verbatim environment.

  \vspace{0.3cm} {\bf{Example \thechapter.\arabic{example}} - #1} \\ \sf



1 Answer 1


I've solved in this way.


And then using this sample:

\begin{example}[caption=My Caption,label=mylabel]
My example text

You must log in to answer this question.

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