I have a tcolorbox
with the following settings:
\tcbset{
noparskip,
colback=yellow!10,
colframe=yellow,
coltext=black,
coltitle=white,
boxrule=0.3mm,
fonttitle=\bfseries,
}
How can I add this tcolorbox
at a node
and give it a specific width and height. In other words, be able to do something like (or whichever syntax is simple):
\node [tcolorbox, title=foo, text width=Xmm, minimum height=Ymm] at (x,y) {blah blah}
A minimal example is as follows (note that the block with tikzpicture
might not run… it's an example of what I want to do. The rest will run).
\documentclass{beamer}
\usepackage{tikz,tcolorbox}
\tcbset{
noparskip,
colback=yellow!10,
colframe=yellow,
coltext=black,
coltitle=white,
boxrule=0.3mm,
fonttitle=\bfseries,
}
\begin{document}
\begin{frame}{}
%Normal tcolorbox
\begin{tcolorbox}
Lorem ipsum
\end{tcolorbox}
%Desired functionality
\begin{tikzpicture}[remember picture, overlay]
\node [tcolorbox, title=foo, text width=Xmm, minimum height=Ymm] at (x,y) {dolor sit amet}
\end{tikzpicture}
\end{frame}
\end{document}
Best Answer
Maybe your answer is fine, but the question shows the subtlety of features of TikZ. As you had the command
minimum height=Ymm
to set this feature, a command such asminimum width=Xmm
is also useful and preferable totext width
in setting the dimensions of a shape. From my experience, usingtext width=Zmm
can override the minimum width command.I've found that it can be useful to set up a node and put the text there so you can use
text width
to control the line breaking, and then put the shape with the appropriateminimum height
/width
commands (possibly defined at\begin{scope}[options]
) at the same node so that you can ensure uniformity of your shapes, rather than having the size of the text dictate them.Here's something from what I'm working on currently: