7

sidebyside option gives poor result...

without sidebyside, code works well.

\documentclass[10pt,xcolor={usenames,dvipsnames,svgnames}]{beamer}

\usepackage[most]{tcolorbox}
\definecolor{linen}{HTML}{FAF0E6}

\definecolor{sandybrown}{rgb}{0.96, 0.64, 0.38}


\begin{document}
\begin{frame}
\begin{tcolorbox}[title=Formulas,
%sidebyside,
enhanced,
colback=linen,
colframe=sandybrown,
coltext=DarkRed,
coltitle=white,
fonttitle=\small\bfseries,
fontupper=\noindent,
segmentation style={dashed, red},
segmentation code={
\path[color=red,draw]
(segmentation.west) -- (segmentation.east);}
]
Some Text \bfseries{Some text}
\begin{equation*}
a = b + c
\end{equation*}
\tcbline
\begin{equation*}
a = b + c
\end{equation*}
\tcbline
\begin{equation*}
a = b + c
\end{equation*}
%
\tcblower
Some Text \bfseries{Some text}
\begin{equation*}
a = b + c
\end{equation*}
\tcbline
\begin{equation*}
a = b + c
\end{equation*}
\tcbline
\begin{equation*}
a = b + c
\end{equation*}
\end{tcolorbox}
\end{frame}
\end{document}

WITHOUT sidebyside... OUTPUT

WITH sidebyside... enter image description here

0

2 Answers 2

6

In this case, why not use just a tabularx inside the tcolorbox?

\documentclass[10pt,xcolor={table, usenames, dvipsnames, svgnames}]{beamer}
\usepackage[T1]{fontenc}
\usepackage{array,tabularx}
\usepackage[most]{tcolorbox}

\definecolor{sandybrown}{rgb}{0.96,0.64,0.38}
\definecolor{linen}{HTML}{FAF0E6}

\begin{document}

\begin{frame}

\rowcolors{1}{linen}{linen!70!DarkRed}
\begin{tcolorbox}[enhanced, colback=linen, colframe=sandybrown,
    title=Formulas, coltitle=white, fonttitle=\small\bfseries,
    clip upper, fontupper=\sffamily,%
    coltext=DarkRed,
    tabularx*={\arrayrulecolor{DarkRed}}{>{\centering\arraybackslash}X|%
              >{\centering\arraybackslash}X}]

Some Text \bfseries{Some text} & 
Some Text \bfseries{Some text} \\\hline
$a= b+c$ & $a= b+c$\\\hline
$a= b+c$ & $a= b+c$\\\hline
$a= b+c$ & $a= b+c$
\end{tcolorbox}
\end{frame}
\end{document}

enter image description here

Update:

OP images show a left aligned text on first line. In my original answer I couldn't reproduce this behaviour due to a problem when a \multicolumn command is introduced in first cell of a tabularx tcolorbox. This problem is shown in tcolorbox, tabularx: first line with a multicolumn does not work in tcolorbox environment. Now, thank you to Thomas F. Sturm (tcolorbox author) there's a provisional solution for this problem.

\documentclass[10pt,xcolor={table, usenames, dvipsnames, svgnames}]{beamer}
\usepackage[T1]{fontenc}
\usepackage{array,tabularx}
\usepackage[most]{tcolorbox}

\definecolor{sandybrown}{rgb}{0.96,0.64,0.38}
\definecolor{linen}{HTML}{FAF0E6}

\makeatletter
\tcbset{%
    hackfortabularx/.code={%
        \def\tcb@saveupperbox{%
            \begin{tcb@savebox}{\tcb@upperbox}{\tcb@w@upper}
                \kvtcb@fontupper\kvtcb@halignupper\kvtcb@before@upper}}
    }
\makeatother

\begin{document}

\begin{frame}

\begin{tcolorbox}[enhanced, colback=linen, colframe=sandybrown,
    title=Formulas, coltitle=white, fonttitle=\small\bfseries,
    clip upper, hackfortabularx,
   fontupper=\sffamily, coltext=DarkRed,
   tabularx*={\rowcolors{1}{linen}{linen!70!DarkRed}\arrayrulecolor{DarkRed}}%
        {>{\centering\arraybackslash}X|>{\centering\arraybackslash}X}]

