Document ClassesNode Coordinates in Circuits

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
Jaraqui
Posts: 26
Joined: Wed Feb 08, 2012 3:54 am

Node Coordinates in Circuits

Post by Jaraqui »

Hi,

please consider the following code:

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{circuits.logic.US}
\begin{document}
\begin{tikzpicture}[circuit logic US]
\matrix[column sep=7mm] {
\node (i0) {a}; & \node [not gate] (not1) {}; & \\
\node (i1) {b}; & & \node [and gate] (and1) {}; \\
& \node [nor gate] (nor1) {}; & \\
\node (i2) {c}; & & \\
};
\draw (i0.east) -- (not1.input);
\draw (i1.east) -- ++ (right: 3mm) |- (nor1.input 1);
\draw (i2.east) -- ++ (right: 3mm) |- (nor1.input 2);
\draw (not1.output) -- ++ (right: 3mm) |- (and1.input 1);
\draw (nor1.output) -- ++ (right: 3mm) |- (and1.input 2);
\draw (and1.output) -- ++ (right: 3mm);
\node at (0.7, 1.05) {a'};
\node at (0.8,-0.8) {(b+c)'};
\node at (2.9, 0.15) {a(b+c)'};
\end{tikzpicture}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I am trying to express the coordinates of the last three \node commands in such a form that they can be related to the nodes in the matrix (likewise the \draw commands).

Is it possible? If 'yes', how?

Regards

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Node Coordinates in Circuits

Post by localghost »

Very good MWE!

You can position nodes relatively to coordinates of intermediate points in paths. For your example it could look like this.

Code: Select all

Code, edit and compile here:
\documentcFass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{circuits.logic.US}
\begin{document}
\begin{tikzpicture}[circuit logic US]
\matrix[column sep=7mm] {
\node (i0) {a}; & \node[not gate] (not1) {}; & \\
\node (i1) {b}; & & \node[and gate] (and1) {}; \\
& \node[nor gate] (nor1) {}; & \\
\node (i2) {c}; & & \\
};
\draw (i0.east) -- (not1.input);
\draw (i1.east) -- ++ (right: 3mm) |- (nor1.input 1);
\draw (i2.east) -- ++ (right: 3mm) |- (nor1.input 2);
\draw (not1.output) -- ++ (right: 3mm) node[above right=-2pt] {a'} |- (and1.input 1);
\draw (nor1.output) -- ++ (right: 3mm) node[below right=-2pt] {(b+c)'} |- (and1.input 2);
\draw (and1.output) -- ++ (right: 3mm) node[right] {a(b+c)'};
\end{tikzpicture}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
For details please refer to the PGF/TikZ manual.


Thorsten
Jaraqui
Posts: 26
Joined: Wed Feb 08, 2012 3:54 am

Re: Node Coordinates in Circuits

Post by Jaraqui »

Perfect!

Thank You!
Post Reply