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.

This is a follow-up question of Combining spacebelow with shaded parameter in thmtools package. Bug?. How can I get rid of the space above the theorem box? If I comment out the mdframed=... line it works, but I also want a nice gray theorem box. Is there a workaround?

\documentclass{article}
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{thmtools}

\declaretheoremstyle[
    mdframed={backgroundcolor=gray!80, hidealllines=true, innertopmargin=6pt, innerbottommargin=60pt, skipabove=\topsep, skipbelow=\topsep },
    spaceabove=0pt, spacebelow=0pt
 ]{mystyle}
\declaretheorem[style=mystyle]{BoxI}

\begin{document}
Text, Text, Text, Text, Text, Text, Text, Text, Text, Text, Text
  \begin{BoxI}[Euclid]
    Text...
  \end{BoxI}
Text, Text, Text, Text, Text, Text, Text, Text, Text, Text, Text
\end{document}
share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

I think this might be a not completely smooth interaction between the packages; skipbelow accepts negative values, but skipabove, and even spaceabove (from thmtools) when the mdframed key is in action, seem to ignore values that are less than 0pt. This might have to do with the fact that thmtools uses \addtotheorempreheadhook to pass the options to the mdframed environment.

In any case, you can to use preheadhook to control the spacing before the structure:

\documentclass{article}
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{thmtools}

\declaretheoremstyle[
preheadhook={\vskip\dimexpr\topsep-0.5\ht\strutbox\relax},
mdframed={
  backgroundcolor=gray!80,
  hidealllines=true,
  innertopmargin=6pt,
  innerbottommargin=60pt,
  skipabove=0pt,
  skipbelow=\topsep}
 ]{mystyle}
\theoremstyle{remark}
\declaretheorem[style=mystyle]
{BoxI}

\begin{document}
Text, Text, Text, Text, Text, Text, Text, Text, Text, Text, Text
  \begin{BoxI}[Euclid]
Text, Text, Text, Text, Text, Text, Text, Text, Text, Text, Text
Text, Text, Text, Text, Text, Text, Text, Text, Text, Text, Text
  \end{BoxI}
Text, Text, Text, Text, Text, Text, Text, Text, Text, Text, Text
\end{document}

enter image description here

I used a \vskip of \topsep-0.5\ht\strutbox, but of course you can use the desired length according to your needs.

share|improve this answer
    
cool, thanks a lot!!! –  user4811 Apr 24 '13 at 22:02
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.