# Creating a custom TikZ shape with lines [duplicate]

I want to create a shape that looks like this:

I have the following code

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[
inout/.style={
rectangle,
draw,
minimum size=1cm,
inner sep=2pt
}
]
\node[inout] (d1) at (1,1) {in};
\end{tikzpicture}

\end{document}


which produces this:

How do I add the lines? This is meant to be a custom shape for a circuit.

Thanks!

Note: I looked at the supposed duplicate of this question and didn't find it very helpful. The question itself wasn't very related (it didn't answer my line question in a way I could understand) and the documentation it provided I found very difficult. If someone could provide a simple explanation, that would be really helpful.

## marked as duplicate by percusse tikz-pgf StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Aug 11 '16 at 19:45

• Are the lines purely decorative? If so, you can just draw them. If you want something where the lines can be used as connectors and cannot make do with a pic, then there isn't a simple explanation of how to do it because nodes can only be defined by diving into the low level PGF stuff. The TikZ manual explains how to create nodes and what is required. It isn't simply only because the task itself is not simple. – cfr Aug 10 '16 at 22:08

If you don't want to create a new shape as in the given link which is often a very tedious job, then you can approximate it with a less flexible approach.

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[
inout/.style={
rectangle,
draw,
minimum size=1cm,
inner sep=2pt,
append after command={
foreach \x in {1,...,4}{
($(\tikzlastnode.south west)!0.2*\x!(\tikzlastnode.north west)$) edge[draw] ++(-2mm,0mm)
($(\tikzlastnode.south east)!0.2*\x!(\tikzlastnode.north east)$) edge[draw] ++(2mm,0mm)
}
}
}
]
\node[inout] (d1) at (1,1) {in};
\end{tikzpicture}
\end{document}


• Just one question: I put it into sharelatex, and it shows up as a tiny piece on a gray background; is it supposed to do that? – heather Aug 10 '16 at 22:10
• That worked, but it now gives the warning Unused global option(s). – heather Aug 10 '16 at 22:13
• @heather My pleasure – percusse Aug 10 '16 at 22:14