图像背后的背景颜色应为白色,覆盖整个框的高度。只有文本必须具有绿色背景颜色。是否可以在框内执行此操作,或者仅在另一个框中执行此操作以放置图像?
\documentclass{article}
\usepackage[skins,hooks,xparse,breakable]{tcolorbox}
\usepackage{xcolor}
\usepackage{chngcntr}
\usepackage{blindtext}
\usepackage{tikz}
\usepackage{graphicx}
\newcounter{examplecounter}
\counterwithin{examplecounter}{section}
\usetikzlibrary{calc}
\definecolor{headercolourgreen}{rgb}{0,0.7019,0.7019}
\usepackage[
typ=ab,
fach=,
lerngruppe=,
farbig
% nummer=2A,
% datumAnzeigen,
% namensfeldAnzeigen,
]{schule}
\tcbset{MyStyle/.style={
enhanced,
breakable,
arc=0pt,
boxrule=0pt,
colback=white,
before skip={2em}, % increase spacing before the env
}}
\DeclareTColorBox{new}{O{}}{
MyStyle,
overlay unbroken and first={
% draw box on the left
\node[fill=headercolourgreen!5,
font=\color{headercolourgreen}\sffamily\bfseries\large,
anchor=south west,
xshift=2mm
] (titlebox) at (frame.north west)
{Exercise \refstepcounter{examplecounter}\theexamplecounter};
\draw[draw=headercolourgreen, line width=2pt]
(titlebox.north west-|frame.north west)--+(0,-1.5);
},
}
\DeclareTColorBox{aufgabeAux}{O{}}{
MyStyle,
overlay unbroken and first={
% draw box on the left
\node[fill=headercolourgreen!5,
font=\color{headercolourgreen}\sffamily\bfseries\large,
anchor=south west,
xshift=2mm
] (titlebox) at (frame.north west)
{Aufgabe \refstepcounter{aufgabe}\theaufgabe\ #1};
\draw[draw=headercolourgreen, line width=2pt]
(titlebox.north west-|frame.north west)--+(0,-1.5);
},
}
\pgfkeys{MyAufgabe/.cd,
subtitle/.store in=\MyAufgabeSubtitle,
}
\renewenvironment{aufgabe}[1][]{%
\pgfkeys{MyAufgabe/.cd, subtitle={}, #1}%
\begin{aufgabeAux}[\MyAufgabeSubtitle]%
}{%
\end{aufgabeAux}%
}%
\newlength\myheight
\newlength\mydepth
\settototalheight\myheight{Xygp}
\settodepth\mydepth{Xygp}
\newcommand*\inlinegraphics[1]{%
\settototalheight\myheight{Xygp}%
\settodepth\mydepth{Xygp}%
\raisebox{-\mydepth}{\includegraphics[height=\myheight]{#1}}%
}
\newcommand{\dpcalc}{\textbf{\inlinegraphics{example-image-b}\space}}
\author{}
\title{}
\date{\today}
\begin{document}
\begin{aufgabe}[subtitle=This is a subtitle \dpcalc]
This is an example of using the new \verb|aufgabe| environment with a subtitle.
This should have the title appear as the \verb|new| environment.
\end{aufgabe}
\end{document}