2

Is it possible to positioning circuitikz nodes, for example antennas relativeli to another node? For example:

\documentclass[border=1mm,
               preview]{standalone}
\usepackage{circuitikz}
\usetikzlibrary{positioning}

        \begin{document}
%%%%    circuit-positioning
    \begin{circuitikz}[node distance=0pt]
\node (bs) [draw,align=center] {base\\station};
\node (a1) [rxantenna] at (bs.east) {};
\node (u1) [draw,align=center,
            below right =3mm and 55mm of bs] {user\\1};
\node (a2) [txantenna,left=of u1.west, xscale=-1] {};
    \end{circuitikz}
        \end{document}

For txanntena i receive error:

Package PGF math Error: Unknown function 'east' (in 'east')

Is only possible positioning as it is in MWE for rxantena?

1 Answer 1

2

When you say right=<dimension> of <wherever>, TikZ uses the direction and the <wherever> and the relevant anchor of the shape you are constructing. So right=of bs.east uses the east anchor of bs and the west anchor of the shape being constructed.

This means that the shape being constructed must have a suitable anchor e.g. west but this is not a requirement for something's being a valid node shape. It is recommended that all node shapes define a center anchor, but even that isn't strictly required.

The problem here is that the antennas in question don't have anchors west or east. Here are the definitions from circuitikz:

\pgfdeclareshape{txantenna}{
        \anchor{center}{\pgfpointorigin}
        \savedanchor{\northeast}{
                \pgf@circ@res@step=\ctikzvalof{monopoles/txantenna/width}\pgf@circ@Rlen
                \pgf@x=5\pgf@circ@res@step%-0.5\pgflinewidth
                \pgf@y=6\pgf@circ@res@step
        }
        \anchor{text}{
                \northeast
                \pgf@x=\ctikzvalof{monopoles/txantenna/label/xanchor}\pgf@x
                \pgf@y=\ctikzvalof{monopoles/txantenna/label/yanchor}\pgf@y
        }
       \behindforegroundpath{
       \pgfstartlinewidth=\pgflinewidth
       \pgf@circ@res@step=\ctikzvalof{monopoles/txantenna/width}\pgf@circ@Rlen

         \pgfpathmoveto{\pgfpointorigin}
         \pgfpathlineto{\pgfpoint{4\pgf@circ@res@step}{0pt}}
         \pgfpathmoveto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{0pt}}
        }
       \behindforegroundpath{
       \pgfstartlinewidth=\pgflinewidth
       \pgf@circ@res@step=\ctikzvalof{monopoles/txantenna/width}\pgf@circ@Rlen

         \pgfpathmoveto{\pgfpointorigin}
         \pgfpathlineto{\pgfpoint{4\pgf@circ@res@step}{0pt}}
         \pgfpathmoveto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{0pt}}
             \pgfpathlineto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}

         \pgfusepath{draw}

          \pgfscope   
          \pgfpathmoveto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
             \pgfpathlineto{\pgfpoint{5\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
             \pgfpathlineto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{4\pgf@circ@res@step}}
             \pgfpathlineto{\pgfpoint{3\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
             \pgfpathlineto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
             \pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}
             \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
             \pgfusepath{draw}
           \endpgfscope
          \pgfpathmoveto{\pgfpoint{5.5\pgf@circ@res@step}{6\pgf@circ@res@step}}
%        \pgfpatharc{60}{-60}{\pgf@circ@res@step and \pgf@circ@res@step}
        \pgfpatharc{30}{-30}{2\pgf@circ@res@step}         \pgfpathmoveto{\pgfpoint{6\pgf@circ@res@step}{6.25\pgf@circ@res@step}}
        \pgfpatharc{30}{-30}{2.5\pgf@circ@res@step}
        \pgfpathmoveto{\pgfpoint{6.5\pgf@circ@res@step}{6.5\pgf@circ@res@step}}
        \pgfpatharc{30}{-30}{3\pgf@circ@res@step}
        \pgfpathmoveto{\pgfpoint{7\pgf@circ@res@step}{6.75\pgf@circ@res@step}}
        \pgfpatharc{30}{-30}{3.5\pgf@circ@res@step}
        \pgfpathmoveto{\pgfpoint{7.5\pgf@circ@res@step}{7\pgf@circ@res@step}}
        \pgfpatharc{30}{-30}{4\pgf@circ@res@step}
        \pgfusepath{draw}
        \pgfsetlinewidth{\pgfstartlinewidth}

        }
     }


