Probably a lame question about how positioning in TikZ works. I'm trying to draw some electrical stuff (starting on the level of single gates) and because many of them repeat over and over, I want to define macros for drawing them. I have this simple thing:
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\def\halfadderplain{%
\draw +(0,2) -- +(3,2);
\draw +(0,1) -- +(3,1);
\draw +(0,0) -- +(3,0);
\draw +(0.5,-0.5) [fill=white] rectangle +(2.5,2.5);
\node at +(1.5,1) {QHA};
}
\begin{tikzpicture}
\coordinate (0,0);
\halfadderplain;
\coordinate (3,3);
\halfadderplain;
\end{tikzpicture}
\end{document}
I want it to do the following: I set up a beginning coordinate and call the macro to draw the component, then I set the coordinate somewhere else and call the draw again. I want to end up with two components drawn like this:
but instead the result is only:
I tried the \newcommand and parameterized the \halfadderplain to set the coordinates and it did properly. I also tried to replace \halfadderplain in above code with its definition and nothing happened, so I think this is not the problem with macro but just my misunderstanding how TikZ computes position. Can somebody help please?
(Please note that using some specific library for drawing this kind of stuff is IS NOT a solution for me.)