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}
If a document indents the first line of a paragraph (in TeX jargon, the indentation amount is governed by the \parindent
length parameter), one usually does not provide extra vertical space between ordinary paragraphs, i.e., the length of the \parskip
parameter is 0pt
by default.
Conversely, some - but certainly not all - document styles that set \parindent
to zero also set a non-zero amount of \parskip
. Otherwise, situations can easily arise where the reader wouldn't be sure if a parapraph break is present or not.
In TeX and LaTeX, a paragraph break is generated automatically whenever one or more entirely-blank lines in the input file are encountered. It is considered bad form to generate line breaks through \\
instructions (and unpleasant things can happen if you do it anyway).
Somewhat different considerations apply for "out-of-the-ordinary" paragraphs, such as theorems. There, one generally does want to generate some visual separation from the surrounding, ordinary-text paragraphs. Just how much extra vertical space is inserted above and below the theorem depends on whether you've loaded certain theorem-related packages such as ntheorem
or amsthm
; the latter is loaded automatically if you use a document class such as amsart
.
Coming to your final question, there are indeed differences, in terms of the vertical space above display-math material, depending on whether \[ ... \]
, \begin{equation} ... \end{equation}
or one of the amsmath
multiline equation environments such as align
and gather
are used. For more information on this subject see, e.g., the postings abovedisplayskip vs abovedisplayshortskip and Un-indent all paragraphs and increase the space between paragraphs.
Best Answer
One option using
amsthm
and a new defined style (I also used\swapnumbers
since your example suggests that you want numbers to appear before the name):The result:
The
ntheorem
package offers you the out of the box stylechangebreak
:The examples above will produce the head, a line break and then the body of the structure; if a complete blank line separating the head and the body is required, then you can modify my examples. For the first case, using
amsthm
, one could say something likewhich will now produce
but I find this extra spacing to be odd and wouldn't recommend this style. Something similar (defining a new style) can be done using
ntheorem
.