Tikz 手册中有一个生成下图的示例: 我尝试在应用@Zarco 注释添加形状示例样式的定义后查看代码是否有效:
\documentclass[border=0.5cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.gates.ee.IEC}
\usetikzlibrary {circuits.ee.IEC}
\begin{document}
\begin{tikzpicture}
\tikzset{
shape example/.style= {color = black!30,
draw,
fill = yellow!30,
line width = .5cm,
inner xsep = 2.5cm,
inner ysep = 0.5cm}
}
\node[name=s,shape=var resistor IEC,shape example,minimum
width=7cm,minimum height=1cm] {};
\foreach \anchor/\placement in
{center/above, 30/above right,
north/above, south/below, east/left, west/right,
north east/above, south east/below, south west/below, north west/above,
input/left,output/right}
\draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{document}
但出现错误:!软件包 PGF 数学错误:未知函数“center”(在“center”中)。您知道如何让它工作吗?
答案1
太期待评论了...
使用从你的问题中复制的代码,我可以确认发生了一些错误(在我的情况下Unknown function
是正确的'(在'正确')。如果我从头开始构建你的MWE,并从Ti复制代码片段钾Z$PGF 手册,版本 3.1.9a:
\documentclass[border=0.5cm]{standalone}
\usepackage{tikz}
\usetikzlibrary {circuits.ee.IEC}
\tikzset{
shape example/.style = {color=black!30,
draw,
fill = yellow!30,
line width = .5cm,
inner xsep = 2.5cm,
inner ysep = 0.5cm}
}
\begin{document}
\begin{tikzpicture}
\node[name=s,shape=var resistor IEC, shape example,
minimum width=7cm, minimum height=1cm] {};
\foreach \anchor/\placement in {
center/above, 30/above,
north/above, south/below,
east/left, west/right,
north east/above, south east/below,
south west/below, north west/above,
input/left, output/right}
\draw[shift=(s.\anchor)]
plot[mark=x] coordinates{(0,0)} node[\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{document}
它编译得很好:没有任何错误,警告或坏框:
但结果与 manula 不同(背景缩小为一条线)。
看来,您的代码副本中可能隐藏了一些不可见的字符,这会导致错误。您可以将您的发现报告给软件包维护者。