Boxes Placement In Tcolorbox
Answer :
Obviously, you would use the \tcbox
macro version for your boxes, rather than the environment form. Calculation of the stackgap is shown automated in this MWE. (Note: this example works starting with V2.30 of tcolorbox).
\documentclass{article} \usepackage{stackengine} \usepackage{tcolorbox} \begin{document} \def\boxone{\tcbox[nobeforeafter]{This is a test}} \def\boxtwo{\tcbox[nobeforeafter]{Another test}} \def\boxthree{\tcbox[nobeforeafter,minipage,width=0.7in]{this is a very long box}} \stackon[\heightof{\boxthree}-\heightof{\boxone}-\heightof{\boxtwo}]% {\boxtwo}{\boxone}~\boxthree \end{document}
Taking a similar tack to Steven Segletes's answer but using the xcoffins
package, which allows us to pick points on the various boxes to line up:
\documentclass{article} \usepackage{tcolorbox} \usepackage{xcoffins} \NewCoffin{\CoffinA} \NewCoffin{\CoffinB} \NewCoffin{\CoffinC} \begin{document} % Set up content in three coffins \SetHorizontalCoffin{\CoffinA}{% \begin{tcolorbox}[width = 1 in] This is a \textbf{tcolorbox}.% \end{tcolorbox} }% \SetHorizontalCoffin{\CoffinB}{% \begin{tcolorbox}[width = 1 in] This is a \textbf{tcolorbox}.% \end{tcolorbox} }% \SetHorizontalCoffin{\CoffinC}{\rule{1 in}{2.5 in}}% % Join the first small coffin onto the big one at the top \JoinCoffins{\CoffinC}[t,l]{\CoffinA}[t,r](-0.1 in, 0 in)% % Join the second small coffin onto the big one at the bottom \JoinCoffins{\CoffinC}[b,\CoffinC-l]{\CoffinB}[b,r](-0.1 in, 0 in)% \TypesetCoffin{\CoffinC} \end{document}
Here, I've added a small gap between the coffins (it's negative as I've done everything relative to the large item, \CoffinC
.)
The 'coffin' system works by having 'handles' on the boxes it creates: we can address those by letters, e.g. t
for 'top', and also refer to points on coffins we've already combined. This allows relatively easy construction of complex box relationships.
Comments
Post a Comment