3

I have

\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);
}

from which I can draw a symbol of a man at (x,y)=(0,2) with

\man(0,2);

but I also want some text just below the man.

I have tried

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

but it doesn't produce any text.

  • You should take a look at pic in TikZ. – Manuel Jun 10 '15 at 13:56
12

As Manuel suggested, you can draw the man with a pic and later on place text nodes around it.

\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}

enter image description here

You can find some other men or women in I am trying to draw this picture with latex and Custom "human" shape for tikz

Update: Man with circle

A circular node is drawn around the man. A node and not a circle has been used because this way all text can be placed making reference to any anchor point of this circular node.

\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}

enter image description here

  • Thank you. Can I also draw the circle around the man? – Jamgreen Jun 10 '15 at 22:42
  • @Jamgreen I've updated the answer with a circular node around the man. – Ignasi Jun 11 '15 at 7:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.