3

With the code

\documentclass[tikz,convert={size=640}]{standalone}

\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{quotes}

\begin{document}
\begin{tikzpicture}[
  rect/.style={rectangle},
  sum/.style={draw,circle,minimum width=0.2cm,minimum height=0.2cm},
  dot/.style={fill,circle,inner sep=1pt,outer sep=0pt},
  pics/lowpass/.style args={#1 and #2}{
    code={
      \node[sum,"-45:-"] (-in) {};
      \node[rect,right=0.3cm of -in] (-gain) {#1};
      \node[sum,right=0.3cm of -gain] (-sum) {};
      \node[dot,right=1.25cm of -sum] (-out) {};
      \node[rect,below=0.5cm of $(-sum)!0.5!(-out)$,
            "left:#2"{font=\scriptsize,yshift=-0.25cm}] (-int) {$z^{-1}$};
      \draw[-latex] (-in) -- (-gain);
      \draw[-latex] (-gain) -- (-sum);
      \draw (-sum) -- (-out);
      \draw[-latex] (-out) |- (-int); 
      \draw[-latex] (-int) -| (-in);
      \draw[-latex] (-sum |- -int) node[xshift=-1.5pt,dot] {} -- (-sum) ; 
    }
  }
] 
  \pic (lowpass1) at (0,0) {lowpass=$k_e$ and $x_1(k)$};
  \pic[right=1cm of lowpass1-out] (lowpass2) {lowpass=$k_c$ and $x_2(k)$};
  \end{tikzpicture}
\end{document}

I produce this image

enter image description here

Depending on absolute and relative position the lower centered dot is shifted by 1.5pt. How can I avoid this behaviour and what is the reference point when I use relative positioning with \pic?

3

First of all, this could be considered subjective, but I find the positioning to be rather confusing. If you can, I'd use absolute positioning for all nodes, it grants some consistency.

Anyway, here's a slightly modified version of your code.

Output

enter image description here

Code

\documentclass[tikz, margin=10pt]{standalone}

\usetikzlibrary{positioning,calc,quotes}

\tikzset{
    rect/.style={rectangle},
    sum/.style={draw,circle,minimum width=0.2cm,minimum height=0.2cm},
    dot/.style={fill,circle,inner sep=1pt,outer sep=0pt},
    pics/lowpass/.style args={#1 and #2}{
        code={
          \node[sum,"-45:-"] (-in) {};
          \node[rect,right=0.3cm of -in] (-gain) {#1};
          \node[sum,right=0.3cm of -gain] (-sum) {};
          \node[dot,right=1.25cm of -sum] (-out) {};
          \node[rect,below=0.5cm of $(-sum)!0.5!(-out)$] (-int) {$z^{-1}$};
          \node[dot, below=0.55cm of -sum,label={below:\scriptsize #2}] {};
          \draw[-latex] (-in) -- (-gain);
          \draw[-latex] (-gain) -- (-sum);
          \draw (-sum) -- (-out);
          \draw[-latex] (-out) |- (-int); 
          \draw[-latex] (-int) -| (-in);
          \draw[-latex] (-sum |- -int) -- (-sum); 
        }
    }
}

\begin{document}
\begin{tikzpicture}

  \pic (lowpass1) at (0,0) {lowpass=$k_e$ and $x_1(k)$};
  \pic[right=1cm of lowpass1-out] (lowpass2) {lowpass=$k_c$ and $x_2(k)$};

\end{tikzpicture}
\end{document}
1

It seems it's a bug in the interplay of the positioning library and \pic. A possible workaround is to use the center anchor of each node in the definition of the \pic:

\documentclass[tikz,convert={size=640}]{standalone}

\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{quotes}

\begin{document}
\begin{tikzpicture}[
  rect/.style={rectangle},
  sum/.style={draw,circle,minimum width=0.2cm,minimum height=0.2cm},
  dot/.style={fill,circle,inner sep=1pt,outer sep=0pt},
  pics/lowpass/.style args={#1 and #2}{
    code={
      \begin{scope}[every node/.append style={anchor=center}]
        \node[sum,"-45:-"] (-in) {};
        \node[rect,right=0.3cm of -in] (-gain) {#1};
        \node[sum,right=0.3cm of -gain] (-sum) {};
        \node[dot,right=1.25cm of -sum] (-out) {};
        \node[rect,below=0.5cm of $(-sum)!0.5!(-out)$,
              "left:#2"{font=\scriptsize,yshift=-0.25cm}] (-int) {$z^{-1}$};
        \draw[-latex] (-in) -- (-gain);
        \draw[-latex] (-gain) -- (-sum);
        \draw (-sum) -- (-out);
        \draw[-latex] (-out) |- (-int); 
        \draw[-latex] (-int) -| (-in);
        \draw[-latex] (-sum |- -int) node[dot] {} -- (-sum) ; 
      \end{scope}
    }
  }
] 
  \pic (lowpass1) at (0,0) {lowpass=$k_e$ and $x_1(k)$};
  \pic[right=1cm of lowpass1-out] (lowpass2) {lowpass=$k_c$ and $x_2(k)$};
  \end{tikzpicture}
\end{document}

this produces the desired behaviour:

enter image description here

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.