这是一个 MWE。
\usepackage{tcolorbox}%
\tcbuselibrary{skins,raster,breakable,}
\begin{tcolorbox}%
[%
boxrule=2mm,%
colback=lightcyan,%
colframe=red,%
title=TITLE,%
]%
\begin{tcbraster}%
[%Begin description raster
raster columns=1,%
raster force size=false,%
%Affects all tcboxes
raster before skip=0mm,% 240 Does not seem to work.
raster row skip=0mm,% 240
raster after skip=0mm,% 240 Does not seem to work.
raster left skip=-2mm,% 240
raster right skip=-2mm,% 240
]%End description raster
\begin{tcolorbox}% Box 1
[%Begin description Box 1
enhanced,show bounding box,%comment to prevent the bndbox from showing
unbreakable,%
colback= white,%
colframe= blue,%
boxrule=0.2mm,
arc=0mm,
sidebyside,%
lower separated=true,
sidebyside gap=3mm,%
sidebyside align=top seam,%
width=(\linewidth),%.
lefthand width=75mm,%107
% righthand width=60mm,%107
left skip =-5mm,%
right skip =-9mm,%
left=0mm,%
right=0mm,%
top=0mm,%
bottom=0mm,%
]%End description Box 1
Text 1 left Text 1 left Text 1 left Text 1 left Text 1 left Text 1 left Text 1 left
\tcblower
Text 1 right Text 1 right Text 1 right Text 1 right Text 1 right
\end{tcolorbox}%Box 1
%%
\begin{tcolorbox}% Box 2
[%Begin description Box 2
enhanced,show bounding box,%comment to prevent the bndbox from showing
unbreakable,%
colback= white,%
colframe= blue,%
boxrule=0.2mm,
arc=0mm,
sidebyside,%
lower separated=true,
sidebyside gap=3mm,%
sidebyside align=top seam,%
width=(\linewidth),%
% lefthand width=40mm,%107
righthand width=80mm,%107
left skip =-5mm, %.
right skip =-9mm, %.
left=0mm,%
right=0mm,%
top=0mm,%
bottom=0mm,%
]%End description Box 5
Text 2 left Text 2 left Text 2 left Text 2 left Text 2 left
\tcblower
Text 2 right Text 2 right Text 2 right Text 2 right Text 2 right Text 2 right
\end{tcolorbox}%Box 2
\end{tcbraster}%End Raster
\end{tcolorbox}
一般来说,命令往往不是独立的,但在这里我无法确定是什么阻止了 TITLE 与第一个框之间的空间以及第二个框与主框底部之间的空间为 0。其他的raster skip
,包括raster row skip
按预期工作:
(注:注释中的数字是文档中的页码。可以通过注释相应的行来使边界框不显示。)
答案1
基本上,对光栅内部框所做的操作必须对外部框执行:top=0pt
等等,此外还nobeforeafter
必须激活内部框的选项以消除任何垂直间距。
但是,应该更好地组织框设置,即使用样式或特殊\newtcolorbox
定义!
\documentclass{article}
\usepackage[x11names,dvipsnames,svgnames]{xcolor}
\usepackage{tcolorbox}%
\tcbuselibrary{skins,raster,breakable,}
\begin{document}
\begin{tcolorbox}%
[%
boxrule=2mm,%
colback=cyan,%
colframe=red,%
title=TITLE,%
top=0pt,
bottom=0pt,
boxsep=0pt,
]%
\begin{tcbraster}%
[%Begin description raster
raster columns=1,%
raster force size=false,%
%Affects all tcboxes
raster before skip=0mm,% 240 Does not seem to work.
raster row skip=0mm,% 240
raster after skip=0mm,% 240 Does not seem to work.
raster left skip=-2mm,% 240
raster right skip=-2mm,% 240
]%End description raster
\begin{tcolorbox}% Box 1
[%Begin description Box 1
enhanced,show bounding box,%comment to prevent the bndbox from showing
unbreakable,%
colback= white,%
colframe= blue,%
boxrule=0.2mm,
arc=0mm,
sidebyside,%
nobeforeafter,
lower separated=true,
sidebyside gap=3mm,%
sidebyside align=top seam,%
width=(\linewidth),%.
lefthand width=75mm,%107
% righthand width=60mm,%107
left skip =-4mm,
right skip =-8mm,%
left=0mm,%
right=0mm,%
top=0mm,%
bottom=0mm%
]%End description Box 1
Text 1 left Text 1 left Text 1 left Text 1 left Text 1 left Text 1 left Text 1 left
\tcblower
Text 1 right Text 1 right Text 1 right Text 1 right Text 1 right
\end{tcolorbox}%Box 1
%%
\begin{tcolorbox}% Box 2
[%Begin description Box 2
enhanced,show bounding box,%comment to prevent the bndbox from showing
unbreakable,%
colback= white,%
colframe= blue,%
boxrule=0.2mm,
arc=0mm,
sidebyside,%
nobeforeafter,
lower separated=true,
sidebyside gap=3mm,%
sidebyside align=top seam,%
width=(\linewidth),%
% lefthand width=40mm,%107
righthand width=80mm,%107
left skip =-4mm, %.
right skip =-8mm, %.
left=0mm,%
right=0mm,%
top=0mm,%
bottom=0mm,%
]%End description Box 5
Text 2 left Text 2 left Text 2 left Text 2 left Text 2 left
\tcblower
Text 2 right Text 2 right Text 2 right Text 2 right Text 2 right Text 2 right
\end{tcolorbox}%Box 2
\end{tcbraster}%End Raster
\end{tcolorbox}
\end{document}
我认为更好的风格是:
\documentclass{article}
\usepackage[x11names,dvipsnames,svgnames]{xcolor}
\usepackage{tcolorbox}%
\tcbuselibrary{skins,raster,breakable,}
\begin{document}
\makeatletter
\newlength{\leftshift}
\newlength{\rightshift}
\newcommand{\determineshifts}{%
\global\leftshift=-\kvtcb@leftupper
\global\rightshift=-8mm
}
\tcbset{%
boxcommonstyle/.style={%
enhanced,show bounding box,%comment to prevent the bndbox from showing
unbreakable,%
colback= white,%
colframe= blue,%
boxrule=0.2mm,
arc=0mm,
sidebyside,%
nobeforeafter,
lower separated=true,
sidebyside gap=3mm,%
sidebyside align=top seam,%
width=(\linewidth),%
left skip=\leftshift,
right skip=\rightshift,%
left=0mm,%
right=0mm,%
top=0mm,%
bottom=0mm,%
},
boxstyle1/.style={%
boxcommonstyle,
lefthand width=75mm,%107
},
boxstyle2/.style={%
boxcommonstyle,
righthand width=80mm,%107
},
outerboxstyle/.style={%
boxrule=2mm,%
colback=cyan,%
colframe=red,%
title=TITLE,%
top=0pt,
outer arc=\kvtcb@bottom@rule@stand,
bottom=0pt,
boxsep=0pt
}
}
\newtcolorbox{topbox}[1][]{%
code={\determineshifts},
boxstyle1,
#1
}
\newtcolorbox{bottombox}[1][]{%
code={\determineshifts},
boxstyle2,
#1,
}
\makeatother
\begin{tcolorbox}[outerboxstyle]
\begin{tcbraster}%
[%Begin description raster
raster columns=1,%
raster force size=false,%
%Affects all tcboxes
raster before skip=0mm,% 240 Does not seem to work.
raster row skip=0mm,% 240
raster after skip=0mm,% 240 Does not seem to work.
raster left skip=-2mm,% 240
raster right skip=-2mm,% 240
]%End description raster
\begin{topbox}
Text 1 left Text 1 left Text 1 left Text 1 left Text 1 left Text 1 left Text 1 left
\tcblower
Text 1 right Text 1 right Text 1 right Text 1 right Text 1 right
\end{topbox}%
%%
\begin{bottombox}%
Text 2 left Text 2 left Text 2 left Text 2 left Text 2 left
\tcblower
Text 2 right Text 2 right Text 2 right Text 2 right Text 2 right Text 2 right
\end{bottombox}%
\end{tcbraster}%End Raster
\end{tcolorbox}
\end{document}