\pgfdeclareshape{rxantenna}{
        \anchor{center}{\pgfpointorigin}
        \savedanchor{\northeast}{
                \pgf@circ@res@step=\ctikzvalof{monopoles/txantenna/width}\pgf@circ@Rlen
                \pgf@x=5\pgf@circ@res@step%-0.5\pgflinewidth
                \pgf@y=6\pgf@circ@res@step
        }
        \anchor{text}{
                \northeast
                \pgf@x=\ctikzvalof{monopoles/rxantenna/label/xanchor}\pgf@x
                \pgf@y=\ctikzvalof{monopoles/rxantenna/label/yanchor}\pgf@y
        }
    \behindforegroundpath{
        \pgfstartlinewidth=\pgflinewidth
        \pgf@circ@res@step=\ctikzvalof{monopoles/rxantenna/width}\pgf@circ@Rlen

         \pgfpathmoveto{\pgfpointorigin}
         \pgfpathlineto{\pgfpoint{4\pgf@circ@res@step}{0pt}}
         \pgfpathmoveto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{0pt}}
             \pgfpathlineto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}

         \pgfusepath{draw}

          \pgfscope   
          \pgfpathmoveto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
             \pgfpathlineto{\pgfpoint{5\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
             \pgfpathlineto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{4\pgf@circ@res@step}}
             \pgfpathlineto{\pgfpoint{3\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
             \pgfpathlineto{\pgfpoint{4\pgf@circ@[email protected]\pgflinewidth}{6\pgf@circ@res@step}}
             \pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}
             \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
             \pgfusepath{draw}
           \endpgfscope

           \pgfpathmoveto{\pgfpoint{6\pgf@circ@res@step}{7\pgf@circ@res@step}}
%             \pgfpatharc{60}{-60}{\pgf@circ@res@step and \pgf@circ@res@step}
             \pgfpatharc{150}{210}{4\pgf@circ@res@step}              \pgfpathmoveto{\pgfpoint{6.5\pgf@circ@res@step}{6.75\pgf@circ@res@step}}
             \pgfpatharc{150}{210}{3.5\pgf@circ@res@step}
             \pgfpathmoveto{\pgfpoint{7\pgf@circ@res@step}{6.5\pgf@circ@res@step}}
             \pgfpatharc{150}{210}{3\pgf@circ@res@step}
             \pgfpathmoveto{\pgfpoint{7.5\pgf@circ@res@step}{6.25\pgf@circ@res@step}}
             \pgfpatharc{150}{210}{2.5\pgf@circ@res@step}
             \pgfpathmoveto{\pgfpoint{8\pgf@circ@res@step}{6\pgf@circ@res@step}}
             \pgfpatharc{150}{210}{2\pgf@circ@res@step}
             \pgfusepath{draw}
             \pgfsetlinewidth{\pgfstartlinewidth}

             }
}

As can be seen, the only anchors defined for these shapes are center and text. Hence, positioning which depends on other anchors cannot be used.

1
  • Dear @cfr, thank you very much for your exhaustive answer. I must confess, that after reading it and observing code for antenna I'm pretty much lost since my anticipation, how it is designed, seems to be wrong. I need some time to understanding, how positioning with at actually works. Using it, node is positioned north east from given point. I will examine closely your answer asap.
    – Zarko
    Aug 22, 2016 at 1:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .