The question is an extension to this question, and is also related to this one.

I want to draw a Simulink-style sum block which is basically a circle node with a port in each direction (north, west, south, east). If a port is used as an added (or subtracted) input, a plus (or minus) sign is shown at the port. I hope I can specify the port configurations using custom node styles with arguments:

    positive/.pic = {\draw (-1mm,0)--(1mm,0) (0,-1mm)--(0,1mm);},
    negative/.pic = {\draw (-1mm,0)--(1mm,0);},
    sum block/.style = {draw, circle, inner sep=0pt, minimum size=9mm,
        north/.style = {append after command={pic at +(0,3mm) {#1}}},
        south/.style = {append after command={pic at +(0,-3mm) {#1}}},
        west/.style = {append after command={pic at +(-3mm,0) {#1}}},
        east/.style = {append after command={pic at +(3mm,0) {#1}}},
% I wish to create a node like this:
\path (1cm, 0) node [sum block] {} pic at +(0,3mm) {positive} pic at +(-3mm, 0) {negative};
% using a more elegant syntax like this:
\node at (2cm, 0) [sum block, north=positive, west=negative] {};

The result is as follows; the desired fancy syntax is not producing any port sign.

test output

Is there an easy way to meet the objective? A TikZ-only solution like this one is preferred.

  • It's much easier with path picture
    – percusse
    Mar 22, 2015 at 16:43
  • Also, you can use \pgftext{$+$} and \pgftext{$-$} instead of pics. Mar 22, 2015 at 18:58

1 Answer 1


Do you want something like this?

\documentclass[tikz, border=5pt]{standalone}
    charge node/.style={inner sep=0pt},
    pics/sum block/.style n args={4}{
        \path node (n) [draw, circle, inner sep=0pt, minimum size=9mm] {}
          (n.north) +(0,-1.5mm) node [charge node] {$#1$}
          (n.south) +(0,1.5mm) node [charge node] {$#2$}
          (n.west) +(1.5mm,0) node [charge node] {$#3$}
          (n.east) +(-1.5mm,0) node [charge node] {$#4$}
    \path pic at (10mm,0) {sum block={+}{-}{+}{-}}
    pic at (20mm,0) {sum block={}{+}{-}{}}

charge pics

  • 1
    Nice style n args solution! I modified it a little bit using alias and append after command to enable a node creation syntax like \node [sum block={-}{+}{}{}] {}; This is especially useful when the node is on a chain with automatic join.
    – salviati
    Mar 23, 2015 at 2:55
  • 2
    @salviati Can you post your finel solution please?
    – Mokus
    Sep 17, 2015 at 9:43
  • If I would like to draw two crossed diagonals, how can it be done?
    – Diaa
    Nov 15, 2018 at 11:36
  • @Diaa Ask a new question with a minimal example (code) and a pointer to this answer, if it is relevant. I have no idea what you mean and can't answer here anyway.
    – cfr
    Nov 16, 2018 at 3:44
  • how does this work with the \node syntax?
    – craigB
    Feb 20, 2023 at 1:19

You must log in to answer this question.

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