# Is there any alternative for tcolorbox in Context?

I am planning to move to Context, however, the fact that I'll miss some of LaTeX packages (especially tcolorbox) feels sad. That's why I asked such a question.

• Unfortunately, there is not. I am using ConTeXt for a while now and really miss that package. If I want to use boxes I have to write some Metapost… Apr 22 '19 at 17:29
• What specific feature from tcolorbox are you missing. Most of it is straightforward using framed and textbackground environments. Apr 22 '19 at 22:51
• @Aditya Breakable boxes and box shape customization by tikz since I am familiar only with tikz. Apr 23 '19 at 3:18
• @MuhammedHashim Actually, looking through the `tcolorbox` code, it seems that it could be made format-independent with moderate effort. Some stuff like `listings` support would have to stay LaTeX-only, but PGF/TikZ does that too. Apr 23 '19 at 7:33
• @MuhammedHashim: textbackground provides breakable boxes and both framed and textbackgrounds provide fancy backgrounds. What do you mean by shape customization? Can you give a specific example of what you are trying to achieve. Not everyone knows all the features of tcolorbox. Apr 23 '19 at 13:04

You can emulate `tcolorbox` sufficiently well with `framed`, `framedtext`, and the MetaFun overlay mechanism.

``````\startuseMPgraphic{mp:tcolorbox}
path p ; numeric w, h, o ;
w := OverlayWidth ; h := OverlayHeight ; o := BodyFontSize ;
p := ((0,0) -- (0,h+2o) -- (w,h+2o) -- (w,0) -- cycle) cornered (o) ;
fill p withcolor OverlayColor ;
draw p withcolor OverlayLineColor withpen pencircle scaled OverlayLineWidth ;
p := ((0,h) -- (0,h+2o) -- (w,h+2o) -- (w,h) -- cycle) cornered (o) ;
filldraw p -- cycle withcolor OverlayLineColor ;
draw textext.rt(\MPstring{tcolorbox}) shifted (o,h+o) withcolor white ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\defineoverlay[tcolorbox][\useMPgraphic{mp:tcolorbox}]

\define\setframetitle
{\setMPtext{tcolorbox}{\strut\framedparameter{title}}}

\defineframedtext
[tcolorbox]
[frame=off,
background=tcolorbox,
backgroundcolor=white,
framecolor=darkred,
rulethickness=2pt,
extras=\setframetitle]

\starttext

\starttcolorbox
[title={Knuth},
backgroundcolor=lightgray]

\samplefile{knuth}

\stoptcolorbox

\stoptext
``````

• Thank you, but is it possible to make breakable boxes like in `tcolorbox` is breakable boxes and being cutomized by tikz that I am familiar with (Maybe I should learn some of MetaFun for such a purpose). Apr 23 '19 at 3:22
• @MuhammedHashim Yes, you can also have breakable boxes with `textbackground`, see e.g. this answer: tex.stackexchange.com/a/377261. Customization with TikZ instead of MetaFun is not possible. ConTeXt is tightly coupled to MetaFun. Apr 23 '19 at 3:55
• @HenriMenke: It is possible to use customization for framed with TikZ instead of Metapost. See mailman.ntg.nl/pipermail/ntg-context/2012/069802.html It is just a matter of providing a few nice helper macros. Apr 23 '19 at 13:06