我尝试使用以下代码来管理三个颜色框,但无法正确排列。
\documentclass[border=10pt]{standalone}
\usepackage{enumitem}
\setlist[itemize]{leftmargin=*, itemsep = 0em}
\usepackage[none]{hyphenat}
\usepackage{tikz}
\usetikzlibrary{matrix, shapes, arrows, positioning}
\usepackage[most]{tcolorbox}
\begin{document}
\newtcolorbox{GreenBox}[2][]{%
enhanced,
colback = green!5!white,
colframe = green!75!black,
arc = 4mm,
outer arc = 1mm,
fonttitle = \Huge\slshape\textbf,
center title,
title = #2,
#1}
\newtcolorbox{BlueBox}[2][]{%
enhanced,
colback = blue!5!white,
colframe = blue!65!black,
arc = 4mm,
outer arc = 1mm,
fonttitle = \Large\slshape\textbf,
center title,
title = #2,
#1}
\begin{tcbraster}[raster columns=3, raster valign=center]
\begin{GreenBox}[width=10cm, remember as=box1, nobeforeafter]{Objectives 1}
\begin{tcbraster}[raster columns=1, raster valign=center]
\begin{BlueBox}[width=10cm, remember as=box14, nobeforeafter]{Objective 1.1}
Some text here.
\end{BlueBox}
\end{tcbraster}
\end{GreenBox}
\begin{GreenBox}[width=5cm, remember as=box2, nobeforeafter]{Objective 2}
Some text here.
\end{GreenBox}
\begin{GreenBox}[width=5cm, remember as=box3, nobeforeafter]{Objective 3}
Some text here
\end{GreenBox}
\end{tcbraster}
\end{document}
答案1
在这个解决方案中,您需要明确设置raster width
并在第二个栅格中使用,reset raster
以避免内部栅格继承栅格宽度。
平均能量损失
\documentclass[margin=10pt]{standalone}
\usepackage[most]{tcolorbox}
\newtcolorbox{GreenBox}[2][]{%
enhanced,
colback = green!5!white,
colframe = green!75!black,
arc = 4mm,
outer arc = 1mm,
fonttitle = \Huge\slshape\textbf,
center title,
title = #2,
#1}
\newtcolorbox{BlueBox}[2][]{%
enhanced,
colback = blue!5!white,
colframe = blue!65!black,
arc = 4mm,
outer arc = 1mm,
fonttitle = \Large\slshape\textbf,
center title,
title = #2,
#1}
\begin{document}
\begin{tcbraster}[raster width=18cm,raster columns=3, raster valign=center]
\begin{GreenBox}[width=10cm, remember as=box1, nobeforeafter]{Objectives 1}
\begin{tcbraster}[raster reset,raster columns=1, raster valign=center]
\begin{BlueBox}[width=10cm, remember as=box14, nobeforeafter]{Objective 1.1}
Some text here.
\end{BlueBox}
\end{tcbraster}
\end{GreenBox}
\begin{GreenBox}[width=5cm, remember as=box2, nobeforeafter]{Objective 2}
Some text here.
\end{GreenBox}
\begin{GreenBox}[width=5cm, remember as=box3, nobeforeafter]{Objective 3}
Some text here
\end{GreenBox}
\end{tcbraster}
\end{document}