1

I have some unbreakable variable height sidebyside tcolorboxes.

At the bottom of those boxes I want to have on the left side a line, and on the right side a "please seperate here" text on the same level as the line.

I have no fixed height, so I cannot set this attribute (?).

\documentclass[notitlepage]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}

\begin{document}

\begin{tcolorbox}[sidebyside,sidebyside align=top]
on left: \lipsum[1]
\vfill
\mbox{}{ \hrule}
\tcblower
text
\vfill
please separate here
\end{tcolorbox}

\begin{tcolorbox}[sidebyside,sidebyside align=top]
text
\vfill
\mbox{}{ \hrule}
\tcblower
on right:\lipsum[2]
\vfill
please separate here
\end{tcolorbox}

\end{document}

1 Answer 1

3

The upper and lower contents of a side-by-side tcolorbox is put in minipage environments respectively. Until the height of minipage is specified, a \vfill used in it will have no effect.

In the following example, the desired effect is emulated by overlay option. Some internal dimensions of tcolorbox and two (avoidable) magic numbers (10pt, 12pt) are used.

\documentclass[notitlepage]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}

\makeatletter
\tcbset{
  my sidebyside/.style={
    sidebyside, sidebyside align=top,
    enhanced, geometry nodes,
    bottom=2mm+14.4pt,
    overlay={
      \draw ([shift={(\kvtcb@leftupper+\kvtcb@boxsep, 10pt)}]frame.south west) 
         -- ([shift={(-.5*\kvtcb@sbs@gap, 10pt)}]frame.south);
      \node[shift={(.5*\kvtcb@sbs@gap, 10pt)}, inner sep=0pt, anchor=base west] at (frame.south) {please separate here};
    }
  }
}
\makeatother

\begin{document}

\begin{tcolorbox}[my sidebyside]
  \lipsum[2]
  \tcblower
  right-side is shorter
\end{tcolorbox}

\begin{tcolorbox}[my sidebyside]
  left-side is shorter
  \tcblower
  \lipsum[2]
\end{tcolorbox}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .