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.

Consider this answer from karlkoeller:

\documentclass[danish]{article}

\usepackage{babel}
\usepackage{color}
\usepackage{amsthm,thmtools}

% Colors.
\definecolor{section_color}{rgb}{0.35,0.0,0}
\definecolor{MyGray}{rgb}{0.96,0.97,0.98}

% Defining common style.
\declaretheoremstyle[
  spaceabove = 6pt,
  spacebelow = 6pt,
  headfont = \color{section_color}\sffamily\bfseries,
  notefont = \mdseries,
  notebraces = {(}{)},
  bodyfont = \normalfont,
  postheadspace = 1em,
  qed = ,
]{mystyle}

% Defining theorem environment.
\declaretheorem[
  style = mystyle,
  name = S{\ae}tning,
  shaded = {
    bgcolor = MyGray,
    padding = 2mm,
    textwidth = 0.98\textwidth
}
]{theorem}

% Defining claim environment.
\declaretheorem[
  sibling = theorem,
  style = mystyle,
  shaded = {
    bgcolor = MyGray,
    padding = 2mm,
    textwidth = 0.98\textwidth
  }
]{claim}

\makeatletter
\renewenvironment{proof}[1][\proofname]{\par
  \pushQED{\qed}%
  \normalfont \topsep6\p@\@plus6\p@\relax
  \list{}{\leftmargin=1.25mm\itemindent=20pt\linewidth=0.975\textwidth%
  \item[\hskip\labelsep
        \color{section_color}\sffamily\bfseries
   #1\@addpunct{.}]\ignorespaces}
}{%
  \popQED\endlist\@endpefalse
}
\makeatother


\begin{document}

\begin{theorem}[Eulers identitet]
$e^{i\pi} + 1 = 0$.
\end{theorem}

\begin{proof}
Brug Eulers formul; $e^{ix} = \cos x + i\sin x$.
\end{proof}

\begin{proof}[Bevis for Fermats sidste S{\ae}tning]
Sp{\o}rg Sir Andrew John Wiles.
\end{proof}

\end{document}

output

As can be seen in the screenshot, the vertical spacing around the theorem environment is bigger than the spacing around the proof environment; how do I change it to be the same?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

We can create an mdframed environment which simulates the one created for theorems:

\newmdenv[
  leftmargin = -2pt,
  rightmargin = -2pt,
  innerleftmargin = 2mm,
  innerrightmargin = 2mm,
  innertopmargin = 6pt,
  innerbottommargin = 6pt,
  skipabove = 1pt,
  skipbelow = 10pt,
  linewidth = 0pt,
  backgroundcolor = white
]{proofbox}

and then apply it to the redefinition of proof

\makeatletter
\renewenvironment{proof}[1][\proofname]{\proofbox\par
  \pushQED{\qed}%
  \normalfont \topsep6\p@\@plus6\p@\relax
  \trivlist
  \item[\hskip\labelsep
        \color{section_color}\sffamily\bfseries
    #1\@addpunct{.}]\ignorespaces
}{%
  \popQED\endtrivlist\@endpefalse\endproofbox
}
\makeatother

Complete code:

\documentclass[danish]{article}

\usepackage{babel}
\usepackage{color}
\usepackage{amsthm,thmtools}
\usepackage{mdframed}

% Colors.
\definecolor{section_color}{rgb}{0.35,0.0,0}
\definecolor{MyGray}{rgb}{0.96,0.97,0.98}

% Defining common style.
\declaretheoremstyle[
  spaceabove = 6pt,
  spacebelow = 6pt,
  headfont = \color{section_color}\sffamily\bfseries,
  notefont = \mdseries,
  notebraces = {(}{)},
  bodyfont = \normalfont,
  postheadspace = 1em,
  qed = ,
]{mystyle}

% Defining theorem environment.
\declaretheorem[
  style = mystyle,
  name = S{\ae}tning,
  shaded = {
    bgcolor = MyGray,
    padding = 2mm,
    textwidth = 0.98\textwidth
}
]{theorem}

% Defining claim environment.
\declaretheorem[
  sibling = theorem,
  style = mystyle,
  shaded = {
    bgcolor = MyGray,
    padding = 2mm,
    textwidth = 0.98\textwidth
  }
]{claim}

\newmdenv[
  leftmargin = -2pt,
  rightmargin = -2pt,
  innerleftmargin = 2mm,
  innerrightmargin = 2mm,
  innertopmargin = 6pt,
  innerbottommargin = 6pt,
  skipabove = 1pt,
  skipbelow = 10pt,
  linewidth = 0pt,
  backgroundcolor = white
]{proofbox}

\makeatletter
\renewenvironment{proof}[1][\proofname]{\proofbox\par
  \pushQED{\qed}%
  \normalfont \topsep6\p@\@plus6\p@\relax
  \trivlist
  \item[\hskip\labelsep
        \color{section_color}\sffamily\bfseries
    #1\@addpunct{.}]\ignorespaces
}{%
  \popQED\endtrivlist\@endpefalse\endproofbox
}
\makeatother

\begin{document}

\begin{theorem}[Eulers identitet]
$e^{i\pi} + 1 = 0$.
\end{theorem}

\begin{proof}
Brug Eulers formul; $e^{ix} = \cos x + i\sin x$.
\end{proof}

\begin{proof}[Bevis for Fermats sidste S{\ae}tning]
Sp{\o}rg Sir Andrew John Wiles.
\end{proof}

\end{document} 

Output:

enter image description here

If you change the background color to

backgroundcolor = MyGray

you can appreciate the result:

enter image description here

share|improve this answer

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.