#StackBounty: #formatting #environments #books #examples #kaobook Custom example environment with colorbox and vertical line for `kaobo…

Bounty: 100

I am making a custom example environment for the kaobook class and would like to modify the second example environment from this question:

![enter image description here

usepackage{chngcntr}
usepackage[tikz]{mdframed}
usepackage{lipsum}

definecolor{greentitle}{RGB}{61,170,61}
definecolor{greentitleback}{RGB}{216,233,213}

newcounter{mdexample}
counterwithin{mdexample}{section}

newenvironment{myexample}[1]
  {stepcounter{mdexample}begin{mdframed}[
    frametitle=#1,
    frametitlefont=normalfont,
    topline=false,
    bottomline=false,
    rightline=false,
    linecolor=greentitleback,
    linewidth=2pt,
    singleextra={
      node[
        overlay,
        outer sep=0pt,
        anchor=north east,
        text width=2.5cm,
        minimum height=4ex,
        fill=greentitleback,
        font=color{greentitle}sffamilyscshape
      ] at (O|-P) {example~themdexample};
      },
    firstextra={
      node[
        overlay,
        outer sep=0pt,
        anchor=north east,
        text width=2.5cm,
        minimum height=4ex,
        fill=greentitleback,
        font=color{greentitle}sffamilyscshape
      ] at (O|-P) {example~themdexample};
      }
    ]
  }
  {end{mdframed}}

I would like to modify the environment so that:

  • I would like the green "Example" box to be on the right side of the vertical line, not in the margin.

  • I would like there to be a gap between the green "Example" box and the vertical line, instead of being connected to the vertical line.

  • I would also like there to be a "title" for the example, similar to
    this. (e.g. title: "Evaluating a Function")

enter image description here

(Disclaimer: screenshot from the Precalculus book by Robert Blitzer.)

It is tricky to post a MWE since the kaobook class has many dependencies spread across different files. In case it helps, here is a link to the Overleaf project.


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.