Sie sind auf Seite 1von 3

If one side of a side-by-side box should be adapted to the width of its content, this width has

to be computed beforehand. The following example uses a savebox \mysavebox to store the
picture to determine its width. A more convenient way to handle this task is to use the methods
from Section 6.2 on page 114.
% \tcbuselibrary{skins,xparse}
% \usepackage{lipsum}
% \newsavebox\mysavebox % preamble
\DeclareTotalTColorBox{\mysidebox}{ O{} +m +m }{
bicolor,colback=white,colbacklower=yellow!10,
fonttitle=\bfseries,center title,
sidebyside,
code={\sbox{\mysavebox}{#2}},
lefthand width=\wd\mysavebox,
drop lifted shadow,
#1
}
{\usebox{\mysavebox}\tcblower#3}
\mysidebox[title=The Triangle]{%
\begin{tikzpicture}
\path[fill=red!20,draw=red!50!black]
(0,0) node[below]{A} -- (3,1) node[right]{B}
-- (1,4) node[above]{C} -- cycle;
\end{tikzpicture}%
}{%
\lipsum[1]
}
The Triangle
C

B
A

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget,
consectetuer id, vulputate a, magna. Donec vehicula augue eu
neque. Pellentesque habitant morbi tristique senectus et netus et
malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra
metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent
eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur
auctor semper nulla. Donec varius orci eget risus. Duis nibh mi,
congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci
sit amet orci dignissim rutrum.

113

xparse Library

following macros and options need the


! onAll page
402.
N 2015-11-20

LIB

Advanced Settings from the

LIB

6.2

xparse library to be loaded, see Section 21

\tcbsidebyside[hoptionsi]{hleft-handed contenti}{hright-handed contenti}


Creates a colored box using more or less arbitrary hoptionsi for a tcolorbox P. 12 .
The /tcb/sidebyside P. 108 option is set to true and the hleft-handed contenti and
hright-handed contenti is filled into the box appropriately. The resulting box is unbreakable.
\tcbsidebyside is not only a shortcut for using a normal tcolorbox P. 12 with
/tcb/sidebyside P. 108 , but allows setting further options like /tcb/sidebyside
adapt P. 115 and /tcb/sidebyside switch P. 117 .
% \tcbuselibrary{skins,xparse}
% \usepackage{lipsum}
\tcbsidebyside[title=The Triangle,
sidebyside adapt=left,
bicolor,colback=white,colbacklower=yellow!10,
fonttitle=\bfseries,center title,drop lifted shadow,
]{%
\begin{tikzpicture}
\path[fill=red!20,draw=red!50!black]
(0,0) node[below]{A} -- (3,1) node[right]{B}
-- (1,4) node[above]{C} -- cycle;
\end{tikzpicture}%
}{%
\lipsum[1]
}
The Triangle
C

B
A

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.


Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae,
felis. Curabitur dictum gravida mauris. Nam arcu libero,
nonummy eget, consectetuer id, vulputate a, magna. Donec
vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla
et lectus vestibulum urna fringilla ultrices. Phasellus eu
tellus sit amet tortor gravida placerat. Integer sapien est,
iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem
vel leo ultrices bibendum. Aenean faucibus. Morbi dolor
nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus.
Duis nibh mi, congue eu, accumsan eleifend, sagittis quis,
diam. Duis eget orci sit amet orci dignissim rutrum.

114

N 2015-11-20

/tcb/sidebyside adapt=hside(s)i
(no default, initially none)
The option allows the left-handed and/or right-handed side to determine the dimensions of
the box. This option is only valid inside \tcbsidebyside P. 114 .
Feasible values for hside(s)i are:
none: no measurement of left-handed and right-handed side.
left: the actual width of the left-handed content is used to set /tcb/lefthand
width P. 111 .
right: the actual width of the right-handed content is used to set /tcb/righthand
width P. 111 .
both: the actual width of the left-handed and right-handed content is used
to set /tcb/lefthand width P. 111 , /tcb/righthand width P. 111 , and the overall
/tcb/width P. 34 .
% \tcbuselibrary{skins,xparse}
\tcbsidebyside[sidebyside adapt=left,
title=Very important table,
beamer,colframe=blue!50!black,colback=blue!10,
lower separated=false,sidebyside gap=5mm
]{%
\begin{tabular}{|l|c|r|}\hline
left & center & right\\\hline
A & B & C\\\hline
D & E & F\\\hline
\end{tabular}
}{%
This table contains the most important figures for
all future actions. You may notice that B follows A,
C follows B, and so on.
}
Very important table
left
A
D

center
B
E

right
C
F

This table contains the most important figures for all future actions. You may notice that B follows A, C follows B, and so
on.

% \tcbuselibrary{skins,xparse}
\tcbsidebyside[sidebyside adapt=right,
blanker,sidebyside gap=5mm
]{%
\lipsum[2]
}{%
\begin{tikzpicture}
\path[fill=yellow,draw=yellow!75!red] (0,0) circle (1cm);
\fill[red] (45:5mm) circle (1mm);
\fill[red] (135:5mm) circle (1mm);
\draw[line width=1mm,red] (215:5mm) arc (215:325:5mm);
\end{tikzpicture}
}
Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor
lorem non justo. Nam lacus libero, pretium at, lobortis vitae, ultricies et, tellus.
Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet magna, vitae
ornare odio metus a mi. Morbi ac orci et nisl hendrerit mollis. Suspendisse ut
massa. Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatibus et
magnis dis parturient montes, nascetur ridiculus mus. Aliquam tincidunt urna.
Nulla ullamcorper vestibulum turpis. Pellentesque cursus luctus mauris.

115

Das könnte Ihnen auch gefallen