14

My initial question:

I'm writing my lecture notes in LaTeX and used some customized theorem environments with amsthm so far. Now I wanted to redesign those theorems with help of tikzpicture.

That's what I want to do:

  • I want the theorem header (Theorem name, Numbering, title) to be within a tikzpicture node. Concretely I want to use tikzpicture's chamfered rectangle option.
  • I want the theorem content/body also to be within a tikzpicture node. Currently there only should be a gray background color. But there will be theorems where I want to customize this area as well (e.g. another chamfered rectangle option).
  • There shall not be a white spacing between header and body (currently there's some unwanted spacing between them) but I'd like to get an option for a definable (customizable) line to separate the header from the content.

Here's a working code example which describes my problems. Do you have any ideas?

% DOCUMENT
\documentclass[twoside]{scrbook}
\parindent0pt
\parskip6pt
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{scrhack}
\renewcommand*\familydefault{\sfdefault}

% GRAPHICS
\usepackage{xcolor, tikz}
\usetikzlibrary{shapes}
\definecolor{lightgray}{RGB}{215,215,215}
\definecolor{blue}{RGB}{17,94,140}

% MATH
\usepackage{amsmath, amsfonts, amssymb, amsthm}

% THEOREMS
\usepackage{environ}
\newtheoremstyle{defstyle}   
    {2em}
    {1em}
    {}
    {}
    {\sffamily\bfseries\large\color{white}}
    {\newline}{2ex}      
    {\tikz\node[fill=blue, inner sep=0, chamfered rectangle, chamfered rectangle corners=north east, text width=\textwidth] {
        \thmname{#1}\thmnumber{ #2}\thmnote{\quad(#3)}
    };}

\NewEnviron{definition}[1][]{
    \begin{deftmp}[#1]
    \tikz\node[fill=lightgray, rectangle, text width=\textwidth] {
        \BODY
    };
    \end{deftmp}
}

\NewEnviron{lemma}[1][]{
    \begin{lemmatmp}[#1]
    \tikz\node[fill=lightgray, inner sep=0, chamfered rectangle, chamfered rectangle corners=south east, text width=\textwidth] {
        \BODY
    };
    \end{lemmatmp}
}

\theoremstyle{defstyle}
\newtheorem{deftmp}{Definition}[chapter]
\newtheorem{lemmatmp}[deftmp]{Lemma}

% BEGIN
\begin{document}

Here's a working definition, but with some unwanted spacing between header and body:

\begin{definition}[One definition]
Text without enumerations and with simple things like formulas:
\begin{align*}
S_n = \frac{1}{n} \sum_{i=1}^n X_i
\end{align*}
\end{definition}

Here's the problem I have with enumerate within the body:

\begin{definition}[Problem definition]
Text with a enumeration:
\begin{enumerate}
\item One
\item Two
\item $\ldots$
\end{enumerate}
\end{definition}

There could also be a theorem like:

\begin{lemma}[Another theorem]
With some text.
\end{lemma}

Additionally there is a small offset on the right margin of both tikzpictures: The upper header tikzpicture is longer than the body tikzpicture though both are set to textwidth.

\end{document}

enter image description here

Update 1: A modification of Gonzalo Medina's Code:

Thanks to Gonzalo Medina I was able to rework my theorems the way I wanted them to look like. But the following MWE shows a problem with page breaking theorems. Is there a way to avoid those display misbehaviors? I'd like my theorems to stay breakable but they should break correctly.

\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={
    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);
    },
    fonttitle=\bfseries\sffamily
},
satzstyle/.style={
    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);
    },
    fonttitle=\bfseries\sffamily
}
}

\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}

enter image description here

17

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.

enter image description here

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}

enter image description here

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}

enter image description here

  • Thank you very much. I've worked through the code in order to understand it and was able to adjust the look. The only thing I don't understand is the way you format the title: \pgfkeysalso{title={\setbox\z@=\hbox{#1~\csname the#2\endcsname\ }\hangindent\wd\z@\hangafter=1 \mbox{#1~\csname the#2\endcsname\ }(#3)}}} Could you please explain how it works and how I could achieve a title where no theorem name and numbering, but only the title is displayed in quotation marks? – Robert Ternes Jun 23 '13 at 15:41
  • I've just discovered that there's a problem with those theorems breaking on a page. The content continued on the next page has another background color and rounded corners as well as some display errors. Any idea? – Robert Ternes Jun 23 '13 at 16:12
  • @RobertTernes please see my updated answer for the new code addressing the problems you mentioned in your second comment and in the edit to your question. In some time I'll provide the code for your first comment (no number, no label and quotes) :-) – Gonzalo Medina Jun 23 '13 at 17:08
  • @RobertTernes New update, this time with the code you requested in your first comment. – Gonzalo Medina Jun 23 '13 at 18:30
  • @RobertTernes regarding your question about how title is set for theorem-like frames, \pgfkeysalso{title={\setbox\z@=\hbox{#1~\csname the#2\endcsname\ }\hangindent\wd\z@\hangafter=1 \mbox{#1~\csname the#2\endcsname\ }(#3)}}} first saves the label and number in a box and then use the width of this box for the hanging indentation of the title; this, of course, can be modified according to your needs. – Gonzalo Medina Jun 23 '13 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.