Like this?
\documentclass{article}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tcolorbox}
%\usepackage{tabularx}
\usepackage{array}
\usepackage{colortbl}
\tcbuselibrary{skins}
%table
%\newcolumntype{Y}{>{\centering\arraybackslash}X}
\tcbset
{
tab2/.style=
{
enhanced,
fonttitle=\bfseries,
fontupper=\normalsize\sffamily,
colback=white!10!white,
colframe=red!50!black,
colbacktitle=Salmon!40!white,
coltitle=black,center title
}
}
\newtcolorbox{mytable}[3][]
{
tab2,
tabular*={\renewcommand{\arraystretch}{1.7}}{#2},
title=Table \ref{#3},
%hbox,
before={\begin{table}[htb]\refstepcounter{table}\label{#3}},
after={\end{table}},
#1
}
\makeatletter
\tcbset{
tabular*/.style 2 args={%
boxsep=0pt,top=0pt,bottom=0pt,leftupper=0pt,rightupper=0pt,
toptitle=1mm,bottomtitle=1mm,boxrule=0.5mm,hbox,
before upper={\arrayrulecolor{tcbcol@frame}\def\arraystretch{1.1}#1%
\tcb@hack@currenvir\tabular{#2}},
after upper=\endtabular\arrayrulecolor{black}},
}
\makeatother
\begin{document}
\begin{mytable}{c|c}{kk}
group & one \\\hline
red & 1000.00 \\\hline
green & 2000.00 \\\hline
blue & 3000.00 \\\hline
sum & 6000.00
\end{mytable}
\end{document}
I have defined a tabular
similar to tabularx
:
\makeatletter
\tcbset{
tabular*/.style 2 args={%
boxsep=0pt,top=0pt,bottom=0pt,leftupper=0pt,rightupper=0pt,
toptitle=1mm,bottomtitle=1mm,boxrule=0.5mm,hbox,
before upper={\arrayrulecolor{tcbcol@frame}\def\arraystretch{1.1}#1%
\tcb@hack@currenvir\tabular{#2}},
after upper=\endtabular\arrayrulecolor{black}},
}
\makeatother
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}
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}
Best Answer
With
minimum for equal height group
, a lower minimal height can be given to an equal height group. Inside a raster, the name of the current equal height group is generated automatically or can be set byraster equal height group
.In my proposed solution, I use
\tcb@ehgid
, the internal name of the current equal height group. Theminimum for equal height group
is called with this name and the width of the side text plus some additional space:This gives:
Note that this tweaked
marktext
will raise an error, if no equal height group is set.