Simplify the example environments

This commit is contained in:
Jip J. Dekker 2021-06-01 11:32:22 +10:00
parent 3faa5602df
commit 3f5cf3aad3
No known key found for this signature in database
GPG Key ID: 517DF4A00618C9C3

View File

@ -109,36 +109,40 @@
\newcommand{\jip}[1]{\textcolor{red}{\Big[\textbf{Jip}: #1\Big]}}
% Example environment
\usepackage[many]{tcolorbox}
\newcounter{example}[chapter]
\counterwithin{example}{chapter}
\newenvironment{example}[1][]{\refstepcounter{example}\begin{examplebox}#1}{\end{examplebox}}
\usepackage{amsthm}
\usepackage{thmtools}
\declaretheoremstyle[
headfont=\usekomafont{disposition},
spaceabove=1em plus 0.75em minus 0.25em,
numberwithin=chapter,
bodyfont=\normalfont,
headformat=\ensuremath{\blacktriangleright} \NAME~\NUMBER\NOTE,
headpunct={:},
postheadspace=2em,
qed=\ensuremath{\blacktriangleleft{}},
spacebelow=1em plus 0.75em minus 0.25em,
]{exmpstyle}
\newtcolorbox{examplebox}[1][]{
breakable,
enhanced,
% skin=enhancedlast,
attach boxed title to top left={xshift=-4mm,yshift=-0.5mm},
fonttitle=\bfseries\sffamily,
attach boxed title to top center,
boxed title style={empty,arc=0pt,outer arc=0pt,boxrule=0pt},
underlay boxed title={
\draw[#1] (title.north west) -- (title.north east) -- +(\tcboxedtitleheight,-\tcboxedtitleheight)
-- (title.south west) -- +(-\tcboxedtitleheight,0)-- cycle;
},
overlay last={
\draw[#1] ([xshift=-80pt]frame.south) -- ++ (160pt,0pt);
\fill[#1] ([xshift=-30pt,yshift=-1pt]frame.south) rectangle +(60pt,2pt);
},
overlay unbroken={
\draw[#1] ([xshift=-80pt]frame.south) -- ++ (160pt,0pt);
\fill[#1] ([xshift=-30pt,yshift=-1pt]frame.south) rectangle +(60pt,2pt);
},
title={Example \theexample{}},
colback=white,
coltitle=black,
colframe=white,
}
\declaretheorem[
style=exmpstyle,
title=Example,
refname={example,examples},
Refname={Example,Examples}
]{example}
% \newtheoremstyle{example}{}{}{}{}{\usekomafont{disposition}}{. }{5pt plus 1pt minus 1pt}{}
% Arguments ---
% Thm head spec
% Space above
% Space below
% Body font
% Indent amount (empty = no indent, \parindent = para indent)
% Thm head font
% Punctuation after thm head
% Space after thm head: \newline = linebreak
% --- Note, empty = default value
% \theoremstyle{example}
% \newtheorem{example}{Example}[chapter]
% Code formatting
\usepackage[
@ -148,6 +152,7 @@
]{minted}
\usemintedstyle{borland}
\usepackage[many]{tcolorbox}
\newtcolorbox{listingbox}[1][]{
breakable,
enhanced,