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