我正在使用 tikz。我有一个图形模型,我想在侧面添加方程式作为解释。就像
感谢您的帮助!
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fit,positioning}
\usetikzlibrary{ automata}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[auto]\label{modelcomplete}
\tikzstyle{main}=[circle, minimum size = 15mm, thick, draw =black!80, node distance = 16mm]
\tikzstyle{connect}=[-latex, thick]
\tikzstyle{box}=[rectangle, draw=black!100]
\node[main, accepting, fill = white!100] (theta) {$\theta$};
\node[main] (muA) [left=of theta,xshift = -14mm] { $\mu_A$};
\node[main] (muB) [right=of theta,xshift = 14mm]{ $\mu_B$};
\node[main] (dim1) [below left=of theta] {Dim1};
\node[main] (dim2) [below right=of theta] {Dim2};
\node[main] (choice) [above=of theta] {choice};
\node[main] (N) [above=of choice] {N};
\path (muA) edge [connect] (theta)
(muB) edge [connect] (theta)
(choice) edge [connect] (theta)
(theta) edge [connect] (dim1)
(N) edge [connect] (choice)
(theta) edge [connect] (dim2);
\node[rectangle, inner sep=4mm,draw=black!100, fit= (choice) (theta)(dim1) (dim2),label=below right:N] {};
\end{tikzpicture}
\end{figure}
\end{document}
答案1
您可以在另一个文本中写入任何您想要的内容node
,并将其放在前一个文本的周围。
举一个可能的例子:
代码如下:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fit,positioning}
\usetikzlibrary{ automata}
\usepackage{amsmath}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[auto]\label{modelcomplete}
\tikzstyle{main}=[circle, minimum size = 15mm, thick, draw =black!80, node distance = 16mm]
\tikzstyle{connect}=[-latex, thick]
\tikzstyle{box}=[rectangle, draw=black!100]
\node[main, accepting, fill = white!100] (theta) {$\theta$};
\node[main] (muA) [left=of theta,xshift = -14mm] { $\mu_A$};
\node[main] (muB) [right=of theta,xshift = 14mm]{ $\mu_B$};
\node[main] (dim1) [below left=of theta] {Dim1};
\node[main] (dim2) [below right=of theta] {Dim2};
\node[main] (choice) [above=of theta] {choice};
\node[main] (N) [above=of choice] {N};
\path (muA) edge [connect] (theta)
(muB) edge [connect] (theta)
(choice) edge [connect] (theta)
(theta) edge [connect] (dim1)
(N) edge [connect] (choice)
(theta) edge [connect] (dim2);
\node[rectangle, inner sep=4mm,draw=black!100, fit= (choice) (theta)(dim1) (dim2),label=below right:N] (box) {};
\node[text width=5cm, align=left, right=of box.north east ]{$\mu\sim\text{Gaussian}(0,0.001)$\\$\lambda_i\sim\text{Gamma}(0.001,0.001)$\\$\sigma_i\leftarrow 1/\sqrt{\lambda_i}$\\
$x_i\sim\text{Gaussian}(\mu,\lambda_i)$};
\end{tikzpicture}
\end{figure}
\end{document}