Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to know if there is a way to place tcolorboxes like this:

-------- --------
| box1 | |      |
-------- | box3 |  
-------- |      | 
| box2 | |      |
-------- --------

To do that I'm actually placing the boxes inside tikz nodes, but that seems like an overkill solution. Is there a tikz-free approach?

share|improve this question

2 Answers 2

up vote 15 down vote accepted

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}

enter image description here

share|improve this answer
    
Does this work with tcolorbox? –  Werner Jul 3 '13 at 14:14
    
Should work with tcolorbox; just remember to give the boxes a fixed width (and, maybe, height). –  Thomas F. Sturm Jul 3 '13 at 14:17
    
never heard of this package before, thanks. Anyway, is it possible to align the third box with the first, assuming that the third box height is not equal to the sum of the other two boxes? @Werner just tested, it works. –  Lep Jul 3 '13 at 14:17
    
@werner I revised solution to demonstrate with \tcbox –  Steven B. Segletes Jul 3 '13 at 14:22
1  
@Lep The stackengine package is new. I just wrote it in recent weeks. –  Steven B. Segletes Jul 3 '13 at 14:27

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.

share|improve this answer
    
The package xcoffin is a great interface to l3coffin. Unfortunately it is very unpopular yet. –  Marco Daniel Jul 3 '13 at 17:09
    
@MarcoDaniel Maybe because it is in the experimental branch? –  cgnieder Jul 6 '13 at 15:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.