latex

Changing the default colours and styles of equations using tcolorbox


I've been experimenting with the tcolorbox to create some LaTeX documents.

It is a wonderful package but I am struggling to see how to change the default colours around the displayed equation given in the Theorem example e.g., how do I change, or removed, the red bounding box around the equation. For example, how could I change it to green?

\newtcbtheorem[auto counter,number within=section]{theo}%
  {Theorem}{fonttitle=\bfseries\upshape, fontupper=\slshape,
     arc=0mm, colback=blue!5!white,colframe=blue!60!white}{theorem}

\begin{theo}{Summation of Numbers}{summation}
  For all natural number $n$ it holds:
  \begin{equation}
  \tcbhighmath{\sum\limits_{i=1}^n i = \frac{n(n+1)}{2}.}
  \end{equation}
\end{theo}

A screen shot of what is currently generated is shown below:

enter image description here

It would also be useful to be able to specify different colours etc., in different Theorems. That is, rather than re-defining the colours for all Theorems, is there a way to have, for example, the first theorem having a green bounding box, the next theorem having a black bounding box, and the next one no bounding box?


Solution

  • You can adjust the highlight math style:

    \documentclass{article}
    
    \usepackage[most]{tcolorbox}
    
    \newtcbtheorem[auto counter,number within=section]{theo}%
      {Theorem}{fonttitle=\bfseries\upshape, fontupper=\slshape,
         arc=0mm, colback=blue!5!white,colframe=blue!60!white,
           every box/.style={
             highlight math style={
               colback=green!10!white,
               colframe=green
             }
           }
         }{theorem}
         
    \newtcbtheorem[auto counter,number within=section]{proof}%
      {Proof}{fonttitle=\bfseries\upshape, fontupper=\slshape,
         arc=0mm, colback=blue!5!white,colframe=blue!60!white,
           every box/.style={
             highlight math style={
               colback=blue!10!white,
               colframe=blue
             }
           }
         }{proof}     
    
    \begin{document}
    
    \begin{theo}{Summation of Numbers}{summation}
      For all natural number $n$ it holds:
      \begin{equation}
      \tcbhighmath{\sum\limits_{i=1}^n i = \frac{n(n+1)}{2}.}
      \end{equation}
    \end{theo}
    
    \begin{proof}{Summation of Numbers}{summation}
      For all natural number $n$ it holds:
      \begin{equation}
      \tcbhighmath{\sum\limits_{i=1}^n i = \frac{n(n+1)}{2}.}
      \end{equation}
    \end{proof}
    
    \end{document}
    

    enter image description here