[Tex/LaTex] tcolorbox: raster before/after skip do not seem to work

tcolorbox

Here is a 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}

In general, the commands tend not to be independent but here I have not been able to determine what is preventing the space between the TITLE and the first box and the space between the second box and the bottom of the main box from being 0. The other raster skips, including raster row skip work as they are supposed to:

png of MWE

(Notes: The numbers in the comments are the page numbers in the doc. The bounding boxes can be made not to show by commenting the corresponding lines.)

Best Answer

Basically what is done for the inner boxes in the raster has to be done for the outer box: top=0pt etc, and in addition the nobeforeafter option for the inner boxes must be activated to eliminate any vertical spacing.

However, there should be a better organization of the box settings, i.e. with a style or a special \newtcolorbox definition for this!

\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}

enter image description here

A better style, in my point of view:

\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}
Related Question