从更复杂的试验开始添加新形状,我得到了这个无法编译的最小示例。我使用 PGF 2.10
\documentclass[12pt]{article}
\usepackage{tikz}
\pgfdeclareshape{minex}{}
\begin{document}
\begin{tikzpicture}
\node[minex] {};
\end{tikzpicture}
\end{document}
收到的错误信息是:
ERROR: Package PGF Math Error: Unknown function `center' (in 'center').
TeX said:
See the PGF Math package documentation for explanation.
Type H <return> for immediate help.
...
l.7 \node[minex] {};
答案1
定义至少一个中心锚点,然后错误就会消失:
\pgfdeclareshape{minex}{\anchor{center}{\pgfpointorigin}}
答案2
添加一些定义(无论是否继承):
\documentclass[12pt]{article}
\usepackage{tikz}
\pgfdeclareshape{minex}{
\inheritsavedanchors[from=rectangle]
\inheritanchorborder[from=rectangle]
\inheritanchor[from=rectangle]{center}
\inheritanchor[from=rectangle]{north}
\inheritanchor[from=rectangle]{south}
\inheritanchor[from=rectangle]{west}
\inheritanchor[from=rectangle]{east}
\inheritanchor[from=rectangle]{north west}
\inheritanchor[from=rectangle]{south east}
\inheritanchor[from=rectangle]{south west}
\inheritanchor[from=rectangle]{north east}
\inheritanchor[from=rectangle]{center}
\inheritanchor[from=rectangle]{base}
\inheritanchor[from=rectangle]{base east}
\inheritanchor[from=rectangle]{base west}
\inheritanchor[from=rectangle]{mid}
\inheritanchor[from=rectangle]{mid east}
\inheritanchor[from=rectangle]{mid west}
%....
}
\begin{document}
\begin{tikzpicture}
\node[shape=minex] {};
\end{tikzpicture}
\end{document}