考虑这个答案来自 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}
从截图中可以看出,定理环境周围的垂直间距大于证明环境周围的间距;我该如何将其改为相同?
答案1
我们可以创建一个mdframed
模拟为定理创建的环境:
\newmdenv[
leftmargin = -2pt,
rightmargin = -2pt,
innerleftmargin = 2mm,
innerrightmargin = 2mm,
innertopmargin = 6pt,
innerbottommargin = 6pt,
skipabove = 1pt,
skipbelow = 10pt,
linewidth = 0pt,
backgroundcolor = white
]{proofbox}
然后将其应用于重新定义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
完整代码:
\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}
输出:
如果将背景颜色更改为
backgroundcolor = MyGray
你可以欣赏一下结果: