I am attempting to use this example environmment in my book. I really like how it creates a vertical line next to examples. I would like to customize the appearance, but that is a separate question.

In this question, I would like to focus on another issue. When I use this in my kaobook, it changes the indentation of lists inside of kaobox environments:

enter image description here

fontsize=10pt, % Base font size
twoside=false, % Use different layouts for even and odd pages (in particular, if twoside=true, the margin column will be always on the outside)
%open=any, % If twoside=true, uncomment this to force new chapters to start on any page, not only on right (odd) pages
%chapterprefix=true, % Uncomment to use the word "Chapter" before chapter numbers everywhere they appear
%chapterentrydots=true, % Uncomment to output dots from the chapter name to the page number in the table of contents
numbers=noenddot, % Comment to output dots after chapter numbers; the most common values for this option are: enddot, noenddot and auto (see the KOMAScript documentation for an in-depth explanation)
%draft=true, % If uncommented, rulers will be added in the header and footer
%overfullrule=true, % If uncommented, overly long lines will be marked by a black box; useful for correcting spacing problems

% Set the language
\usepackage[english]{babel} % Load characters and hyphenation
\usepackage[english=british]{csquotes} % English quotes

% Load mathematical packages for theorems and related environments. NOTE: choose only one between 'mdftheorems' and 'plaintheorems'.


\settowidth{\longestlabel}{\bfseries viii.}
\settasks{label=\roman*., label-format={\bfseries}, label-width=\longestlabel,
    item-indent=20pt, label-offset=2pt, column-sep={10pt}}
\newcommand{\QuestionNB}{\bfseries\arabic{Question}.\ }
\renewcommand{\ExerciseHeader}{\noindent\def\stackalignment{l}% code from https://tex.stackexchange.com/a/195118/101651
    {\bigskip\noindent\textcolor{cyan}{\textbf{CHAPTER \thechapter}}\newline\newline%
        \noindent\bfseries\emph{\textcolor{cyan}{\AnswerName\ \ExerciseHeaderNB, page %
    {\noindent\bfseries\emph{\textcolor{cyan}{\AnswerName\ \ExerciseHeaderNB, page \pageref{\AnswerRef}}}\smallskip}}

\def\exampletext{Example} % If English
\NewTColorBox[use counter=bookexample]{bookexamplebox}{O{}o}{%
% Example Frame Start
empty,% Empty previously set parameters
title={\exampletext\ \thetcbcounter: #1},% use \thetcbcounter to access the 
% Attaching a box requires an overlay
attach boxed title to top left,
% Ensures proper line breaking in longer titles
minipage boxed title,
% (boxed title style requires an overlay)
boxed title style={empty,size=minimal,toprule=0pt,top=4pt,left=3mm,overlay={}},
pad at break=0mm,
before upper=\csname @totalleftmargin\endcsname0pt, % Use instead of 
parbox=true, %This ensures parskip is inherited by box.
% Handles box when it exists on one page only
overlay unbroken={\draw[colexam,line width=5pt] ([xshift=-0pt]title.north 
  west) -- ([xshift=-0pt]frame.south west); 
%Handles multipage box: first page
overlay first={\draw[colexam,line width=5pt] ([xshift=-0pt]title.north west) 
  -- ([xshift=-0pt]frame.south west); },
%Handles multipage box: middle page
overlay middle={\draw[colexam,line width=5pt] ([xshift=-0pt]frame.north west) 
  -- ([xshift=-0pt]frame.south west); },
% Handles multipage box: last page
overlay last={\draw[colexam,line width=5pt] ([xshift=-0pt]frame.north west) - 
  - ([xshift=-0pt]frame.south west); },%
  \colorlet{colexam}{red!55!black} % Global example color

\chapter{Chapter Name}

Consider the following list:
    \item Item 1
    \item Item 2
    \item Item 3

Consider the following list:
    \item Question 1
    \item Question 2
    \item Question 3

Consider the following list:
    \item Question 1
    \item Question 2
    \item Question 3

Consider the following list:
    \item Solution 1
    \item Solution 2
    \item Solution 3

Consider the following list:
    \item Item 1
    \item Item 2
    \item Item 3

Consider the following list:
    \item Question 1
    \item Question 2
    \item Question 3

\vspace{-\baselineskip}% <-- You don't need this line of code if there's some text here
\Question Multiple choice question
\task Choice 1
\task Choice 2
\task Choice 3
\task\label{correctchoice_1.1.1} Choice 4

\Question Multi-part question
\task Part 1
\task Part 2
\task Part 3
\Question This is a solution of Ex 1

Notice how the first and second kaobox have lists that are indented properly. But after the example with the red vertical line, indentation is wrong for all every kaobox that follows.

Here is a link to an Overleaf project, if it helps.

  • (1) Your MWE does not compile (Missing \usepackage{styles/mdftheorems}). (2) Link to Overleaf not shared. Jul 12 at 14:48
  • Oops! Overleaf link fixed! Thank you for the notice Jul 12 at 16:35

Using \usepackage{styles/mdftheorems}; adding to your MWE


and correcting

    \colorlet{colexam}{red!55!black} % Global example color
    }{\end{bookexamplebox}}% changed <<<

solves the problem.


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.