Anordnungen verschachtelter tcolorbox.
Zur Info: es ist ein [Crosspost von matheplanet.de][1].
Ich würde gerne die inneren Boxen besser platzsparender anordnen.
Idealerweise links 3 Boxen und rechts 3 Boxen. Ich weiß, dass der Code jenseits jeder Optimalität ist, allerdings ist es mir zunächst wichtig, dass er funktioniert. In einem zweiten Schritt würde ich diesen dann zu optimieren versuchen.
\documentclass{article}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{varwidth}
\usepackage{array}
\usepackage{colortbl}
\usepackage{amsmath}
\usepackage{sfmath}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{shadings}
\usetikzlibrary{shapes.geometric, angles,quotes,babel,3d}
\usepackage[most]{tcolorbox}
\tcbuselibrary{skins,xparse}
\tcbuselibrary{breakable}
\tcbset{
innenboxstyle/.style={
% Horizontale Aufteilung ===========
%sidebyside adapt=right, % nein, sondern
% lefthand width=4cm, % entweder absolutes Maß
lefthand ratio=0.65, % oder Verhältnis festlegen
% Farben und Schrift ===========
%lower separated=false,% kein Effekt, da eh weg
bicolor,colback=gray!10, colbacklower=white,
fonttitle=\bfseries, sharpish corners, colframe=gray!20!black, colbacktitle=gray!40,coltitle=black,
scale=1.0, % besser die tikzpictures skalieren, statt die ganzen Boxen
% Alignment ===========
sidebyside align=top seam, % vermutlich gewünscht
left=0mm, % Sonst Probleme mit dem halign lower,
% der boxsep noch gibt einen zusätzlichen Defalult-Abstand
valign lower=center,
halign lower=center,
},
seitenboxstyle/.style={
sidebyside,
sidebyside align=top seam,
sidebyside gap=3mm,
sharpish corners,
lower separated=false,
colframe=gray!10!black,colback=white,fonttitle=\bfseries,
%height fill,
% grundsätzlich seiten-hoch % evtl. brauchbar
},
}
\begin{document}
\tcbset{colframe=gray!10!black,colback=white,fonttitle=\bfseries}
\begin{tcolorbox}[title=I. Körperberechnung,sharpish corners]
\tcbsidebyside[title=Quadratische Pyramide,
sidebyside adapt=right,
bicolor,colback=gray!10,colbacklower=white,
fonttitle=\bfseries,sharpish corners,colframe=gray!20!black,colbacktitle=gray!40,coltitle=black,scale=0.5
]{%
\subsubsection*{Mantel}
\begin{equation*}
M=x+y
\end{equation*}
\subsubsection*{Oberfläche}
\begin{equation*}
O=x+z
\end{equation*}
\subsubsection*{Volumen}
\begin{equation*}
V=\frac{1}{3}\cdot a^{2}\cdot h
\end{equation*}
}{%
\pgfmathsetmacro{\a}{3.5}%
\pgfmathsetmacro{\b}{3.5}%
\pgfmathsetmacro{\h}{4}%
\begin{tikzpicture}[scale=0.7,
font=\footnotesize,
z ={(0,0,-cos(45))},
]
\coordinate[] (A) at (0,0,0);
\coordinate[label=right:] (B) at (\a,0,0);
\coordinate[label=right:] (C) at (\a,0,\b);
\coordinate[label=below:] (D) at (0,0,\b);
\coordinate[label=below:] (MBC) at (\a,0,0.5*\b);
\coordinate[] (M) at (0.5*\a,0,0.5*\b);
\path[] (M) --+ (0,\h,0) coordinate[label=\textsf{S}] (S);
% Grundfläche
\fill[lightgray] (A) -- (B) -- (C) -- (D) --cycle;
\draw[] (A) -- (B) node[midway, below]{\textsf{a}} -- (C) node[pos=0.6, below]{};
\draw[densely dashed] (A) -- (D) -- (C);
% Höhe
\draw[] ($(M)!-5pt!(C)$) -- ($(M)!5pt!(C)$) ;
\draw[] ($(M)!-5pt!(B)$) -- ($(M)!5pt!(B)$) ;
\draw[] (M) -- (S) node[midway, right]{\textsf{h}};
\draw[] (S) -- (MBC) node[midway, right]{$\textsf{h}_{\textsf{a}}$};
% Mantellinien
\draw[densely dashed] (D) -- (S);
\foreach \P in {A,B,C}{ \draw[] (\P) -- (S); }
%\begin{scope}[-latex, shift={(0,\h-0.3,0)}]
%\foreach \P/\s/\Pos in {(1,0,0)/x/below, (0,1,0)/y/left, (0,0,2)/z/right}
%\draw[] (0,0,0) -- \P node[\Pos, pos=0.9,inner sep=2pt]{$\s$};
%\end{scope}
\end{tikzpicture}
}
\tcbsidebyside[title=Kugel,
sidebyside adapt=right,
bicolor,colback=gray!10,colbacklower=white,
fonttitle=\bfseries,sharpish corners,colframe=gray!20!black,colbacktitle=gray!40,coltitle=black,scale=0.5
]{%
\subsubsection*{Mantel}
\begin{equation*}
M=x+y
\end{equation*}
\subsubsection*{Oberfläche}
\begin{equation*}
O=x+z
\end{equation*}
\subsubsection*{Volumen}
\begin{equation*}
V=x^{3}
\end{equation*}
}
{%
\begin{tikzpicture}
\shade[ball color = gray!40, opacity = 0.4] (0,0) circle (1.5cm);
\draw (0,0) circle (1.5cm);
\draw (-1.5,0) arc (180:360:1.5 and 0.6);
\draw[dashed] (1.5,0) arc (0:180:1.5 and 0.6);
\fill[fill=black] (0,0) circle (1pt);
\draw[dashed] (0,0 ) -- node[above]{\textsf{r}} (1.5,0);
\end{tikzpicture}
}
\tcbsidebyside[title=Kegel,
sidebyside adapt=right,
bicolor,colback=gray!10,colbacklower=white,
fonttitle=\bfseries,sharpish corners,colframe=gray!20!black,colbacktitle=gray!40,coltitle=black,scale=0.5
]{%
\subsubsection*{Mantel}
\begin{equation*}
M=x+y
\end{equation*}
\subsubsection*{Oberfläche}
\begin{equation*}
O=x+z
\end{equation*}
\subsubsection*{Volumen}
\begin{equation*}
V=x^{3}
\end{equation*}
}{%
\pgfmathsetmacro{\a}{4}%
\pgfmathsetmacro{\b}{5}%
\pgfmathsetmacro{\h}{3}%
\begin{tikzpicture}
\fill[
top color=gray!50,
bottom color=gray!10,
shading=axis,
opacity=0.25
]
(0,0) circle (1.5cm and 0.5cm);
(1.5,0) -- (0,4) -- (-1.5,0) arc (180:360:1.5cm and 0.5cm);
\draw
(-1.5,0) arc (180:360:1.5cm and 0.5cm) -- (0,4) -- cycle;
\draw[dashed]
(-1.5,0) arc (180:0:1.5cm and 0.5cm);
\draw[dashed]
(1.5,0) -- node[below] {$r$} (0,0) -- node[left] {h} (0,4) ;
%\draw
%(0,8pt) -- ++(8pt,0) -- (8pt,0);
\end{tikzpicture}
}
\tcblower
\tcbsidebyside[title=Zylinder,
sidebyside adapt=right,
bicolor,colback=gray!10,colbacklower=white,
fonttitle=\bfseries,sharpish corners,colframe=gray!20!black,colbacktitle=gray!40,coltitle=black,scale=0.5
]{%
\subsubsection*{Mantel}
\begin{equation*}
M=x+y
\end{equation*}
\subsubsection*{Oberfläche}
\begin{equation*}
O=x+z
\end{equation*}
\subsubsection*{Volumen}
\begin{equation*}
V=x^{3}
\end{equation*}
}
{%
\begin{tikzpicture}
\fill[top color=gray!50!black,bottom color=gray!10,middle color=gray,shading=axis,opacity=0.25] (0,0) circle (1.5cm and 0.5cm);
(1.5,0) -- (1.5,4) arc (360:180:1.5cm and 0.5cm) -- (-1.5,0) arc (180:360:1.5cm and 0.5cm);
\fill[top color=gray!90!,bottom color=gray!2,middle color=gray!30,shading=axis,opacity=0.25] (0,4) circle (1.5cm and 0.5cm);
\draw (-1.5,4) -- (-1.5,0) arc (180:360:1.5cm and 0.5cm) -- (1.5,4) ++ (-1.5,0) circle (1.5cm and 0.5cm);
\draw[densely dashed] (-1.5,0) arc (180:0:1.5cm and 0.5cm);
\draw[dashed]
(1.5,0) -- node[below] {$r$} (0,0) -- node[left] {h} (0,4) ;
\end{tikzpicture}
}
\tcbsidebyside[title=Quader,
sidebyside adapt=right,
bicolor,colback=gray!10,colbacklower=white,
fonttitle=\bfseries,sharpish corners,colframe=gray!20!black,colbacktitle=gray!40,coltitle=black,scale=0.5
]{%
\subsubsection*{Mantel}
\begin{equation*}
M=x+y
\end{equation*}
\subsubsection*{Oberfläche}
\begin{equation*}
O=x+z
\end{equation*}
\subsubsection*{Volumen}
\begin{equation*}
V=x^{3}
\end{equation*}
}
{%
\begin{tikzpicture}[%
x={(1cm,0cm)},
y={(0cm,1cm)},
z={({0.5*cos(45)},{0.5*sin(45)})},
]
\def\a{2}
\def\b{3}
\def\c{4}
\coordinate (A) at (0,0,0);
\coordinate (B) at (\a,0,0) ;
\coordinate (C) at (\a,\b,0);
\coordinate (D) at (0,\b,0);
\coordinate (E) at (0,0,\c);
\coordinate (F) at (\a,0,\c);
\coordinate (G) at (\a,\b,\c);
\coordinate (H) at (0,\b,\c);
%Ecken
\node[left= 1pt of A]{};
\node[right= 1pt of B]{};
\node[right= 1pt of C]{};
\node[left= 1pt of D]{};
\node[left= 1pt of E]{};
\node[right= 1pt of F]{};
\node[right= 1pt of G]{};
\node[left= 1pt of H]{};
%Kanten
\draw[] (A)
-- (B) node[midway, below]{\small a}
-- (C) node[midway, right]{\small c}
-- (D)
-- (A) ;
\draw[] (B)
-- (F) node[midway, right]{\small b}
-- (G) -- (C);
\draw[] (G) -- (H) -- (D);
\draw[densely dashed] (A) -- (E) -- (F);
\draw[densely dashed] (E) -- (H);
\fill[top color=gray!50!black,bottom color=gray!10,middle color=gray,shading=axis,opacity=0.25](A)--(B)--(F)--(E);
\fill[top color=gray!50!black,bottom color=gray!10,middle color=gray,shading=axis,opacity=0.25](D)--(C)--(G)--(H);
\end{tikzpicture}
}
\tcbsidebyside[title=Allgemeine Prismen,
sidebyside adapt=right,
bicolor,colback=gray!10,colbacklower=white,
fonttitle=\bfseries,sharpish corners,colframe=gray!20!black,colbacktitle=gray!40,coltitle=black,scale=0.5
]{%
\subsubsection*{Mantel}
\begin{equation*}
M=x+y
\end{equation*}
\subsubsection*{Oberfläche}
\begin{equation*}
O=x+z
\end{equation*}
\subsubsection*{Volumen}
\begin{equation*}
V=x^{3}
\end{equation*}
}
{%
\tikzset{
xyz/.style={x={(-.385cm,-.385cm)},y={(1cm,0cm)},z={(0cm,1cm)}},
flaeche/.style={fill=gray!10,opacity=.5},
}
\begin{tikzpicture}[xyz]% z-Achse zeigt nach oben
% Koordinaten in zwei zur xy-Ebene parallelen Ebenen definieren
\foreach[count=\i] \z in {0,4}
\path
(0,1,\z)coordinate(A\i)
(0,4,\z)coordinate(B\i)
(-2,2,\z)coordinate(C\i)
(-2,1,\z)coordinate(D\i)
;
% Grund- und Deckfläche füllen, gegebenenfalls doppelt
\foreach \i in {1,2,2}
\path[flaeche](A\i)--(B\i)--(C\i)--(D\i)--cycle;
% Seitenfläche(n) füllen
% \foreach \i/\j in {A/B}
% \path[flaeche](\i1)--(\i2)--(\j2)--(\j1)--cycle;
% sichtbare Kanten zeichnen
\path[draw](A2)--(B2)--(C2)--(D2)--(A2)--(A1)--(B1)--(B2);
% verdeckte Kanten zeichnen
\path[draw,dashed](A1)--(D1)--(C1)--(B1) (C1)--(C2) (D1)--(D2);
\end{tikzpicture}
}
\end{tcolorbox}
%----------------------------------------------------------------------------------------------
%----------------------------------------------------------------------------------------------
%----------------------------------------------------------------------------------------------
\tcbset{colframe=gray!10!black,colback=white,fonttitle=\bfseries}
\begin{tcolorbox}[title=II. Flächenberechnung,sharpish corners]
\tcbsidebyside[title=Quadrat,
sidebyside adapt=right,
bicolor,colback=gray!10,colbacklower=white,
fonttitle=\bfseries,sharpish corners,colframe=gray!20!black,colbacktitle=gray!40,coltitle=black,scale=0.5
]{%
\subsubsection*{Flächeninhalt}
\begin{equation*}
M=x+y
\end{equation*}
\subsubsection*{Umfang}
\begin{equation*}
O=x+z
\end{equation*}
}{%
\begin{tikzpicture}[scale=0.5
]
\def\a{4}
\coordinate (A) at (0,0);
\coordinate (B) at (\a,0) ;
\coordinate (C) at (0,\a);
\coordinate (D) at (\a,\a);
\draw[very thick] (A) -- (B) -- (D) -- (C) -- cycle;
\path (A) -- node [midway,below] {a} (B);
\end{tikzpicture}
}
\tcbsidebyside[title=Rechteck,
sidebyside adapt=right,
bicolor,colback=gray!10,colbacklower=white,
fonttitle=\bfseries,sharpish corners,colframe=gray!20!black,colbacktitle=gray!40,coltitle=black,scale=0.5
]{%
\subsubsection*{Mantel}
\begin{equation*}
M=x+y
\end{equation*}
\subsubsection*{Oberfläche}
\begin{equation*}
O=x+z
\end{equation*}
\subsubsection*{Volumen}
\begin{equation*}
V=x^{3}
\end{equation*}
}
{%
\begin{tikzpicture}[scale=0.5,very thick
]
\def\a{5}
\def\b{2}
\coordinate (A) at (0,0);
\coordinate (B) at (\a,0) ;
\coordinate (C) at (0,\b);
\coordinate (D) at (\a,\b);
\draw[very thick] (A) -- (B) -- (D) -- (C) -- cycle;
\path (A) -- node [midway,below] {a} (B);
\path (B) -- node [midway,right] {b} (D);
\end{tikzpicture}
}
\tcbsidebyside[title=Trapez,
sidebyside adapt=right,
bicolor,colback=gray!10,colbacklower=white,
fonttitle=\bfseries,sharpish corners,colframe=gray!20!black,colbacktitle=gray!40,coltitle=black,scale=0.5
]{%
\subsubsection*{Mantel}
\begin{equation*}
M=x+y
\end{equation*}
\subsubsection*{Oberfläche}
\begin{equation*}
O=x+z
\end{equation*}
\subsubsection*{Volumen}
\begin{equation*}
V=x^{3}
\end{equation*}
}{%
\begin{tikzpicture}[my angle/.style={font=\small, draw, angle eccentricity=1.75, angle radius=3mm},very thick]
\node (a) [trapezium, trapezium angle=60, minimum width=50mm, draw, very thick, label=above:b, label=below:a, label=right:c, label=left:d] {};
\draw [densely dashed] (a.north west) coordinate (a nw) -- (a nw |- a.south) node [midway,right] {$h$} ;
% \draw (a nw |- a.south) ++(0,1.5mm) -| ++(-1.5mm,-1.5mm) (a ne |- a.south) +%+(0,1.5mm) -| ++(1.5mm,-1.5mm);
\coordinate (a blc) at (a.bottom left corner);
\coordinate (a brc) at (a.bottom right corner);
%\pic [my angle, "$\alpha$"] {angle=a1--a blc--a nw};
%\pic [my angle, "$\alpha$"] {angle=a ne--a brc--a1};
%\pic [my angle, "$\beta$"] {angle=a blc--a nw--a1};
%\pic [my angle, "$\beta$"] {angle=a2--a ne--a brc};
\end{tikzpicture}
}
\tcbsidebyside[title=Parallelogramm,
sidebyside adapt=right,
bicolor,colback=gray!10,colbacklower=white,
fonttitle=\bfseries,sharpish corners,colframe=gray!20!black,colbacktitle=gray!40,coltitle=black,scale=0.5
]{%
\subsubsection*{Mantel}
\begin{equation*}
M=x+y
\end{equation*}
\subsubsection*{Oberfläche}
\begin{equation*}
O=x+z
\end{equation*}
\subsubsection*{Volumen}
\begin{equation*}
V=x^{3}
\end{equation*}
}
{%
\begin{tikzpicture}[my angle/.style={font=\small, draw, angle eccentricity=1.75, angle radius=3mm}]
\node (a) [trapezium,trapezium left angle=60, trapezium right angle=120, minimum width=50mm, draw, very thick, label=below:a, label=left:b] {};
\draw [densely dashed, very thick] (a.north west) coordinate (a nw) -- (a nw |- a.south) node [midway,right] {$h$} ;
% \draw (a nw |- a.south) ++(0,1.5mm) -| ++(-1.5mm,-1.5mm) (a ne |- a.south) +%+(0,1.5mm) -| ++(1.5mm,-1.5mm);
\coordinate (a blc) at (a.bottom left corner);
\coordinate (a brc) at (a.bottom right corner);
%\pic [my angle, "$\alpha$"] {angle=a1--a blc--a nw};
%\pic [my angle, "$\alpha$"] {angle=a ne--a brc--a1};
%\pic [my angle, "$\beta$"] {angle=a blc--a nw--a1};
%\pic [my angle, "$\beta$"] {angle=a2--a ne--a brc};
\end{tikzpicture}
}
\tcbsidebyside[title=Rechtwinkliges Dreieck,
sidebyside adapt=right,
bicolor,colback=gray!10,colbacklower=white,
fonttitle=\bfseries,sharpish corners,colframe=gray!20!black,colbacktitle=gray!40,coltitle=black,scale=0.5
]{%
\subsubsection*{Mantel}
\begin{equation*}
M=x+y
\end{equation*}
\subsubsection*{Oberfläche}
\begin{equation*}
O=x+z
\end{equation*}
\subsubsection*{Volumen}
\begin{equation*}
V=x^{3}
\end{equation*}
}
{%
\begin{tikzpicture} [very thick]
\draw (-2,0)coordinate[](A)
--(2,0)coordinate[](B)
--(-2,2)coordinate[](C)
--cycle;
% rechte Winkel
\pic[draw,fill=gray!10,fill opacity=0.5,angle radius=4mm,"$\pmb{\cdot}$" opacity=1]
{angle=B--A--C};
% Streckenbezeichnungen
\path (A) -- node [midway,below] {b} (B);
\path (A) -- node [midway,left] {a} (C);
\path (B) -- node [midway,above] {c} (C);
\end{tikzpicture}
}
\tcbsidebyside[title=Kreis,
sidebyside adapt=right,
bicolor,colback=gray!10,colbacklower=white,
fonttitle=\bfseries,sharpish corners,colframe=gray!20!black,colbacktitle=gray!40,coltitle=black,scale=0.5
]{%
\subsubsection*{Mantel}
\begin{equation*}
M=x+y
\end{equation*}
\subsubsection*{Oberfläche}
\begin{equation*}
O=x+z
\end{equation*}
\subsubsection*{Volumen}
\begin{equation*}
V=x^{3}
\end{equation*}
}
{%
\begin{tikzpicture}
\def\a{2}
\def\r{1.8}
\coordinate (A) at (0,0);
\coordinate (B) at (\r,0) ;
\coordinate (C) at (0,\r) ;
\coordinate (D) at (0,-\r) ;
\filldraw[ fill=white, very thick](A) circle (\r);
\draw[color=black] (A) node {$\pmb{+}$};
%\draw[color=black] (A) node[below] {M};
\draw[color=black,dotted,very thick] (A)-- (B) node[midway,below]{r};
\draw[color=gray,very thick] (C)-- (D) node[midway,left,color=black]{d};
\end{tikzpicture}
}
\end{tcolorbox}
\end{document}
Zudem scheint es mir, dass die äußeren Boxen etwas sehr zentriert angeordnet sind, so dass die Ränder recht groß sind. Gibt es eine Möglichkeit, die Seitenränder besser auszunutzen? Eventuell mit dem `geometry` Paket?Paket?
[1]: https://matheplanet.de/matheplanet/nuke/html/viewtopic.php?rd2&topic=251089&start=0#p1836448