Following with the answer for this question Create a color box? given by Gonzalo Medina I just made a few arrangements for a list of exercises the code is this
\documentclass{article}
\usepackage[most]{tcolorbox}
\tcbuselibrary{skins}
\usepackage{lipsum}
\newtcolorbox[auto counter,number within=section]{ejemplo}[1][]{
before=\bigskip\centering,
after=\bigskip,
breakable,
enhanced,
arc=15pt,
colframe=blue,
colback=white,
fonttitle=\sffamily\bfseries,
title=Ejem.~\thetcbcounter,
sharp corners,
rounded corners=northeast,
attach boxed title to top left,
boxed title style={
enhanced,
colframe=blue,
colback=cyan,
arc=5pt,
bottomrule=0pt,
rightrule=0pt,
sharp corners,
rounded corners=northeast,
},
interior style={},
frame style={
left color=blue,
right color=cyan,},
overlay unbroken and first={
\node[anchor=west,font=\sffamily,color=cyan]
at (title.east) {{\small #1}};}}
\begin{document}
\begin{ejemplo}[Title]
\lipsum[2]
\end{ejemplo}
\end{document}
getting something like this
But I need to add another argument in order to get some boxes with the \tcblower
with the sidebyside
option in other words write something like this with the code above
\begin{ejemplo}[sidebyside]{Title}
\lipsum[2]
\tcblower
\lipsum[2]
\end{ejemplo}
I've tried with
\newtcolorbox[auto counter,number within=section]{ejemplo}[2][]{
before=\bigskip\centering,
after=\bigskip,
breakable,
enhanced,
arc=15pt,
colframe=blue,
colback=white,
fonttitle=\sffamily\bfseries,
title=Ejem.~\thetcbcounter,
sharp corners,
rounded corners=northeast,
attach boxed title to top left,
boxed title style={
enhanced,
colframe=blue,
colback=cyan,
arc=5pt,
bottomrule=0pt,
rightrule=0pt,
sharp corners,
rounded corners=northeast,
},
interior style={},
frame style={
left color=blue,
right color=cyan,},
overlay unbroken and first={
\node[anchor=west,font=\sffamily,color=cyan]
at (title.east) {{\small #2}};},#1}
and with
\newtcolorbox[auto counter,number within=section]{ejemplo}[2][]{
before=\bigskip\centering,
after=\bigskip,
breakable,
enhanced,
arc=15pt,
colframe=blue,
colback=white,
fonttitle=\sffamily\bfseries,
before title=Ejem.~\thetcbcounter,
sharp corners,
rounded corners=northeast,
attach boxed title to top left,
boxed title style={
enhanced,
colframe=blue,
colback=cyan,
arc=5pt,
bottomrule=0pt,
rightrule=0pt,
sharp corners,
rounded corners=northeast,
},
interior style={},
frame style={
left color=blue,
right color=cyan,},
overlay unbroken and first={
\node[anchor=west,font=\sffamily,color=cyan]
at (title.east) {title #2};},#1}
But both are giving me errors how can I achieve that
Best Answer
sidebyside
andbreakable
are not compatible.Improved version
In this version the
xparse
package was used (through thexparse
library) to define the environment and a starred version of it. The unstarred version admits page breaks and the starred version usessidebyside
; they are used as follows:The result:
Using
there's now an optional argument after the title to pass eventual keys, as in
Initial version
I added
fill=none
toframe style
to prevent some undesired borders. Thanks to Thomas F. Sturm for suggesting this inhis comment
.