I would suggest you a slightly different approach, using the tcolorbox
package and its \tcbmaketheorem
command from the theorems
library; the freelance skin gives you complete freedom to design the shape for the title and the body using the power of TikZ.
This approach satisfies your three requirements and gives you many customization possibilities.
Here's an example in which I easily produced chamfered rectangles; two styles were defined which can be used for various structures:
\documentclass{scrbook}
\usepackage[svgnames]{xcolor}
\usepackage{chngcntr}
\usepackage{amssymb}
\usepackage{aliascnt}
\usepackage{tikz}
\usetikzlibrary{shapes.misc,calc}
\usepackage{tcolorbox}
\tcbuselibrary{skins,theorems,breakable}
\definecolor{mygray}{RGB}{215,215,215}
\definecolor{myblue}{RGB}{17,94,140}
\makeatletter
\tcbset{
mytheorem/.code args={#1#2#3#4}{%
\refstepcounter{#2}\label{#4}%
\pgfkeysalso{title={\setbox\z@=\hbox{#1~\csname the#2\endcsname\ }\hangindent\wd\z@\hangafter=1 \mbox{#1~\csname the#2\endcsname\ }(#3)}}},%
}
\newcommand{\mtcbmaketheorem}[5]{%
\newtcolorbox{#1}[3][]{#3,mytheorem={#2}{#4}{##2}{#5:##3},##1}%
}
\makeatother
\newcounter{defi}
\newaliascnt{lemm}{defi}
\counterwithin{defi}{chapter}
\counterwithin{lemm}{chapter}
\tcbset{
thmstyle/.style={
breakable,
freelance,
boxrule=2pt,
width=\linewidth,
frame code={%
\path[fill=myblue,draw=myblue!75!black]
(frame.north west) -- ([xshift=-8pt]frame.north east) --
([yshift=-8pt]frame.north east) -- (frame.north east|-interior.north east) --
(frame.north west|-interior.north west) -- cycle;
},
interior titled code={
\path[fill=mygray!80,draw=mygray]
(frame.west|-interior.north west) -- (frame.east|-interior.north east) --
([yshift=8pt]frame.east|-interior.south east) --
([xshift=-8pt]frame.east|-interior.south east) --
(frame.west|-interior.south west) -- cycle;
},
fonttitle=\bfseries\sffamily
},
defstyle/.style={
breakable,
freelance,
boxrule=2pt,
width=\linewidth,
frame code={%
\path[top color=myblue!50,bottom color=myblue!50,
middle color=myblue!50]
([xshift=8pt]frame.north west) -- ([xshift=-8pt]frame.north east) --
([yshift=-8pt]frame.north east) --
(frame.north east|-interior.north east) --
(frame.north west|-interior.north west) --
([yshift=-8pt]frame.north west) -- cycle;
},
interior titled code={
\path[fill=mygray!80]
(frame.west|-interior.north west) -|
([yshift=8pt]frame.east|-interior.south east) --
([xshift=-8pt]frame.east|-interior.south east) --
([xshift=8pt]frame.west|-interior.south west) --
([yshift=8pt]frame.west|-interior.south west) -- cycle;
\path[fill=myblue]
([xshift=0.5\pgflinewidth,yshift=1.5pt]frame.west|-interior.north west)
rectangle
([xshift=-0.5\pgflinewidth,yshift=-1.5pt]frame.east|-interior.north east);
},
fonttitle=\bfseries\sffamily\normalcolor
}
}
\mtcbmaketheorem{defi}{Definition}{defstyle}{defi}{df}
\mtcbmaketheorem{lemm}{Lemma}{thmstyle}{lemm}{lm}
\begin{document}
\chapter{A test chapter}
\begin{defi}{Partially ordered set}{poset}
A partial order is a binary relation $\preccurlyeq$ over a set $P$ which is antisymmetric, transitive, and reflexive. A set with a partial order is called a partially ordered set (also called a poset).
\end{defi}
\begin{lemm}{Zorn's Lemma}{zorn}
Suppose a non-empty partially ordered set $P$ has the property that every non-empty chain has an upper bound in $P$. Then the set $P$ contains at least one maximal element.
\end{lemm}
\begin{lemm}{A list test}{lsit}
\begin{itemize}
\item First.
\item Second.
\item Third.
\end{itemize}
\end{lemm}
\end{document}
To get the desired formatting for the theorem head, I used a little variation of \tcbmaketheorem
.
The style used for definitions clearly shows that you can customize the three elements (title, body, separator) independently.
After the edit to the question, here are the required modifications:
\documentclass{scrbook}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[svgnames]{xcolor}
\usepackage{chngcntr}
\usepackage{amssymb}
\usepackage{aliascnt}
\usepackage{tikz}
\usepackage{lipsum}
\usetikzlibrary{shapes.misc,calc}
\usepackage{tcolorbox}
\tcbuselibrary{skins,theorems,breakable}
\renewcommand*\familydefault{\sfdefault}
\definecolor{hellgrau}{RGB}{215,215,215}
\definecolor{blau}{RGB}{17,94,140}
\definecolor{orange}{RGB}{229,94,30}
\makeatletter
\tcbset{
mytheorem/.code args={#1#2#3#4}{
\refstepcounter{#2}\label{#4}
\pgfkeysalso{title={\setbox\z@=\hbox{#1~\csname the#2\endcsname\ }\hangindent\wd\z@\hangafter=1 \mbox{#1~\csname the#2\endcsname\ }(#3)}}},
}
\newcommand{\mtcbmaketheorem}[5]{
\newtcolorbox{#1}[3][]{#3,mytheorem={#2}{#4}{##2}{#5:##3},##1}
}
\makeatother
\newcounter{defi}
\newaliascnt{lemm}{defi}
\counterwithin{defi}{chapter}
\counterwithin{lemm}{chapter}
\tcbset{
defstyle/.style={
enhanced,
breakable,
freelance,
boxrule=1pt,
width=\linewidth,
frame code={%
\path[fill=blau]
([yshift=-7.5pt]frame.north west) -- ([xshift=7.5pt]frame.north west) --
(frame.north east) -- (frame.north east|-interior.north east) --
(frame.north west|-interior.north west) -- cycle;
},
interior titled code={
\path[fill=hellgrau]
(frame.west|-interior.north west) -- (frame.east|-interior.north east) --
(frame.east|-interior.south east) -- (frame.west|-interior.south west) -- cycle;
\path[draw=white, line width=1pt] ([xshift=-1pt]frame.west|-interior.north west) -- ([xshift=1pt]frame.east|-interior.north east);
},
interior code={
\path[fill=hellgrau]
(frame.west|-interior.north west) -- (frame.east|-interior.north east) --
(frame.east|-interior.south east) -- (frame.west|-interior.south west) -- cycle;
\path[draw=white, line width=1pt] ([xshift=-1pt]frame.west|-interior.north west) -- ([xshift=1pt]frame.east|-interior.north east);
},
fonttitle=\bfseries\sffamily,
toprule at break=0pt,
},
satzstyle/.style={
enhanced,
breakable,
freelance,
boxrule=1pt,
width=\linewidth,
frame code={%
\path[fill=orange]
([yshift=-7.5pt]frame.north west) -- ([xshift=7.5pt]frame.north west) --
(frame.north east) -- (frame.north east|-interior.north east) --
(frame.north west|-interior.north west) -- cycle;
},
interior titled code={
\path[fill=hellgrau]
(frame.west|-interior.north west) -- (frame.east|-interior.north east) --
(frame.east|-interior.south east) -- (frame.west|-interior.south west) -- cycle;
\path[draw=white, line width=1pt] ([xshift=-1pt]frame.west|-interior.north west) -- ([xshift=1pt]frame.east|-interior.north east);
},
interior code={
\path[fill=hellgrau]
(frame.west|-interior.north west) -- (frame.east|-interior.north east) --
(frame.east|-interior.south east) -- (frame.west|-interior.south west) -- cycle;
\path[draw=white, line width=1pt] ([xshift=-1pt]frame.west|-interior.north west) -- ([xshift=1pt]frame.east|-interior.north east);
},
fonttitle=\bfseries\sffamily,
toprule at break=0pt,
}
}
\mtcbmaketheorem{defi}{Definition}{defstyle}{defi}{df}
\mtcbmaketheorem{lemm}{Lemma}{satzstyle}{lemm}{lm}
\begin{document}
\chapter{A test chapter}
\begin{defi}{Partially ordered set}{poset}
A partial order is a binary relation $\preccurlyeq$ over a set $P$ which is antisymmetric, transitive, and reflexive. A set with a partial order is called a partially ordered set (also called a poset).
\end{defi}
\begin{lemm}{Zorn's Lemma}{zorn}
Suppose a non-empty partially ordered set $P$ has the property that every non-empty chain has an upper bound in $P$. Then the set $P$ contains at least one maximal element.
\end{lemm}
\lipsum[1-2]
\begin{lemm}{Poissonpunktprozess}{PoissPunktProzess}
Wir nehmen an, unser System zuf"alliger Punkte erf"ullt folgende Bedingungen:
\begin{enumerate}
\item $N_{a,b}$ und $N_{c,d}$ sind stochastisch unabh"angig und $[a,b] \cap [c,d] = \emptyset$. \label{item1:satz:PoissPunktProzess}
\item $N_{a+s,b+s}$ und $N_{a,b}$ haben f"ur alle $s \in [0,\infty)$ die gleiche Verteilung. \label{item2:satz:PoissPunktProzess}
\item Es existiert ein $\lambda > 0$, so dass $\lim_{\Delta t \downarrow 0} \frac{P_1(\Delta t)}{\Delta t} = \lambda$. \label{item3:satz:PoissPunktProzess}
\item Es ist $\lim_{\Delta t \downarrow 0} \frac{P(N_{\Delta t} \geq 2)}{\Delta t} = 0$. \label{item4:satz:PoissPunktProzess}
\end{enumerate}
Dann gilt f"ur $t \geq 0$ bzw. $a,b \in [0,\infty)$, $b > a \geq 0$:
\begin{itemize}
\item $N_t$ ist Poissonverteilt zum Parameter $\lambda t$,
\item $N_{a,b}$ ist Poissonverteilt zum Parameter $\lambda(b-a)$.
\end{itemize}
\end{lemm}
\end{document}
To define a "plain" frame, use the same idea: define an appropriate style (I called it plainstyle
), and now use \newtcolorbox
to define the new environment with the desired style and with one mandatory argument for the title. To automatically add the quotes for the title, you can use the before title, after title keys (since I an not familiar with the German quotation style, I used standard quotation marks):
\documentclass{scrbook}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[svgnames]{xcolor}
\usepackage{chngcntr}
\usepackage{amssymb}
\usepackage{aliascnt}
\usepackage{tikz}
\usepackage{lipsum}
\usetikzlibrary{shapes.misc,calc}
\usepackage{tcolorbox}
\tcbuselibrary{skins,theorems,breakable}
\renewcommand*\familydefault{\sfdefault}
\definecolor{hellgrau}{RGB}{215,215,215}
\definecolor{blau}{RGB}{17,94,140}
\definecolor{orange}{RGB}{229,94,30}
\makeatletter
\tcbset{
mytheorem/.code args={#1#2#3#4}{
\refstepcounter{#2}\label{#4}
\pgfkeysalso{title={\setbox\z@=\hbox{#1~\csname the#2\endcsname\ }\hangindent\wd\z@\hangafter=1 \mbox{#1~\csname the#2\endcsname\ }(#3)}}},
}
\newcommand{\mtcbmaketheorem}[5]{
\newtcolorbox{#1}[3][]{#3,mytheorem={#2}{#4}{##2}{#5:##3},##1}
}
\makeatother
\newcounter{defi}
\newaliascnt{lemm}{defi}
\counterwithin{defi}{chapter}
\counterwithin{lemm}{chapter}
\tcbset{
defstyle/.style={
enhanced,
breakable,
freelance,
boxrule=1pt,
width=\linewidth,
frame code={%
\path[fill=blau]
([yshift=-7.5pt]frame.north west) -- ([xshift=7.5pt]frame.north west) --
(frame.north east) -- (frame.north east|-interior.north east) --
(frame.north west|-interior.north west) -- cycle;
},
interior titled code={
\path[fill=hellgrau]
(frame.west|-interior.north west) -- (frame.east|-interior.north east) --
(frame.east|-interior.south east) -- (frame.west|-interior.south west) -- cycle;
\path[draw=white, line width=1pt] ([xshift=-1pt]frame.west|-interior.north west) -- ([xshift=1pt]frame.east|-interior.north east);
},
interior code={
\path[fill=hellgrau]
(frame.west|-interior.north west) -- (frame.east|-interior.north east) --
(frame.east|-interior.south east) -- (frame.west|-interior.south west) -- cycle;
\path[draw=white, line width=1pt] ([xshift=-1pt]frame.west|-interior.north west) -- ([xshift=1pt]frame.east|-interior.north east);
},
fonttitle=\bfseries\sffamily,
toprule at break=0pt,
},
satzstyle/.style={
enhanced,
breakable,
freelance,
boxrule=1pt,
width=\linewidth,
frame code={%
\path[fill=orange]
([yshift=-7.5pt]frame.north west) -- ([xshift=7.5pt]frame.north west) --
(frame.north east) -- (frame.north east|-interior.north east) --
(frame.north west|-interior.north west) -- cycle;
},
interior titled code={
\path[fill=hellgrau]
(frame.west|-interior.north west) -- (frame.east|-interior.north east) --
(frame.east|-interior.south east) -- (frame.west|-interior.south west) -- cycle;
\path[draw=white, line width=1pt] ([xshift=-1pt]frame.west|-interior.north west) -- ([xshift=1pt]frame.east|-interior.north east);
},
interior code={
\path[fill=hellgrau]
(frame.west|-interior.north west) -- (frame.east|-interior.north east) --
(frame.east|-interior.south east) -- (frame.west|-interior.south west) -- cycle;
\path[draw=white, line width=1pt] ([xshift=-1pt]frame.west|-interior.north west) -- ([xshift=1pt]frame.east|-interior.north east);
},
fonttitle=\bfseries\sffamily,
toprule at break=0pt,
},
plainstyle/.style={
enhanced,
breakable,
freelance,
boxrule=1pt,
width=\linewidth,
frame code={%
\path[fill=orange]
([yshift=-7.5pt]frame.north west) -- ([xshift=7.5pt]frame.north west) --
(frame.north east) -- (frame.north east|-interior.north east) --
(frame.north west|-interior.north west) -- cycle;
},
interior titled code={
\path[fill=hellgrau]
(frame.west|-interior.north west) -- (frame.east|-interior.north east) --
(frame.east|-interior.south east) -- (frame.west|-interior.south west) -- cycle;
\path[draw=white, line width=1pt] ([xshift=-1pt]frame.west|-interior.north west) -- ([xshift=1pt]frame.east|-interior.north east);
},
interior code={
\path[fill=hellgrau]
(frame.west|-interior.north west) -- (frame.east|-interior.north east) --
(frame.east|-interior.south east) -- (frame.west|-interior.south west) -- cycle;
\path[draw=white, line width=1pt] ([xshift=-1pt]frame.west|-interior.north west) -- ([xshift=1pt]frame.east|-interior.north east);
},
fonttitle=\bfseries\sffamily,
before title=``,
after title='',
toprule at break=0pt,
}
}
\mtcbmaketheorem{defi}{Definition}{defstyle}{defi}{df}
\mtcbmaketheorem{lemm}{Lemma}{satzstyle}{lemm}{lm}
\newtcolorbox{MyBox}[1]{plainstyle,title=#1}
\begin{document}
\chapter{A test chapter}
\begin{defi}{Partially ordered set}{poset}
A partial order is a binary relation $\preccurlyeq$ over a set $P$ which is antisymmetric, transitive, and reflexive. A set with a partial order is called a partially ordered set (also called a poset).
\end{defi}
\begin{lemm}{Zorn's Lemma}{zorn}
Suppose a non-empty partially ordered set $P$ has the property that every non-empty chain has an upper bound in $P$. Then the set $P$ contains at least one maximal element.
\end{lemm}
\begin{MyBox}{A plain frame}
Suppose a non-empty partially ordered set $P$ has the property that every non-empty chain has an upper bound in $P$. Then the set $P$ contains at least one maximal element.
\end{MyBox}
\end{document}
Best Answer
Assume
foo
is some environment; withLaTeX does some bookkeping, opens a group and expands the macro
With
some check are performed,
\endfoo
is expanded and the group is closed.In the case of
theorem
, we can testwhich gives
It may seem that
\endtheorem
is no big deal; but let's see what\endtrivlist
means:So you're missing several things if you omit
\end{theorem}
.Perhaps, in the case of
theorem
not much is missed, but only getting "similar" output doesn't guarantee that, maybe some pages later, something goes awry. The most striking aspect in the particular case is that the vertical spacing after the statement will be wrong, even if you leave an empty line after the closing brace.This practice is definitely not recommendable: some environments do the bulk of their work exactly at
\end...
; others do almost nothing at that stage. One should know in depth what every environment does.Finally, the
{\theorem ...}
syntax is clumsy.