2

I create an exercise sheet with solutions and I would like to use the following colourful exercise environment that I also found on this blog :

\documentclass[a4paper,10pt,oneside]{article}
\usepackage[paper=a4paper,left=35mm,right=20mm,top=25mm,bottom=20mm]{geometry}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{nth}
\usepackage{xspace}
\usepackage{amsmath}
\usepackage{pdfpages}
\usepackage{amssymb}
\usepackage{amstext}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{graphicx}
\usepackage{paralist}
\usepackage{acronym}
\usepackage{xcolor}
\usepackage{enumitem}  
\usepackage{fancyhdr}
\usepackage{tikz}
\usepackage{tikz-cd}
\usepackage{mathrsfs}
\usepackage{float}
\usepackage{subfigure}
\usepackage{leftidx}
\usepackage{lipsum}
\usepackage[many]{tcolorbox}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\xp}{x^{\prime}}
\let \ra \rangle
\let \l \langle
\newcommand{\oco}{\otimes \cdots \otimes}
\newcommand{\dos}{, \ldots ,}
\newcommand{\tis}{ \t \cdots \t}
\newcommand{\bt}[1]{\left| #1 \right|}
\newcommand{\pr}[1]{#1^{\prime}}
\newcommand{\fk}[1]{\textit{\textbf{#1}}}
\newcommand{\h}{^} % I use this command instead of ^ since my notebook has a different keyboard on which it is cumbersome to find the sign ^ 
\newcommand{\tr}[1]{\textit{\textcolor{red}{#1}}}
\let\t\times
\let\r\rightarrow
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}
\theoremstyle{definition}
\newtheorem{definition}{Definition}
\theoremstyle{definition}
\newtheorem{prop}{Proposition}
\theoremstyle{definition}
\newtheorem*{exmps}{Examples}
\theoremstyle{definition}
\newtheorem*{exmpn}{Example}
\theoremstyle{remark}
\newtheorem{remark}{Remark}[section]
\theoremstyle{definition}
\newtheorem{rems}{Remarks}[section]
\theoremstyle{definition}
\newtheorem{exmp}{Example}[section]
\definecolor{greentitle}{rgb}{0.0, 0.0, 0.5}
\definecolor{greentitleback}{rgb}{0.8, 0.8, 1.0}
\newtcolorbox[
  auto counter,
  number within=section
]{exo}[2][]{%
  breakable,
  enhanced,
  colback=white,
  colbacktitle=white,
  arc=0pt,
  leftrule=1pt,
  rightrule=0pt,
  toprule=0pt,
  bottomrule=1pt,
  titlerule=0pt,
  colframe=greentitleback,
  fonttitle=\normalcolor,
  overlay={
    \node[
      outer sep=0pt,
      anchor=east,
      text width=2.5cm,
      minimum height=4ex,
      fill=greentitleback,
      font=\color{greentitle}\sffamily\scshape
    ] at (title.west) {exercise~\thetcbcounter};
  },
  title=#2,
  #1
}
\newcommand\Solution{\par\textbf{\textit{\textcolor{greentitle}{Solution :}}}\par\medskip}
\begin{document}
\section{Exercises on categories, functors and natural transformations}
\ \\  
\begin{exo}{Let $\mathcal{C}$ and $\mathcal{D}$ be two categories.}
\begin{enumerate}
\item[a)] Prove that $\mathcal{C}\h{op}$ is a category, called the \tr{opposite category}.
\item[b)] Show that $\mathcal{C} \t \mathcal{D}$ is a category, termed the \tr{product category}. 
\end{enumerate}
\Solution
\begin{enumerate}
\item[a)] Let us remind that the opposite category  $\mathcal{C}\h{op}$ of a given category $\mathcal{C}$ is obtained by reversing the morphisms. Clearly, we have $(\mathcal{C}\h{op})\h{op} = \mathcal{C}$, since reversing the arrows twice yields the original category. It is easily comprehensible that $\mathcal{C}\h{op}$ is formed as follows : 
\begin{enumerate}
\item[\textcolor{greentitle}{•}] The objects of $\mathcal{C}\h{op}$ coincide with the objects of $\mathcal{C}$, i.e. $Ob(\mathcal{C}\h{op}) = Ob(\mathcal{C})$. 
\item[\textcolor{greentitle}{•}] Let $A, B \in Ob(\mathcal{C})$. To every morphism $f : A \r B$ in $C$, there corresponds a morphism $f\h{op} : B \r A$ in $C\h{op}$. In other words, $Hom_{\mathcal{C}}(A, B) = Hom_{\mathcal{C}\h{op}}(B, A)$. 
\item[\textcolor{greentitle}{•}] If $f: A \r B$ and $g: B \r C$ are morphisms in $\mathcal{C}$, then the composite 
\ \\ $(g \circ f)\h{op} = f\h{op} \circ g\h{op}$  in $\mathcal{C}\h{op}$ is defined to be the composite $g \circ f$ in $\mathcal{C}$, as illustrated in the diagram below. 
\begin{figure}[H] 
\centerline{\includegraphics[width=7cm]{d1col.png}}
\end{figure}
\ \\ Since $\mathcal{C}$ is a category, it is evident that the composition in $\mathcal{C}\h{op}$ is associative.  
\item[\textcolor{greentitle}{•}] The identity of $\mathcal{C}\h{op}$ is the equivalent to the identity of $\mathcal{C}$. 
\end{enumerate}
\ \\ We conclude that $\mathcal{C}\h{op}$ is a category. 
\item[b)] The product category $\mathcal{C} \t \mathcal{D}$ is composed of the following : 
\begin{enumerate}
\item[\textcolor{greentitle}{•}] The objects of $\mathcal{C} \t \mathcal{D}$ are pairs of objects $(A, B)$, where $A \in Ob(\mathcal{C})$ and $B \in Ob(\mathcal{D})$.  
\item[\textcolor{greentitle}{•}] The morphisms from $(A, B)$ to $(\pr{A}, \pr{B})$ are pairs of morphisms $(f, g)$, 
\ \\ where $f : A \r \pr{A}$ is a morphism of $\mathcal{C}$ and $g : B \r \pr{B}$ is a morphism of $\mathcal{D}$. 
\item[\textcolor{greentitle}{•}] The composition of two morphisms $(f, g) : (A, B) \r (\pr{A}, \pr{B})$ and 
\ \\ $(\pr{f}, \pr{g}) : (\pr{A}, \pr{C}) \r (A\h{\prime \prime}, B\h{\prime \prime})$ in $\mathcal{C} \t \mathcal{D}$ is defined componentwise by means of the composites in $\mathcal{C}$ and $\mathcal{D}$, i.e. $(\pr{f}, \pr{g}) \circ (f, g) = (\pr{f} \circ f, \pr{g} \circ g)$. Moreover, associativity of the composition of morphisms in $\mathcal{C} \t \mathcal{D}$ follows from the fact that the composition of morphisms in the categories $\mathcal{C}$ and $\mathcal{D}$ are associative. 
\item[\textcolor{greentitle}{•}] The identity of $\mathcal{C} \t \mathcal{D}$ is the pair $1_{(A, B)} = (1_A, 1_B)$ of identities of the categories $\mathcal{C}$ and $\mathcal{D}$ respectively. 
\end{enumerate} 
\end{enumerate}
\end{exo}
\ \\
\begin{exo}{Recall the definition of a cochain complex of vector spaces from the lecture. Show that $cCh(Vect)$ and $gVect$ are categories.} Subsequently, prove that $H : cCh(Vect) \r gVect$ is a functor, called the \tr{cohomology functor}. 
\ \\ 
\Solution
\ \\ (The solution is not complete.)It is straightforward to show that $gVect$ is a category : Let $K$ be a field. The objects of $gVect$ are $K$-vector spaces $V$ equipped with a direct sum decomposition $V = \bigoplus\limits_{k \in \Z} V_k$. 
\ \\ Let $U, V \in Ob(gVect)$. Morphisms of $\Z$-graded vector spaces are $K$-linear maps $f: U \r V$ of degree $0$, i.e. $f(U_i) \subseteq V_i$ for all $i \in \Z$. For every $U, V$ and $W \in Ob(gVect)$, the composition of morphisms $f: U \r V$ and $g : V \r W$ is defined as $g \circ f : U \r W$. The identity of $gVect$ is given by the morphism $id_V : V \r V$.
\end{exo}
\begin{exo}{Verify that the map $T : Manifold \r VectBd$ sending a smooth manifold $M$ to its tangent bundle $TM$ and a smooth map $f: M \r N$ to its derivative $Tf : TM \r TN$ is a covariant functor from the category of smooth manifolds to the category of vector bundles. }
\Solution
\end{exo}
\begin{exo}{Show that functors preserve isomorphisms.}
\ \\ 
\Solution
\end{exo}
\end{document}

However, I have two problems. Each time a new exercise begins, its numbering is indicated by a coloured box on the left hand side. The first problem is that, if an exercise with solution continues over several pages, then the coloured box indicating the numbering of the exercise also appears several times, but it should only appear once at the beginning of the new exercise.

The second problem is that I cannot write commas in the title of an exercise, because otherwise the pgfkeys error message occurs.

I would be very pleased if someone can help me to solve my problems. Unfortunately, I am not very experienced in using latex.

Thanks for your help.

  • 1
    Welcome to TeX.SX! Please provide a compilable document, not just a fragment. – Bobyandbob Mar 7 '18 at 17:41
  • It would help to have a compilable document and not fragments. And since your problems are related to tcolorbox, looking into the manual of that package could also help, especially for overlay features – user31729 Mar 7 '18 at 18:00
  • Ok, I posted the complete code. There are also some commands inside that are not necessary. – Crystal Mar 7 '18 at 18:13
  • 1
    you upload complete document :-(, but we only need a minimal work example (mwe) which exhibits your problem. for real text use dummy text generated by package lipsum or other similar. we are not so familiar with your document as you are, so we can go lost in it ... and real image replace with example-image from graphicx package. please, remove all what is not necessary for mwe – Zarko Mar 7 '18 at 18:20
  • This is neither blog nor a forum ... – user31729 Mar 7 '18 at 19:08
1

The overlay unbroken and first option will use the overlay specifications either if the box is unbroken (i.e. for short boxes) or only for the first part of the broken box.

The , issue is due to the fact, that it should be title={#2}, not title=#2,

There are so many other issues here regarding style etc, but that are not part of the question and should not made part of the question.

\documentclass[a4paper,10pt,oneside,demo]{article}
\usepackage[paper=a4paper,left=35mm,right=20mm,top=25mm,bottom=20mm]{geometry}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{nth}
\usepackage{xspace}
\usepackage{amsmath}
\usepackage{pdfpages}
\usepackage{amssymb}
\usepackage{amstext}
\usepackage{amsthm}
\usepackage{amsfonts}
%\PassOptionsToPackage{demo}{graphicx}
\usepackage{graphicx}
\usepackage{paralist}
\usepackage{acronym}
\usepackage{xcolor}
\usepackage{enumitem}  
\usepackage{fancyhdr}
\usepackage{tikz}
\usepackage{tikz-cd}
\usepackage{mathrsfs}
\usepackage{float}
\usepackage{subfigure}
\usepackage{leftidx}
\usepackage{lipsum}
\usepackage[many]{tcolorbox}

\usepackage{blindtext}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\xp}{x^{\prime}}
\let \ra \rangle
\let \l \langle
\newcommand{\oco}{\otimes \cdots \otimes}
\newcommand{\dos}{, \ldots ,}
\newcommand{\tis}{ \t \cdots \t}
\newcommand{\bt}[1]{\left| #1 \right|}
\newcommand{\pr}[1]{#1^{\prime}}
\newcommand{\fk}[1]{\textit{\textbf{#1}}}
\newcommand{\h}{^} % I use this command instead of ^ since my notebook has a different keyboard on which it is cumbersome to find the sign ^ 
\newcommand{\tr}[1]{\textit{\textcolor{red}{#1}}}
\let\t\times
\let\r\rightarrow
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}
\theoremstyle{definition}
\newtheorem{definition}{Definition}
\theoremstyle{definition}
\newtheorem{prop}{Proposition}
\theoremstyle{definition}
\newtheorem*{exmps}{Examples}
\theoremstyle{definition}
\newtheorem*{exmpn}{Example}
\theoremstyle{remark}
\newtheorem{remark}{Remark}[section]
\theoremstyle{definition}
\newtheorem{rems}{Remarks}[section]
\theoremstyle{definition}
\newtheorem{exmp}{Example}[section]
\definecolor{greentitle}{rgb}{0.0, 0.0, 0.5}
\definecolor{greentitleback}{rgb}{0.8, 0.8, 1.0}
\newtcolorbox[
  auto counter,
  number within=section
]{exo}[2][]{%
  breakable,
  enhanced,
  colback=white,
  colbacktitle=white,
  arc=0pt,
  leftrule=1pt,
  rightrule=0pt,
  toprule=0pt,
  bottomrule=1pt,
  titlerule=0pt,
  colframe=greentitleback,
  fonttitle=\normalcolor,
  overlay unbroken and first={
    \node[
      outer sep=0pt,
      anchor=east,
      text width=2.5cm,
      minimum height=4ex,
      fill=greentitleback,
      font=\color{greentitle}\sffamily\scshape
    ] at (title.west) {exercise~\thetcbcounter};
  },
  title={#2},
  #1
}
\newcommand\Solution{\par\textbf{\textit{\textcolor{greentitle}{Solution :}}}\par\medskip}
\begin{document}
\section{Exercises on categories, functors and natural transformations}
\ \\  
\begin{exo}{Let $\mathcal{C}$, and $\mathcal{D}$ be two categories.}% comma explicitly there
\begin{enumerate}[label={\alph*)}]
\item Prove that $\mathcal{C}\h{op}$ is a category, called the \tr{opposite category}.
\item Show that $\mathcal{C} \t \mathcal{D}$ is a category, termed the \tr{product category}. 
\end{enumerate}
\Solution
\begin{enumerate}
\item[a)] Let us remind that the opposite category  $\mathcal{C}\h{op}$ of a given category $\mathcal{C}$ is obtained by reversing the morphisms. Clearly, we have $(\mathcal{C}\h{op})\h{op} = \mathcal{C}$, since reversing the arrows twice yields the original category. It is easily comprehensible that $\mathcal{C}\h{op}$ is formed as follows : 
\begin{enumerate}
\item[\textcolor{greentitle}{•}] The objects of $\mathcal{C}\h{op}$ coincide with the objects of $\mathcal{C}$, i.e. $Ob(\mathcal{C}\h{op}) = Ob(\mathcal{C})$. 
\item[\textcolor{greentitle}{•}] Let $A, B \in Ob(\mathcal{C})$. To every morphism $f : A \r B$ in $C$, there corresponds a morphism $f\h{op} : B \r A$ in $C\h{op}$. In other words, $Hom_{\mathcal{C}}(A, B) = Hom_{\mathcal{C}\h{op}}(B, A)$. 
\item[\textcolor{greentitle}{•}] If $f: A \r B$ and $g: B \r C$ are morphisms in $\mathcal{C}$, then the composite 
\ \\ $(g \circ f)\h{op} = f\h{op} \circ g\h{op}$  in $\mathcal{C}\h{op}$ is defined to be the composite $g \circ f$ in $\mathcal{C}$, as illustrated in the diagram below. 
\begin{figure}[H] 
\centering 
\includegraphics[width=7cm]{d1col.png}
\end{figure}
\ \\ Since $\mathcal{C}$ is a category, it is evident that the composition in $\mathcal{C}\h{op}$ is associative.  
\item[\textcolor{greentitle}{•}] The identity of $\mathcal{C}\h{op}$ is the equivalent to the identity of $\mathcal{C}$. 
\end{enumerate}
\ \\ We conclude that $\mathcal{C}\h{op}$ is a category. 
\item[b)] The product category $\mathcal{C} \t \mathcal{D}$ is composed of the following : 
\begin{enumerate}
\item[\textcolor{greentitle}{•}] The objects of $\mathcal{C} \t \mathcal{D}$ are pairs of objects $(A, B)$, where $A \in Ob(\mathcal{C})$ and $B \in Ob(\mathcal{D})$.  
\item[\textcolor{greentitle}{•}] The morphisms from $(A, B)$ to $(\pr{A}, \pr{B})$ are pairs of morphisms $(f, g)$, 
\ \\ where $f : A \r \pr{A}$ is a morphism of $\mathcal{C}$ and $g : B \r \pr{B}$ is a morphism of $\mathcal{D}$. 
\item[\textcolor{greentitle}{•}] The composition of two morphisms $(f, g) : (A, B) \r (\pr{A}, \pr{B})$ and 
\ \\ $(\pr{f}, \pr{g}) : (\pr{A}, \pr{C}) \r (A\h{\prime \prime}, B\h{\prime \prime})$ in $\mathcal{C} \t \mathcal{D}$ is defined componentwise by means of the composites in $\mathcal{C}$ and $\mathcal{D}$, i.e. $(\pr{f}, \pr{g}) \circ (f, g) = (\pr{f} \circ f, \pr{g} \circ g)$. Moreover, associativity of the composition of morphisms in $\mathcal{C} \t \mathcal{D}$ follows from the fact that the composition of morphisms in the categories $\mathcal{C}$ and $\mathcal{D}$ are associative. 
\item[\textcolor{greentitle}{•}] The identity of $\mathcal{C} \t \mathcal{D}$ is the pair $1_{(A, B)} = (1_A, 1_B)$ of identities of the categories $\mathcal{C}$ and $\mathcal{D}$ respectively. 
\end{enumerate} 
\end{enumerate}
\end{exo}
\ \\
\begin{exo}{Recall the definition of a cochain complex of vector spaces from the lecture. Show that $cCh(Vect)$ and $gVect$ are categories.} Subsequently, prove that $H : cCh(Vect) \r gVect$ is a functor, called the \tr{cohomology functor}. 
\ \\ 
\Solution
\ \\ (The solution is not complete.)It is straightforward to show that $gVect$ is a category : Let $K$ be a field. The objects of $gVect$ are $K$-vector spaces $V$ equipped with a direct sum decomposition $V = \bigoplus\limits_{k \in \Z} V_k$. 
\ \\ Let $U, V \in Ob(gVect)$. Morphisms of $\Z$-graded vector spaces are $K$-linear maps $f: U \r V$ of degree $0$, i.e. $f(U_i) \subseteq V_i$ for all $i \in \Z$. For every $U, V$ and $W \in Ob(gVect)$, the composition of morphisms $f: U \r V$ and $g : V \r W$ is defined as $g \circ f : U \r W$. The identity of $gVect$ is given by the morphism $id_V : V \r V$.
\end{exo}
\begin{exo}{Verify that the map $T : Manifold \r VectBd$ sending a smooth manifold $M$ to its tangent bundle $TM$ and a smooth map $f: M \r N$ to its derivative $Tf : TM \r TN$ is a covariant functor from the category of smooth manifolds to the category of vector bundles. }
\Solution
\end{exo}
\begin{exo}{Show that functors preserve isomorphisms.}
\blindtext[20]
\Solution
\end{exo}
\end{document}

enter image description here

|improve this answer|||||
  • Thank you very much for helping me, although my code is a bit chaotic. I think you solved my problems. I still have a little question : The document now indicates a black box instead of my original picture. How can I change this again ? – Crystal Mar 7 '18 at 19:43
  • Remove the demo option from the documentclass -- that was one possibility to make your document compilable – user31729 Mar 7 '18 at 19:45

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.