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 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
text\\text\\text\\ really a lot of text\\ text\\ text\\text\\ 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!)

share|improve this question
Welcome to TeX.sx!! You set the space by skipabove and skipbelow. – Marco Daniel Sep 1 '12 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. – Marco Daniel Sep 1 '12 at 8:01
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. – barbara beeton Sep 1 '12 at 13:16

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

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.