我有一张 tikz 图片。它在我的论文文件中运行顺利。但是当我把它放到框架中时,它出错了,请帮帮我。
这是我的代码:
\documentclass{beamer}
\usepackage{graphicx}
\usepackage[labelsep=quad,indention=10pt]{subfig}
\usepackage{tikz}
\begin{document}
\frame{
\begin{figure}[ht]
\centering
\begin{tikzpicture}[
init/.style={
draw,
circle,
inner sep=2pt,
font=\Huge,
join = by -latex
},
squa/.style={
draw,
inner sep=2pt,
font=\Large,
join = by -latex
},
start chain=2,node distance=13mm
]
\node[on chain=2]
(x2) {$x_2$};
\node[on chain=2,join=by o-latex]
{$w_2$};
\node[on chain=2,init] (sigma)
{$\displaystyle\Sigma$};
\node[on chain=2,squa,label=above:{\parbox{2cm}{\centering Activate \\ function}}]
{$f$};
\node[on chain=2,label=above:Output,join=by -latex]
{$y$};
\begin{scope}[start chain=1]
\node[on chain=1] at (0,1.5cm)
(x1) {$x_1$};
\node[on chain=1,join=by o-latex]
(w1) {$w_1$};
\end{scope}
\begin{scope}[start chain=3]
\node[on chain=3] at (0,-1.5cm)
(x3) {$x_3$};
\node[on chain=3,label=below:Weights,join=by o-latex]
(w3) {$w_3$};
\end{scope}
\node[label=above:\parbox{2cm}{\centering Bias \\ $b$}] at (sigma|-w1) (b) {};
\draw[-latex] (w1) -- (sigma);
\draw[-latex] (w3) -- (sigma);
\draw[o-latex] (b) -- (sigma);
\draw[decorate,decoration={brace,mirror}] (x1.north west) -- node[left=10pt] {Inputs} (x3.south west);
\end{tikzpicture}
\end{figure}
}
\end{document}
答案1
您忘记加载适当的 TikZ 库。添加
\usetikzlibrary{chains,arrows,decorations.pathreplacing}
到序言部分,代码就可以编译了。
如果你想扩展tikzpicture
,你可以添加选项
transform shape,scale=<factor>,
对tikzpicture
环境的影响。例如,
\begin{tikzpicture}[
transform shape,scale=.5,
<other options>
]
<drawing commands>
\end{tikzpicture}
将产生以下结果: