How to make properly macro with the use of pic?

I'd like do make a picture that consists of few blocks. One of these blocks I called \elementsymbol (in MWE below) - it consists of an arrow surrounded by a circle.

  1. I have the problem with scaling of the picture - connection of the line to the circle center is lost while picture scale is not equal to 1.
  2. I don't know how to pass the label to my block in the form angle:text.


\documentclass{standalone} \usepackage{tikz}  % \makeatletter \newcommand{\gettikzxy}[3]{%   \[email protected]@[email protected]\[email protected]#1\relax   \edef#2{\the\[email protected]}%   \edef#3{\the\[email protected]}% } \makeatother  \pgfkeys{     /element settings/.is family,     /element settings,     default/.style={         name=nonameelement,         diameter=2ex,         x pos=0,         y pos=0,         label={}     },     name/.store in=\elementname,     diameter/.store in=\elementdiameter,     x pos/.store in=\elementxpos,     y pos/.store in=\elementypos,     label/.store in=\elementlabel } \tikzset{     pics/elementsym/.style args={origin #1:#2 d #3}{         foreground code={             \node (-housing) [draw,circle,minimum size=#3] at (#1,#2) {};             \draw [-stealth] ( -- +(45:0.43*#3);    % arrow part             \draw ( -- +(225:0.4*#3);           % arrow part         }     } } \newcommand\elementsymbol[1][]{     \pgfkeys{/element settings,default,#1}     \path pic (\elementname) {elementsym=origin {\elementxpos}:{\elementypos} d {\elementdiameter}};     % label attachment     \node [circle,inner sep=0,minimum size=\elementdiameter]           at (\elementxpos,\elementypos) [label={[label distance=-0.5ex]60:\elementlabel}] {}; }  \begin{document} \begin{tikzpicture}[     scale=0.5 ]      \draw (0,0) -- +(0:5mm) coordinate (con);     \gettikzxy{(con)}{\xpos}{\ypos}     \elementsymbol [x pos=\xpos,y pos=\ypos,name=device,label=x] % How to enable argument "label={60:text}"? \end{tikzpicture} \end{document} 

How to make properly macro with the use of pic?

Links listed below were helpful for me (not everything I understand), but I can't find solutions of the above problems by the use of information contained in these links.

  1. Using pgfkeys as an argument to a macro
  2. How to interpret the contents of a macro as key=value assignment for pgfkeys
  3. How to create a command with key values?

After reading pgfkeys documentation in pgf-tikz manual several times I can't understand it in many points.


Following code shows how to define a new shape for your symbol adapting the original code from forbidden sign shape.

\usetikzlibrary{positioning, arrows.meta}

  \inheritsavedanchors[from=circle] % this is nearly a circle
  \inheritanchor[from=circle]{north west}
  \inheritanchor[from=circle]{north east}
  \inheritanchor[from=circle]{mid west}
  \inheritanchor[from=circle]{mid east}
  \inheritanchor[from=circle]{base west}
  \inheritanchor[from=circle]{base east}
  \inheritanchor[from=circle]{south west}
  \inheritanchor[from=circle]{south east}
    \[email protected]=\[email protected]%
    \[email protected]=\[email protected]%
    \[email protected]=\radius%
    \pgfmathsetlength{\[email protected]}{\pgfkeysvalueof{/pgf/outer xsep}}%
    \pgfmathsetlength{\[email protected]}{\pgfkeysvalueof{/pgf/outer ysep}}%
    \ifdim\[email protected]<\[email protected]%
      \advance\[email protected] by-\[email protected]%
      \advance\[email protected] by-\[email protected]%
    \pgfpathmoveto{\pgfpointadd{\pgfqpoint{\[email protected]}{\[email protected]}}{\pgfqpoint{-0.6\[email protected]}{-0.6\[email protected]}}}
    \pgfpathlineto{\pgfpointadd{\pgfqpoint{\[email protected]}{\[email protected]}}{\pgfqpoint{0.6\[email protected]}{0.6\[email protected]}}}


\node[draw, newsign] (A) {A};

\node[draw, newsign, minimum size=1cm, red, fill=green!30, ultra thick, label=x] at (2,0) (B) {};

\draw (A) -- (B);

\node[draw, newsign] at (0,1) {Text};

How to make properly macro with the use of pic?

Category: tikz pgf Time: 2016-07-28 Views: 3

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.123 (s). 12 q(s)