1

For my theorems and section titles, I use i.e.

\usepackage{listofitem}
\setsepchar{,}
\readlist\mycolors{amaranth,blue,orange,purple}

\definecolor{amaranth}{HTML}{a82337}
\definecolor{orange}{HTML}{BF7F00}
\definecolor{blue}{HTML}{016FB9}
\definecolor{purple}{HTML}{603C96}

\usepackage[explicit]{titlesec}
\titleformat{\subsection}{
\normalfont\Large\bfseries}{}{0pt}{\colorbox{\mycolors[\thesection]!10{\thesubsection \ #1}}

to make my headings change color with each section (from this answer.

Now, I use the same specifications for my bclogo environments:

\usepackage[tikz]{bclogo}
\begin{bclogo}[logo = \bclampe, couleur=blue!10,arrondi=0.1, couleurBarre=blue!10,noborder=true,ombre=true]{Idee}
 Some text.
\end{bclogo}

Now, I want to define a new environment, which looks like this and changes its colors with each section like my section titles, so I don't have to write all the options every time I use this environment.

MWE:

\documentclass[a4paper,twoside,ngerman]{article}
\usepackage{amsmath,amsfonts,cancel,mathtools,framed,mathabx,array,amssymb}
\usepackage{enumitem} % einfacher Nummerierung verändern
\usepackage{tikz} % zeichnen
\usetikzlibrary{cd} % kommutierende Diagramme
\usepackage{listofitems} % für Farben für Kapitel
\usepackage[tikz]{bclogo} % Kästen für Errinerung etc.

\usepackage{babel} % neue Rechtschreibung, Worttrennung
\usepackage[utf8]{inputenc} % Inputencoding
\usepackage[T1]{fontenc} % Umlaute
\usepackage[bookmarks=true,colorlinks=true,linkcolor=black]{hyperref}

\usepackage[thmmarks,framed,thref,hyperref]{ntheorem} % [thmmarks] guarantees endmarks

%theorems
\usepackage{tcolorbox}
\tcbuselibrary{theorems}
\newtcbtheorem[number within=subsection]{thm}{Satz} 
    {{colback=\mycolors[\thesection]!5},
    {colframe=\mycolors[\thesection]!95!black},
    fonttitle=\scshape\bfseries,
    before skip=15pt plus 2pt,after skip=15pt plus 2pt}{th}

\setsepchar{,}
\readlist\mycolors{amaranth,blue,orange,purple}

\definecolor{amaranth}{HTML}{a82337}
\definecolor{orange}{HTML}{BF7F00}
\definecolor{blue}{HTML}{016FB9}
\definecolor{purple}{HTML}{603C96}

% formatting
\usepackage[explicit]{titlesec}

\titleformat{\section}
{\normalfont\LARGE\bfseries\raggedright}
{\llap{\colorbox{\mycolors[\thesection]}{\makebox[3em][r]    {\textcolor{white}{\thesection}}}\hspace{1em}}}
{0pt}
{#1}

\begin{document}
\section{first, red section}

\begin{bclogo}[logo = \bclampe, couleur=amaranth!10,arrondi=0.1, couleurBarre= amaranth!10,noborder=true,ombre=true]{Idee}
 Some text.
\end{bclogo}

\section{next, blue section}
\begin{bclogo}[logo = \bclampe, couleur=blue!10,arrondi=0.1, couleurBarre= blue!10,noborder=true,ombre=true]{Idee}
 Some text.
\end{bclogo}
\end{document}
2

Instead of using a list of colour names, I would simply include the section number in the colour name. Then you can use it like couleur=mycol\thesection!10 to mix the colours of the bclogo boxes

\documentclass[a4paper,twoside,ngerman]{article}
\usepackage{amsmath,amsfonts,cancel,mathtools,framed,mathabx,array,amssymb}
\usepackage{enumitem} % einfacher Nummerierung verändern
\usepackage{tikz} % zeichnen
\usetikzlibrary{cd} % kommutierende Diagramme
\usepackage{listofitems} % für Farben für Kapitel
\usepackage[tikz]{bclogo} % Kästen für Errinerung etc.

\usepackage{babel} % neue Rechtschreibung, Worttrennung
\usepackage[utf8]{inputenc} % Inputencoding
\usepackage[T1]{fontenc} % Umlaute

\usepackage[thmmarks,framed,thref,hyperref]{ntheorem} % [thmmarks] guarantees endmarks

%theorems
\usepackage{tcolorbox}
\tcbuselibrary{theorems}
\newtcbtheorem[number within=subsection]{thm}{Satz} 
    {{colback=mycol\number\value{section}!5},
    {colframe=mycol\number\value{section}!95!black},
    fonttitle=\scshape\bfseries,
    before skip=15pt plus 2pt,after skip=15pt plus 2pt}{th}

\definecolor{mycol1}{HTML}{a82337}
\definecolor{mycol2}{HTML}{016FB9}
\definecolor{mycol3}{HTML}{BF7F00}
\definecolor{mycol4}{HTML}{603C96}

% formatting
\usepackage[explicit]{titlesec}

\titleformat{\section}
{\normalfont\LARGE\bfseries\raggedright}
{\llap{\colorbox{mycol\number\value{section}}{\makebox[3em][r]    {\textcolor{white}{\number\value{section}}}}\hspace{1em}}}
{0pt}
{#1}

\usepackage{etoolbox}

\newenvironment{mybclogo}[1]{%
    \begin{bclogo}[logo = \bclampe, couleur=mycol\number\value{section}!10,arrondi=0.1, couleurBarre= mycol\number\value{section}!10,noborder=true,ombre=true]{#1}
}{
    \end{bclogo}
}

\usepackage[bookmarks=true,colorlinks=true,linkcolor=black]{hyperref}

\begin{document}
\section{first, red section}

\begin{mybclogo}{Idee}
 Some text.
\end{mybclogo}

\section{next, blue section}
\begin{mybclogo}{Idee}
 Some text.
\end{mybclogo}
\end{document}

enter image description here

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.