Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to create a node style which looks like this:

enter image description here

After some investigations I was not able to succeed and identified two directions to achieve this goal. I am asking here which direction should I take and how continue into this direction.

The first direction seems to use append after command in my style definition as following:

channel/.style={ 
        fifo,minimum size=4mm,minimum width=10mm,
        append after command={
          (\tikzlastnode.north west)edge(\tikzlastnode.north east)
          (\tikzlastnode.south west)edge(\tikzlastnode.south east)
          (\tikzlastnode.north east)edge(\tikzlastnode.south east)
        }
}

My problem with this solution is that I don't know how to extend it to draw de "other" vertical lines in my node.

The second direction consist in declaring a new shape as clearly described here How to draw inside a TikZ node, using node style? My problem with this solution is it's relative complexity and how to draw these lines using \pgf primitives.

Feel free to add any other solution that may better suits this need.

share|improve this question
1  
Except for the left border, a multipart rectangle is what you want. And, may be, creating-a-fifo-symbol-with-pgfdeclareshape can help you. –  Ignasi Nov 16 '12 at 14:04
    
Thanks for the link and what is a multipart rectangle ? –  Manuel Selva Nov 16 '12 at 15:02
1  
TikZ has a node shape called rectangle split, which is a rectangle divided into multiple parts. See chapter 48.6, Shapes with multiple text parts, in the manual. –  Torbjørn T. Nov 16 '12 at 22:12
add comment

1 Answer

up vote 6 down vote accepted

One solution would be to just add more edges at the appropriate spots. This version adds four vertical lines evenly distributed along the length:

enter image description here

Notes:

Code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\tikzset{channel/.style={ 
        minimum size=4mm, minimum width=10mm,
        append after command={
            (\tikzlastnode.north west)edge(\tikzlastnode.north east)
            (\tikzlastnode.south west)edge(\tikzlastnode.south east)
            ([shift={(0,+0.5\pgflinewidth)}]\tikzlastnode.north east)edge
            ([shift={(0,-0.5\pgflinewidth)}]\tikzlastnode.south east)
            ([shift={(0,+0.5\pgflinewidth)}]
                $(\tikzlastnode.north west)!0.8!(\tikzlastnode.north east)$)edge
            ([shift={(0,-0.5\pgflinewidth)}]
                $(\tikzlastnode.south west)!0.8!(\tikzlastnode.south east)$)
            ([shift={(0,+0.5\pgflinewidth)}]
                $(\tikzlastnode.north west)!0.6!(\tikzlastnode.north east)$)edge
            ([shift={(0,-0.5\pgflinewidth)}]
                $(\tikzlastnode.south west)!0.6!(\tikzlastnode.south east)$)
            ([shift={(0,+0.5\pgflinewidth)}]
                $(\tikzlastnode.north west)!0.4!(\tikzlastnode.north east)$)edge
            ([shift={(0,-0.5\pgflinewidth)}]
                $(\tikzlastnode.south west)!0.4!(\tikzlastnode.south east)$)
            ([shift={(0,+0.5\pgflinewidth)}]
                $(\tikzlastnode.north west)!0.2!(\tikzlastnode.north east)$)edge
            ([shift={(0,-0.5\pgflinewidth)}]
                $(\tikzlastnode.south west)!0.2!(\tikzlastnode.south east)$)
        }
    }
}

\begin{document} 
\begin{tikzpicture}
  \node [channel] (Channel1) at (0,  0)  {};
  \node [channel, minimum width=20mm] (Channel1) at (0, -0.5)  {};
\end{tikzpicture}
\end{document}
share|improve this answer
    
Many thanks !!! –  Manuel Selva Nov 17 '12 at 17:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.