# Defining a particular environment in LaTeX

I need help writing an Example environment. I just want it to look like the figure below which I took from an old book I have in my library.

This is what I have done.

    \newtheorem{exem}{EXAMPLE}

\newenvironment{ex}{\parshape=3
0\textwidth \textwidth
0.25\textwidth 0.74\textwidth
0pt \textwidth \begin{exem} \rm \hspace{0.2cm}}{\end{exem}}

\begin{document}
\begin{ex}
Text
\end{ex}
\end{document}


However this code fails when the text is very long in the defined environment. Then I start having problems with right margin. I have no idea how to solve it. Please, can you help me to define that environment?

-
Welcome to TeX.SX! Questions about how to draw specific graphics that just post an image of the desired result would be greatly improved by adding a MWE. Please post a minimal compilable document showing that you've tried to produce the image and then people will be more disposed to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. –  Adam Liter Dec 24 '13 at 23:57

Here is an example environment that sets the paragraph alignment/shape using \parshape:

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\newcounter{example}
\newcommand{\examplename}{\textsc{Example}}
\makeatletter
\newenvironment{example}
{\refstepcounter{example}% Step example counter
\sbox\@tempboxa{\examplename~\theexample.~}% Store environment title
% Set paragraph alignment
\parshape 3 \wd\@tempboxa \dimexpr\linewidth-\wd\@tempboxa % Line 1
\wd\@tempboxa \dimexpr\linewidth-\wd\@tempboxa % Line 2
0pt \linewidth% Line 3+
\noindent% No indent
\leavevmode% Start paragraph
\llap{\usebox\@tempboxa}% Insert environment title
\ignorespaces}% Remove spaces
{\par}
\begin{document}
\lipsum[1]
\begin{example}
\lipsum[2]
\end{example}
\lipsum[3]
\begin{example}
Some example content
\end{example}
\begin{example}
Some more example content
\end{example}
\lipsum[4]
\end{document}

-
Thank you for your answer! It really works for me. –  limber Dec 25 '13 at 1:47
@limber Instead of---or in addition to---posting a “Thank you” as a comment, you should thank Werner by upvoting his answer (with the upward pointing arrow to the left of it; you need 15 reputation points before you can upvote) and accepting it (by clicking on the checkmark ✓). –  Adam Liter Dec 25 '13 at 2:41