20

Trying to prepare homeschool reading material for kids in lockdown and I would love to use an environment like the one below:

enter image description here

I adapted codes from enter link description here Credit @SebGlav and made some modifications as below.

\documentclass[12pt,openany,twoside,fleqn]{book}
\usepackage{amsmath}
\usepackage{tikz,lipsum}
\usetikzlibrary{shapes.symbols,positioning}
\usepackage{mathspec}
\setmainfont{ITC Berkeley Oldstyle Std} 
\setmathsfont(Digits,Greek,Latin){ITC Berkeley Oldstyle Std} 
\usepackage{chemfig}
\setlength{\parindent}{0pt}
\definecolor{pina}{HTML}{7B68EE}
\usepackage{enumitem}
%Codes adapted from tex.stackexchange.com/questions/617495/how-to-produce- 
fancy-box-in-tcolorbox
%Respect and credit to @SebGlav 
\newcounter{examp}
\setcounter{examp}{0}
\newcommand{\mytitlex}[2]%
{%
\stepcounter{examp}
\begin{tikzpicture}[font=\fontspec{Chevin}]
\def\cola{pina}
\node[fill=\cola,anchor=west,minimum height=17mm,minimum width=3.8cm] 
at (-1,0) {}; 
\node[fill=white,line width=2pt,circle,draw=\cola,minimum size=1cm] 
at (2.25,-.95) {\thechapter.\theexamp}; 
\node[text=white,anchor=west,align=center] at (-1,0) {\large\bfseries 
CHECK YOUR\\ UNDERSTANDING}; 
\draw[line width=3pt,\cola](2,.777)--(15,.777); 
\end{tikzpicture}
}
\begin{document}
\setcounter{chapter}{1}
\chapter{Alkenes}
\mytitlex{}{}
\begin{enumerate}
\item
\begin{enumerate}[label=\textbf{\alph*}]
\item Explain the 
\item Give two 
\end{enumerate}
\item Explain the difference 
\end{enumerate}
\end{document}

And this gave me

enter image description here

Any kind help to achieve the desired environment is highly welcomed.

0

1 Answer 1

35

The tcolorbox package is very flexible and you can do almost anything in it.

This solution auto numbers the boxes, resetting numbers every section heading. There's no bottom rule (as in your question), which might be confusing if it isn't clear when the box finishes, but one could be added easily enough. I chose to draw the top rule manually in frame code, since the way tcolorbox draws rules tends to leave artefacts when viewed on screen.

\documentclass{article}

\usepackage{lipsum}
\usepackage{microtype}

\usepackage{roboto}

\usepackage{tcolorbox}
\tcbuselibrary{skins}

\newtcolorbox[auto counter, number within=section]{checkyourunderstanding}{%
  enhanced,
  before skip=\bigskipamount, after skip=\bigskipamount,
  size=minimal, left=2.8cm, top=3mm, toprule=3pt,
  colframe=cyan, colbacktitle=cyan, colback=white,
  fontupper=\sffamily\small,
  title=CHECK YOUR UNDERSTANDING,
  attach boxed title to top left={yshift=-\tcboxedtitleheight},
  center title, minipage boxed title=2.5cm,
  fonttitle=\sffamily\robotocondensed\bfseries\small,
  boxed title style={
    size=minimal, boxsep=4pt, bottom=5mm,
    frame code={
      \path[fill=tcbcolback]
        (frame.north west) -- ([yshift=2mm]frame.south west) --
        ([xshift=2mm]frame.south west) -- (frame.south east) --
        (frame.north east) -- cycle;
      \path[fill=white, draw=tcbcolback, line width=1pt]
        ([xshift=-5mm-0.5pt]frame.south east) circle [radius=5mm]
        node [font=\sffamily\large] {\thetcbcounter};
    },
    interior engine=empty
  },
  frame code={
    \path[fill=tcbcolframe]
      (frame.north west) rectangle ([yshift=-3pt]frame.north east);
  }
}

\usepackage{enumitem}

\newcommand*{\listnum}{\sffamily\robotoblack\color{cyan}}
\newcommand*{\textlistnum}[1]{%
  \begingroup\listnum #1\endgroup
}

\setlist[enumerate,1]{label=\listnum\arabic*}
\setlist[enumerate,2]{label=\listnum\alph*, leftmargin=1.5em}


\begin{document}

\section{Lorem Ipsum}

\lipsum[1]

\begin{checkyourunderstanding}
  \begin{enumerate}
    \item
      \begin{enumerate}
        \item Explain the difference between a physical property and a
          chemical property.
        \item Give two examples of each type of property.
      \end{enumerate}
    \item Explain the difference between:
      \begin{enumerate}
        \item melting and freezing.
        \item boiling and evaporating.
        \item boiling point and normal boiling point.
        \item gas and vapour.
      \end{enumerate}
    \item Define density. What are the common units for it.
    \item Explain how you would decide whether \textlistnum{a} a solid,
      \textlistnum{b} a liquid was a pure substance.
  \end{enumerate}
\end{checkyourunderstanding}

\lipsum[2]

\end{document}

output

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .