tikz 中图标下方的节点

tikz 中图标下方的节点

我有

\def\man#1;{%
    \begin{scope}[shift={#1}]
        \fill [rounded corners=1.5] (0,0.4) -- (0,0.8) -- (0.4,0.8) -- (0.4,0.4) --
            (0.325,0.4) -- (0.325,0.7) -- (0.3,0.7) -- (0.3,0) -- (0.225,0) --
            (0.225,0.4) -- (0.175,0.4) -- (0.175,0) -- (0.1,0) -- (0.1,0.7) --
            (0.075,0.7) -- (0.075,0.4) -- cycle;
        \fill (0.2,0.9) circle (0.1);
    \end{scope}}
\def\shadecircle(#1)(#2);{%
    \draw [thick,opacity=0.05] (#1) circle (#2);
}

从中我可以在(x,y)=(0,2)处画出一个人的符号

\man(0,2);

但我还想在男人下面写一些文字。

我努力了

\man(0,2) node [below] {my text};

但它没有产生任何文本。

答案1

正如 Manuel 所建议的,您可以man用绘制pic,然后在其周围放置文本节点。

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}

\tikzset{
    man/.pic={%
        \fill [rounded corners=1.5] (0,0.4) -- (0,0.8) -- (0.4,0.8) -- (0.4,0.4) --
            (0.325,0.4) -- (0.325,0.7) -- (0.3,0.7) -- (0.3,0) -- (0.225,0) --
            (0.225,0.4) -- (0.175,0.4) -- (0.175,0) -- (0.1,0) -- (0.1,0.7) --
            (0.075,0.7) -- (0.075,0.4) -- cycle;
        \fill (0.2,0.9) circle (0.1);
        \coordinate (-head) at (0.2,1);
        \coordinate (-foot) at (0.2,0);
    }
%\def\shadecircle(#1)(#2);{%
%    \draw [thick,opacity=0.05] (#1) circle (#2);
}

\begin{tikzpicture}
\pic[red] at (0,2) (myman) {man};
\node[below=1mm of myman-foot] {Some text};
\node[above=1mm of myman-head] {Some text};
\end{tikzpicture}
\end{document}

在此处输入图片描述

您可以找到其他内容,men或者women我正在尝试用乳胶画这幅画tikz 的自定义“人形”

更新:带圆圈的男人

在男人周围画了一个圆形节点。之所以使用 Anode而不是 a,是circle因为这样可以放置所有文本,并参考此圆形节点的任意锚点。

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}

\tikzset{
    man/.pic={%
        \node[circle, thick, draw, fill, fill opacity=0.3, minimum size=1.3cm, outer sep=0pt] at (0.2,0.5) (-circ) {};
        \fill [rounded corners=1.5] (0,0.4) -- (0,0.8) -- (0.4,0.8) -- (0.4,0.4) --
            (0.325,0.4) -- (0.325,0.7) -- (0.3,0.7) -- (0.3,0) -- (0.225,0) --
            (0.225,0.4) -- (0.175,0.4) -- (0.175,0) -- (0.1,0) -- (0.1,0.7) --
            (0.075,0.7) -- (0.075,0.4) -- cycle;
        \fill (0.2,0.9) circle (0.1);
        \coordinate (-head) at (0.2,1);
        \coordinate (-foot) at (0.2,0);
    }
}

\begin{tikzpicture}
\pic[red] at (0,2) (myman) {man};
\node[below=1mm of myman-foot] {Some text};
\node[above=1mm of myman-head] {Some text};

\pic[green] at (2,2) (greenman) {man};
\node[draw, above right=0pt of greenman-circ.60] {Some text};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容