Take the 2-minute tour ×
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.

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:

\documentclass{book}
\usepackage{geometry}
\geometry{left=4cm,right=3cm, top=2cm, bottom=2cm} 
\usepackage[ngerman]{babel}
\usepackage[final]{pdfpages} 
\usepackage{xcolor,bookmark}         
\usepackage{graphicx}  
\usepackage{multicol} 
\usepackage[bottom]{footmisc}
\usepackage{shadethm}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{paralist}
\usepackage{amssymb}
\usepackage[framemethod=tikz]{mdframed}

\definecolor{aufgaben}{rgb}{0.9333,0.93333,0.933333}

\newtheoremstyle{mystyle2}
  {\topsep}{\topsep}{}{}%
  {\bfseries}{}{.5em}{}%

\theoremstyle{mystyle2}

\newmdtheoremenv[hidealllines=true,
backgroundcolor=aufgaben,skipabove=\topsep,
skipbelow=\topsep]{aufgabe}{Aufgabe}


\begin{document}
text\\ a lot of text\\
\begin{aufgabe}
the excercise
\end{aufgabe}
%no space here! please!
\begin{aufgabe}
the next excercise
\end{aufgabe}
text\\text\\text\\ really a lot of text\\ text\\ text\\text\\ text\\ text\\
\end{document}

(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
3  
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
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. –  barbara beeton Sep 1 '12 at 13:16
add comment

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

\newtheoremstyle{mystyle2}
  {}{}{}{}%
  {\bfseries}{}{.5em}{}%

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

\newmdtheoremenv[hidealllines=true,
backgroundcolor=aufgaben,skipabove=0pt,
skipbelow=0pt]{aufgabe}{Aufgabe}

And it works.

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

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.