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 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.

enter image description here

This is what I have done.


    0\textwidth \textwidth
    0.25\textwidth 0.74\textwidth
    0pt \textwidth \begin{exem} \rm \hspace{0.2cm}}{\end{exem}}


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?

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

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

enter image description here

\usepackage{lipsum}% http://ctan.org/pkg/lipsum
  {\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
  Some example content
  Some more example content
share|improve this answer
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

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.