我经常使用 tcolorbox,现在使用 raster。我对目前的结果非常满意:
\documentclass{standalone}
\usepackage[most]{tcolorbox}
\usepackage[outline]{contour}
\begin{document}
\begin{tcolorbox}[enhanced,colback=gray!15,colframe=black!50, boxrule = 1pt, titlerule=1mm,
colbacktitle=blue!15, coltitle=black!75, center title, title = \contour{blue!30}{Main Title}]
\begin{tcbraster}[raster columns=2, sharp corners, raster equal height,
raster column skip= 0.5mm, nobeforeafter]
\begin{tcolorbox}[colback=blue!30, title = Sub Title , width=0.3\textwidth]
Column1
\end{tcolorbox}
\begin{tcolorbox}[height fill]
Column 2
\end{tcolorbox}
\end{tcbraster}
\end{tcolorbox}
\end{document}
(代码需编译两次)
另一件被忽视的事情是宽度-command 在提交的框中。浏览手册后,我也没有找到执行此操作的选项。还有其他选择吗?
答案1
减小宽度两个都列使用raster width=0.6\textwidth
。
要更改一列的宽度,请使用更多列(此示例中为 3 列),并tcolorbox
使用 扩展第二列以占据两列raster multicolumn=2
。
(或列数和的任意组合raster multicolumn
)
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage[outline]{contour}
\begin{document}
\begin{tcolorbox}[enhanced,colback=gray!15,colframe=black!50, boxrule = 1pt, titlerule=1mm,
colbacktitle=blue!15, coltitle=black!75, center title, title = \contour{blue!30}{Main Title}]
% two columns, same width
\begin{tcbraster}[raster columns=2, sharp corners, raster equal height,
raster column skip= 0.5mm, nobeforeafter, raster width=0.6\textwidth]
\begin{tcolorbox}[colback=blue!30, title = Sub Title ]
Column1
\end{tcolorbox}
\begin{tcolorbox}[height fill]
Column 2
\end{tcolorbox}
\end{tcbraster}
\end{tcolorbox}
\begin{tcolorbox}[enhanced,colback=gray!15,colframe=black!50, boxrule = 1pt, titlerule=1mm,
colbacktitle=blue!15, coltitle=black!75, center title, title = \contour{blue!30}{Main Title}]
% two columns column 1 = 1/3 column 2= 2/3
\begin{tcbraster}[raster columns=3, sharp corners, raster equal height,
raster column skip= 0.5mm, nobeforeafter]
\begin{tcolorbox}[colback=blue!30, title = Sub Title ,]
Column1
\end{tcolorbox}
\begin{tcolorbox}[height fill, raster multicolumn=2]
Column 2
\end{tcolorbox}
\end{tcbraster}
\end{tcolorbox}
\end{document}