\multicolumn{1}{l|}{Some Text \bfseries{Some text}} & 
\multicolumn{1}{l}{Some Text \bfseries{Some text}} \\\hline
$a= b+c$ & $a= b+c$\\\hline
$a= b+c$ & $a= b+c$\\\hline
$a= b+c$ & $a= b+c$
\end{tcolorbox}
\end{frame}
\end{document}

enter image description here

2nd update:

The problem with multicolumn command on left column of top most rule has been solved in tcolorbox v4.20. There's no need for previous pacth. Seond figure can be obtained with:

\documentclass[10pt,xcolor={table, usenames, dvipsnames, svgnames}]{beamer}
\usepackage[T1]{fontenc}
\usepackage{array,tabularx}
\usepackage[most]{tcolorbox}

\definecolor{sandybrown}{rgb}{0.96,0.64,0.38}
\definecolor{linen}{HTML}{FAF0E6}

\begin{document}

\begin{frame}

\begin{tcolorbox}[enhanced, colback=linen, colframe=sandybrown,
    title=Formulas, coltitle=white, fonttitle=\small\bfseries,
    clip upper, 
   fontupper=\sffamily, coltext=DarkRed,
   tabularx*={\rowcolors{1}{linen}{linen!70!DarkRed}\arrayrulecolor{DarkRed}}%
        {>{\centering\arraybackslash}X|>{\centering\arraybackslash}X}]

\multicolumn{1}{l|}{Some Text \bfseries{Some text}} & 
\multicolumn{1}{l}{Some Text \bfseries{Some text}} \\\hline
$a= b+c$ & $a= b+c$\\\hline
$a= b+c$ & $a= b+c$\\\hline
$a= b+c$ & $a= b+c$
\end{tcolorbox}
\end{frame}
\end{document}
5

The problem arises because the sidebyside option appears to modify the segmentation node so that \tcblower can produce a vertical line between the two units instead of the usual horizontal one. Consequently, \tcbline does not work as expected, since it uses the same segmentation code which relies on the segmentation node.

I can't find any examples in the package documentation of using \tcbline with the sidebyside option, so it is not clear doing so is supported.

You can get a box reasonably close to your intended result with a solid, vertical line by setting your segmentation style to solid (red) and removing the segmentation code (Which is causing problems). Dashed horizontal lines are not present, however.

The changes

segmentation style={solid, red}
% segmentation code={
% \path[color=red,draw]
% (segmentation.west) -- (segmentation.east);}

produces

output

The only workaround I can see is to manually draw the segmentation lines using the overlay option (disabling the in-built ones with the segmentation hidden key). You can do this somewhat pragmatically using the frame node and the tikizlibrary calc library:

% \usetikzlibrary{calc} % Preamble
% Box options
[title=Formulas,
sidebyside,
enhanced,
colback=linen,
colframe=sandybrown,
coltext=DarkRed,
coltitle=white,
fonttitle=\small\bfseries,
fontupper=\noindent,
segmentation hidden, % Hide the inbuilt segmentation - we're drawing our own
overlay={
\coordinate (FL) at (frame.west);
\coordinate (FT) at (frame.north);
\coordinate (FR) at (frame.east);
\coordinate (FB) at (frame.south);
\coordinate (L1) at (frame.center);  % Center of frame is about right height
\coordinate (L2) at (0,1.1); % Second dashed line at height of 1.1
\def\borderthickness{2} % Offset due to borders of box
\def\titlethickness{15} % Offset due to box title
\draw [red,dashed] let  \p{FT}=(FT),\p{FB}=(FB) in (\x{FB},\y{FB}+\borderthickness) -- (\x{FT},\y{FT}-\titlethickness);
\draw [red,dashed] let  \p{FR}=(FR),\p{FL}=(FL),\p{L1}=(L1) in (\x{FL}+\borderthickness,\y{L1}) -- (\x{FR}-\borderthickness,\y{L1});
\draw [red,dashed] let  \p{FR}=(FR),\p{FL}=(FL),\p{L2}=(L2) in (\x{FL}+\borderthickness,\y{L2}) -- (\x{FR}-\borderthickness,\y{L2});
}
]

For use of let in \draw commands, see, for example, this answer. When constructing future boxes, you should hopefully only have to edit the coordinates L1 and L2 to get the height of the horizontal lines correct (note that only the y-component of these coordinates is used).

Output:

output2

You must log in to answer this question.

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