I'm working on a block diagram using TikZ. I'd like to create a symbol like below, which means I have to draw 5 lines inside a node and write a letter in the upper-right corner.

enter image description here

What's the best way to achieve what I need? Any hints appreciated.

  • How often do you need this symbol. Is it a one-off or will you use it a lot? If a lot, will it always be the same or do you want to be able to scale it? – Andrew Stacey Aug 1 '12 at 14:11
  • I'm going to reuse this symbol about 3 times in a document. I'd like to be scalable. But would generally appreciate any hints regarding libraries or techniques to add simple drawings inside nodes, as it's possible I'm going to face this problem more times in the future. – mmm Aug 1 '12 at 14:40

Here is a possible implementation (based on Automat within Record). Is this what you had in mind?






\tikzset{drawinside/.code args={#1}{%
            \draw($(#1.south west)!0.4!(#1.west)!0.3!(#1.center)$)--($(#1.south west)!0.165!(#1.west)!0.5!(#1.center)$)--(#1.center);
            \draw(#1.center)--($(#1.north east)!0.165!(#1.east)!0.65!(#1.center)$)--($(#1.north east)!0.45!(#1.east)!0.45!(#1.center)$) node[right,font=\labelfont]{$\mylabel$};            

\tikzset{record/.style args={#1 and #2}{
        rectangle,draw,minimum width=#1, minimum height=#2

\node[record=\recordwidth cm and \recordheight cm,name=a\theimage]{};
\node[record=\recordwidth cm and \recordheight cm,name=a\theimage]at(#1){};


\drawrecord(6,0) % that's the 4° picture, so it can be accessed by (a4)

enter image description here

It allows you to customize the dimensions of the block and the labels. Moreover, as did for the last block, you can connect this with the rest of the picture by means of (anumber of the picture).

  • Wow. This achieves much more than just what I wanted - thank you. I feel I'll draw many hints from this example. – mmm Aug 1 '12 at 14:44
  • Glad of having help you :). – Claudio Fiandrino Aug 1 '12 at 14:52
  • I have a follow-up question about this, as the proposed solution is way too flexible/powerful for what I need (also, I would like to avoid xparse) Could you help me here or should I open a new question? – Federico Feb 18 '14 at 12:04
  • @Federico: without xparse it is a bit more tricky to perform the check on the presence of the argument, but it is also doable. I will try to provide a solution later on. – Claudio Fiandrino Feb 18 '14 at 12:51
  • That´s the thing: I do not need the check: I have a fixed size block (1x1 cm), the block is always placed w.r.t. a previously placed node and no label (the "M" in this case). I tried to remove that part, but I get errors I do not know how to solve. – Federico Feb 18 '14 at 12:56

Complementing Claudio's answer: You can also inherit the properties of a rectangle node shape and further add some drawings on top of it and use it as a genuine node shape.



\foreach \x in {center,north east,north west,north,south,south east,south west}{
\pgf@xa=\pgf@x \pgf@ya=\pgf@y


\node[satnode,minimum size=1cm,fill=blue,draw] (a) {};
\node[satnode,draw,fill=red,minimum height=2cm,minimum width=1 cm] (a2) at (-2,0) {};
\node[satnode,thick,draw,minimum height=1cm,minimum width=1.5 cm,fill=yellow] (a1) at (2,0) {};
\draw[-latex] (a2) -- (a) -- (a1);

enter image description here

  • 3
    Adding colours won't get you extra credits from me;-) – user10274 Aug 1 '12 at 21:00
  • 2
    @MarcvanDongen Getting a comment from you is also quite welcome :-). – percusse Aug 1 '12 at 21:13

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.