You can use the sidebyside align
key (possible values are top
, bottom
and, the default, center
):
\documentclass[]{article}
\usepackage[skins,listings,breakable,listingsutf8,theorems,hooks,fitting]{tcolorbox}%
\begin{document}
\begin{tcolorbox}[adjusted title= First Outer Box,sidebyside,sidebyside align=top]
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
\tcblower
Variable vertical space
\begin{tcolorbox}[adjusted title=First Box Right Side]
Inside 1st box
First Outer Box
\end{tcolorbox}
\begin{tcolorbox}[adjusted title=Second Box Right Side]
Inside 2nd box
First Outer Box
\end{tcolorbox}
\end{tcolorbox} % first outer box
\begin{tcolorbox}[adjusted title= Second Outer Box,sidebyside,sidebyside align=top]
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
Left side of Outer Box\\
\tcblower
Variable vertical space.
\begin{tcolorbox}[adjusted title=First Box Right Side]
Inside 1st box
Second Outer Box
\end{tcolorbox}
\begin{tcolorbox}[adjusted title=Second Box Right Side]
Inside 2nd box
Second Outer Box
\end{tcolorbox}
\end{tcolorbox} % first outer box
\end{document}
![enter image description here](https://i.stack.imgur.com/t33S8.png)
There is more than one question to answer here. I try to answer them step by step.
1. How to define an inner margin for a tcolorbox?
The margins are set by left
, right
, top
, bottom
. Additionally, boxsep
is added to all these values for the resulting margin.
E.g.
\begin{tcolorbox}[boxsep=1pt,left=2pt,right=2pt,top=0pt,bottom=0pt]...
gives a total of 3pt
for the left and right margin, and a total of 1pt
for the top and bottom margin.
2. Content clipping
If rounded corners are used, but there is no margin or a very small margin, the text content (e.g. a picture) can protrude over the rounded corners. This can be avoided by using the enhanced
and clip upper
options of the skins
library which clip the interior:
\documentclass[a0paper,portrait]{article}
\usepackage[skins]{tcolorbox}
\begin{document}
\title{Test}
\begin{tcolorbox}[
enhanced,clip upper,%<------------
colframe=gray,colback=white,boxrule=2pt,arc=10pt,
boxsep=0pt,left=0pt,right=0pt,top=0pt,bottom=0pt]
\includegraphics[width=\linewidth]{example-image}
\end{tcolorbox}
\end{document}
![enter image description here](https://i.stack.imgur.com/yUHh8.png)
3. Font dependend units
A tcolorbox
is drawn inside a pgfpicture
or a tikzpicture
environment. Inside such an environment, a nullfont is used. If font dependend units like arc=.3em
are given, the actual sizing depends on where this setting is used exactly inside the internal implementation. If it is used (and expanded) before the actual tikzpicture
, it will have the intended size, but if it is used very lately in the drawing process, it may become zero.
Using
\begin{tcolorbox}[arc=0.3em]
\end{tcolorbox}
gives an unlucky combination of this effect. The outer arc
is computed automatically before the graphical environment is started. It gets the intended (expanded) size. The inner arc (i.e. arc
) stays at 0.3em
and becomes 0pt
inside the graphical environment.
So, currently, one should use fixed units like 3pt
or 3mm
to avoid such effects. But, for the next tcolorbox
version (3.36
or higher), I will implement a sanitize procedure which freezes font depended units before entering the graphical environment.
Best Answer
You can adjust
lefthand width=1.5em,
and usesidebyside gap=2pt,
to getI don't think I understand the bonus question properly. It means probably this:
If the upper part has only one letter like
R
, then the following is also possible:Adjust
left=3em,
,line width=6em-4pt
(6em=2 times the left margin and 4pt = 2 times the right margin),inner ysep=5pt, minimum width=3em
(minimum width
=left
).