I have created an environment for my excercises. The problem now is, that if I have different excercises (Excercise 1, Excercise 2 and so on) there is always a little space between them. I have a background color and this is interrupted, so it looks quite stupid. I want to have no interruption so the color is not interrupted. How can I do this? I do not know how to modify the definition of my environment to teach LaTeX to not do any spaces between it....

Here is my code:

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





text\\ a lot of text\\
the excercise
%no space here! please!
the next excercise
ext\\ really a lot of text\\ text\\ text\\
ext\\ text\\ text\\

(I know that LaTeX sets the excercises dependend on how much text there is, but also, if the page is full of text there is still a bit space between it, I do not want to have any space between it!)

  • 3
    Welcome to TeX.sx!! You set the space by skipabove and skipbelow. Commented Sep 1, 2012 at 7:59
  • Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. Commented Sep 1, 2012 at 8:01
  • 2
    you have inserted \topsep in four places, any of which could have the effect of inserting space above or below the theorem. in particular, the skipabove and skipbelow insert space outside the shaded area; i don't know why @HarishKumar deleted his answer, because it would solve at least part of the problem. Commented Sep 1, 2012 at 13:16

1 Answer 1


As Barbara noticed you are using \topsep four times in your code. You have to remove two of them in \newtheoremstyle to get


Hence you will not get unnecessary spaces (inside the shaded area). Further, other two instances in \newmdtheoremenv, where you should make skipabove and skipbelow equal to 0pt like


And it works.

enter image description here

You must log in to answer this question.

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