节点上的 tcolorbox

节点上的 tcolorbox

我有一个tcolorbox具有以下设置:

\tcbset{
    noparskip,
    colback=yellow!10,
    colframe=yellow,
    coltext=black,
    coltitle=white,
    boxrule=0.3mm,
    fonttitle=\bfseries,
}

我怎样才能tcolorbox在 a 处添加它node并赋予它特定的宽度和高度。换句话说,可以执行类似操作(或任何简单的语法):

\node [tcolorbox, title=foo, text width=Xmm, minimum height=Ymm] at (x,y) {blah blah}

一个最小的例子如下(请注意,带有的块tikzpicture可能不会运行...这是我想要做的一个例子。其余的将会运行)。

\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}

答案1

也许您的答案很好,但问题显示了 TikZ 功能的微妙之处。由于您有minimum height=Ymm设置此功能的命令,因此诸如在设置形状尺寸时minimum width=Xmm也很有用且更可取的命令。根据我的经验,使用可以覆盖最小宽度命令。text widthtext width=Zmm

我发现设置一个节点并将文本放在那里很有用,这样您就可以使用它text width来控制换行,然后将具有适当minimum height/width命令(可能在 定义\begin{scope}[options])的形状放在同一个节点上,这样您就可以确保形状的统一性,而不是让文本的大小决定它们。

以下是我目前正在进行的工作:

\documentclass[a4paper]{article}
\usepackage{amssymb,amsmath,tikz,amsmath,amssymb}
\usetikzlibrary{fit,positioning,shapes}


\begin{document}

\begin{center}
\begin{tikzpicture}

  % Use the scope environment to set features of the shapes such as minimal dimensions, and text features 

\begin{scope}[font=\tiny, color=black, ultra thick, node distance=2.5cm,minimum height=15mm,minimum width=55mm]

% First set up the text to go at a particular node

\node[text width=35mm] (3term) at +(0.0cm,0.0cm) {$Y_{n+1}$ = $K_{n}Y_{n}$ = $(\kappa_{1} x + \kappa_{0}) Y_{n}$ \\ 3-term recurrence relation};
% then draw the desired shape at that node to go around the text. 

\node[ellipse,draw] at (3term) {};

%    a second text snippet in a shape

\node[rectangle, draw,right = of 3term]  (HMEqns) {Hirota--Miwa Equations};

%   a third example

\node[below = of 3term, text width = 48mm]  (LFEqns) {$\displaystyle [\Omega_{nr} - V_{r} ] [ \Omega_{nr} + V_{r} ] = a_{n}^{2} \Theta_{nr} \Theta_{n-1 \, r}$ \\ Laguerre--Freud Equations/ \\ discrete Painlev\'e Equations};

\node[rectangle, draw] at (LFEqns) {};


\end{scope}

\draw[] (3term) to (HMEqns) {};

\draw[] (3term) to (LFEqns) {};

\end{tikzpicture}
\end{center}

\end{document}

上述代码的 pdf 输出

相关内容