8

I am using the mdframed package to create these boxes:

\usepackage[framemethod=tikz]{mdframed}

% Shorthands \newcommand*\iffdef{\overset{\text{def}}{\iff}} \DeclarePairedDelimiter\abs{\lvert}{\rvert} \DeclarePairedDelimiter\norm{\lVert}{\rVert}

% https://www.google.de/design/spec/style/color.html#color-color-palette \definecolor{colorBackground}{HTML}{F5F5F5} % Grey 500 \definecolor{colorDefinition}{HTML}{4CAF50} % Green 500 \definecolor{colorNotiz}{HTML}{81D4FA} % Light Blue 200 \definecolor{colorWarnung}{HTML}{FF9800} % Orange 500 \definecolor{colorBeispiel}{HTML}{0288D1} % Light Blue 700 \definecolor{colorSatz}{HTML}{009688} % Teal 500

\mdfdefinestyle{box}{ topline=false, bottomline=false, rightline=false, linewidth=4pt, backgroundcolor=colorBackground, frametitlefont=\sffamily\bfseries\color{black}, splittopskip=.5cm, frametitlebelowskip=.3cm, }

% Definition \mdtheorem[ style=box, linecolor=colorDefinition, ]{Def}{Defintion}[section]

% Notiz \mdtheorem[ style=box, linecolor=colorNotiz, ]{Notiz}{Notiz}[section]

% Warnung \mdtheorem[ style=box, linecolor=colorWarnung, ]{Warnung}{Warnung}[section]

% Beispiel \mdtheorem[ style=box, linecolor=colorBeispiel, ]{Beispiel}{Beispiel}[section]

% Satz \mdtheorem[ style=box, linecolor=colorSatz, ]{Satz}{Satz}[section]

Result: A nice box

Problem

When I nest one box into another they have the same background color: Nested boxes

I want it so, that the inner box has a darker background color. And if there is a box in a box in a box it should have an even darker background color.

I tried to set the background color to something transparent, so the color would add up if the boxes are nested, but I didn't really find a way to do that.

Does anyone know how to get the inner boxes darker?

Edit

Code to build the boxes in the images:

\section{Eigenwerte}

\begin{Def} Ein Eigenvektor einer Abbildung ist in der linearen Algebra ein vom Nullvektor verschiedener Vektor, dessen Richtung durch die Abbildung nicht verändert wird. Ein Eigenvektor wird also nur skaliert und man bezeichnet den Skalierungsfaktor als Eigenwert der Abbildung. \end{Def}

\section{Rezepte} \begin{Def} Sei $\varphi : V \rightarrow W $ linear und $B,B'$ sind Basen von $V$ \begin{align} D_{B'}(\varphi) = S_{B',B} \cdot D_B(\varphi) \cdot S_{B,B'} = S_{B,B'}^{-1} \cdot D_B(\varphi) \cdot S_{B,B'} \end{align} \begin{Notiz} $D_{B'}$ steht für $D_{B', B'}$ \end{Notiz} \end{Def}

You can view the project here: https://www.sharelatex.com/project/5583d6ee0b6e7e8821079c47.

moonlight
  • 183
  • 2
    Your code has only preamble. Can you add content of MWE that I can repeat result which you show in question? – Zarko Jul 18 '15 at 20:30

1 Answers1

7

You could define the fill transparency. You have to switch of the background of the frame for this.

% arara: pdflatex

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{mathtools}

\usepackage[framemethod=tikz]{mdframed}
% As I am working with transparency here, you should define darker colors.
\definecolor{colorBackground}{HTML}{F5F5F5} % Grey 500
\definecolor{colorDefinition}{HTML}{4CAF50} % Green 500
\definecolor{colorNotiz}{HTML}{81D4FA}      % Light Blue 200

\mdfdefinestyle{box}{
    topline=false,
    bottomline=false,
    rightline=false,
    linewidth=4pt,
    backgroundcolor=none,
    apptotikzsetting={\tikzset{mdfbackground/.append style={fill=gray!45,fill opacity=.6}}},
    frametitlefont=\sffamily\bfseries\color{black},
    splittopskip=.5cm,
    frametitlebelowskip=.3cm,
}

% Definition
\mdtheorem[%
  style=box,
  linecolor=colorDefinition
]{Def}{Defintion}[section]

% Notiz
\mdtheorem[%
  style=box,
  linecolor=colorNotiz
]{Notiz}{Notiz}[section]

\begin{document}
\section{Eigenwerte}
\begin{Def}
  Ein Eigenvektor einer Abbildung ist in der linearen Algebra ein
  vom Nullvektor verschiedener Vektor, dessen Richtung durch die
  Abbildung nicht verändert wird. Ein Eigenvektor wird also nur
  skaliert und man bezeichnet den Skalierungsfaktor als Eigenwert
  der Abbildung.
\end{Def}
\section{Rezepte}
\begin{Def}
  Sei $\varphi : V \rightarrow W $ linear und $B,B'$ sind Basen von $V$
  \begin{align*}
  D_{B'}(\varphi) = S_{B',B} \cdot D_B(\varphi) \cdot S_{B,B'} = S_{B,B'}^{-1} \cdot D_B(\varphi) \cdot S_{B,B'}
  \end{align*}
  \begin{Notiz}
  $D_{B'}$ steht für $D_{B', B'}$
  \end{Notiz}
\end{Def}
\end{document}

enter image description here

LaRiFaRi
  • 43,807