TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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 have created an own environment with the mdframed package. My problem is, if I insert a picture in the self defined envrionment, the width of the color box is wrong.

Here is the code:


\geometry{left=4cm,right=3cm, top=2cm, bottom=2cm} 











Here comes a lot of text which describes different things, but this complete area should have the same color background width as the solution below! : $\bar{x}=\frac{1}{99}(18*1.5+20*3.5+25*5+22*7+14*9)$
here comes the next solution with the correct width of the color background box!

How can I make the color box has the same width?

Also a general question: If I try to include a float figure, it does not work. It seems to me, that this is in general not possible, to include a float figure in the self defined environment loesung. Also a table is not possible (but tabular). Any ideas on this? The error message if I use figures in the loesung environment is Float(s) lost.

I am writing on a larger document, so I have this problem several times and it really rips me of. I solved the other problems with just using tabular, but here in this case, I really need the picture there to be included.

Thanks a lot!

I attached a screenshot of my problem (I changed the text, so you can better understand the problem, the changing of the text does not matter), I have no account so I have to give you the screenshot:


share|improve this question
Your example code doesn't compile; the thmbox and amsthm packages conflict; also, there's a typo in \end{looesung} (it should be \end{loesung}). – Gonzalo Medina Aug 27 '12 at 21:33
floats can not go in boxes, but boxes can go in floats – cmhughes Aug 27 '12 at 21:35
@GonzaloMedina it was in response to, 'Also a general question'... – cmhughes Aug 27 '12 at 21:43
well, first of all thanks a lot, but if I change it to \textwidth it is getting a bit more width but it is still not correct! and to the general question: What does that mean "boxes can go in floats", how can I add a figure in a loesung environment? – StochastiprocStu Aug 28 '12 at 8:04

In the \includegraphics instruction, don't use [scale=0.5]; instead, use [width=\textwidth].

Separately, two humble requests: 1. When posting a minimum working example, please eliminate all typos (see: \end{looesung}); do note the word "working" in the term "minimum working example". 2. Please also avoid loading any and all packages in the MWE that are aren't strictly needed to illustrate and/or replicate the problem at hand.

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.