Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I use tcolorbox. How I can achieve box like draft bellow?

--------------------
|Lorem   |ipsum    |
|        |         |
--------------------
|Lorem ipsum dolor |
|                  | 
--------------------

When I combine two boxes, I have space between them.

enter image description here

\documentclass[]{article}
\usepackage{lipsum}
\usepackage[most]{tcolorbox} %kolor wokół sekcji
\usepackage{geometry}
\usepackage{tikz}
    \usetikzlibrary{shadows}
\usepackage{tcolorbox}
    \tcbuselibrary{skins}

\newtcolorbox{FirstBox}[2]{
    sidebyside,sidebyside align=top,
    skin=enhanced#2,
    boxsep=1mm,left=1mm,right=1mm,top=1mm,
    colback=black!5!white,
    colframe=black!75!white,
    title={Box {\bf #1}}
}

\newtcolorbox{SecondBox}[2]{
boxsep=1mm,left=1mm,right=1mm,top=0mm,
colback=black!5!white,
colframe=black!75!white,
skin=enhanced#2,
}

%--------------------------
\begin{document}
\begin{FirstBox}{ABC}{first}
Lorem ipsum dolor
\tcblower
Lorem ipsum dolor
\end{FirstBox}

\begin{SecondBox}{ABC}{last}
\lipsum[4]
\end{SecondBox}

\end{document}
share|improve this question

3 Answers 3

This is one example with tabularx:

\documentclass{article}
\usepackage{array,tabularx,lipsum}
\usepackage[table]{xcolor}
\usepackage[most]{tcolorbox}
\newtcolorbox{MyBox}[1][]{%
    enhanced,
    boxsep=0pt,
    fonttitle=\bfseries\large,
    fontupper=\normalsize\sffamily,
    colback=yellow!10!white,
    colframe=red!50!black,
    colbacktitle=red!30!white,
    coltitle=black,
    before title={\noindent},
    #1
}%

\begin{document}
  \begin{MyBox}[tabularx*={\arrayrulewidth0.5mm}{X|X},title=Box ABC]%
    Lorem ipsum dolor & Lorem ipsum dolor \\\hline
    \multicolumn{2}{p{0.96\linewidth}}{\lipsum*[4]}
\end{MyBox}
\end{document}

enter image description here

While there are possibilities for improvement, this should serve as a starting point.

share|improve this answer
    
This was my initial intention but I didn't know tabularx*, just tabularx which didn't worked. I learn something new every day. Thank you. –  Ignasi Apr 29 at 9:29

You can to play with before and after options trying to delete this white space but I think a better solution would be to build this construction inside a single tcolorbox.

The first part could be build with a tabular or two column environment.

But if you insist in a side by side tcolorbox you can insert a box inside another one.

\documentclass[]{article}
\usepackage{lipsum}
\usepackage[most]{tcolorbox} %kolor wokół sekcji
\usepackage{geometry}
\usepackage{tikz}
\usetikzlibrary{shadows}

\newtcolorbox{outerBox}[1]{
    breakable, enhanced,
    colback=black!5!white,
    colframe=black!75!white,
    title={Box {\bf #1}},
    top=0pt
}

\newtcolorbox{twocolBox}{
    sidebyside, sidebyside align=top,
    enhanced,
    arc=0pt,
    colback=black!5!white,
    colframe=black!75!white,
    boxsep=1mm,
    notitle,
    oversize,
    nobeforeafter,
    frame hidden,
}

%--------------------------
\begin{document}

\begin{outerBox}{ABC}
\begin{twocolBox}
Lorem ipsum dolor
\tcblower
Lorem ipsum dolor
\end{twocolBox}
\lipsum[4]
\end{outerBox}

\end{document}

enter image description here

share|improve this answer

As long as there are rounded box corners there will be a slight separation at the border between two boxes at the corners.

The tcolorbox environment introduces top and bottom parskip values, which can be omitted by setting nobeforeafter, however, this indents the box a little bit. This can be prevented by using `\noindent.

\documentclass[]{article}
\usepackage{lipsum}
\usepackage{tcolorbox} %kolor wokół sekcji
\usepackage{geometry}
\usepackage{tikz}
    \usetikzlibrary{shadows}
\usepackage{tcolorbox}
    \tcbuselibrary{skins}






\newtcolorbox{FirstBox}[2]{%
    sidebyside,sidebyside align=top,
    boxsep=1mm,left=1mm,right=1mm,top=1mm,
    bottomrule=0pt,
    colback=black!5!white,
    colframe=black!75!white,
    nobeforeafter,%
    title={Box {\textbf{#1}}},
    auto outer arc,
    arc=0mm
    skin=enhanced#2
}%

\newtcolorbox{SecondBox}[2]{
boxsep=1mm,left=1mm,right=1mm,top=1mm,
colback=black!5!white,%
colframe=black!75!white,
nobeforeafter,
toprule=0pt,
notitle,
arc=0pt,
auto outer arc,
    skin=enhanced#2
}%


\begin{document}

\noindent
\begin{FirstBox}{ABC}{first}
Lorem ipsum dolor
\tcblower
Lorem ipsum dolor

\end{FirstBox}
\begin{SecondBox}{ABC}{last}
\lipsum[4]
\end{SecondBox}


\end{document}

enter image description here

Edit Improved(???) version using one \newcommand, doing all in one:

\documentclass[]{article}
\usepackage{lipsum}
\usepackage{tcolorbox} %kolor wokół sekcji
\usepackage{geometry}
\usepackage{tikz}
    \usetikzlibrary{shadows}
\usepackage{tcolorbox}
    \tcbuselibrary{skins}



\newcommand*{\SuperBox}[6][]{%
\begin{tcolorbox}[colback=black!5!white,colframe=black!75!white,  skin=enhanced,#1,title=#2]
\begin{tcolorbox}[sidebyside,sidebyside align=top,notitle,boxrule=-1pt,left=0pt,top=0pt,titlerule=0pt,leftlower=0pt,nobeforeafter,bottomtitle=-10pt,notitle]
#4%
\tcblower%
#5%
\end{tcolorbox}
\begin{tcolorbox}[boxsep=0mm,left=1mm,right=1mm,%
nobeforeafter,%
boxrule=-1pt,%
notitle]%
#6%
\end{tcolorbox}%
\end{tcolorbox}%
}%




\begin{document}
% [opt arg]{box title}{unused skin}{left box content}{right box content}{lower box content}
\SuperBox{Box ABC}{First}{Lorem ipsum dolor left}{Lorem ipsum dolor right}{\lipsum[4]}


\SuperBox[colframe=red,colbacktitle=red,coltitle={yellow}]{Box ABC}{First}{Lorem ipsum dolor left}{Lorem ipsum dolor \textcolor{blue}{\textbf{right}}}{\lipsum[8]}



\end{document}

enter image description here

share|improve this answer
    
Why do you need a second inner box in SuperBox? Inner boxes are not breakable so I think it's better to leave second box text as outer box text written after first inner box as shown in my answer. –  Ignasi Apr 30 at 7:11
    
@Ignasi: I initially thought about a tabular approach, leaving two separate boxes, but I had not enough time, switched to my first (not really good) solution. The second solution is rather 'fun'. You are right: The inner box is not breakable, but that is a feature not explicitly demanded, is it? –  Christian Hupfer Apr 30 at 12:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.