3

i adjusted some code but now i reached my borders. i'd want to rotate the following shape with 90 degree, so it looks upwards afterwards. enter image description here enter image description here

but my problem is to put the connection lines also from west to north. It seems this shape doesn't have the anchor i need for this. My code:

\documentclass{article}
\usepackage{amsmath}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{shapes.multipart}
\usepackage{flowchart}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows.meta, calc, positioning, shapes, matrix}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}
\usepackage{circuitikz}

\newcommand{\mysize}{2.5cm}
\newcommand{\connectlength}{0.6cm}




\tikzstyle{mynode}=[draw, minimum size=\mysize,
label={[anchor = east]25:$\text{A}$},
label={[anchor = east]-25:$\text{B}$},]

\tikzstyle{mynodemirror} = [draw, minimum size=\mysize,
    label={[anchor = west]155:$\text{A}$},
    label={[anchor = west]205:$\text{B}$},]

\tikzstyle{mynodebelow} = [draw, minimum size=\mysize,
    label={[anchor = north]110:$\text{A}$},
    label={[anchor = north]70:$\text{B}$}]
\begin{document}

    \begin{tikzpicture}[]
    % Hilfslinien
%   \draw[help lines] (0,-7) grid (7,7);
    \node[mynode] (master) {node 0};
    \node[mynodemirror, right=8cm of master] (slave1)  {node 1};
    \node[mynodebelow, below left=2.0cm of slave1] (slave2)  {node 2};
%   \node[vcc, above=2cm of slave1]          (nodevcc) {VCC};


    \draw ($(master.north east)!.5!(master.east)$) to[short,-o]  ++(\connectlength,0) coordinate (oben_master);
    \draw ($(master.south east)!.5!(master.east)$) to[short,-o] ++(\connectlength,0) coordinate (unten_master);


    \draw ($(slave1.north west)!.5!(slave1.west)$) to[short,-o]  ++(-\connectlength,0) coordinate (oben_slave1);
    \draw ($(slave1.south west)!.5!(slave1.west)$) to[short,-o] ++(-\connectlength,0) coordinate (unten_slave1);

    % how to change the following line to make the connections look upwards?
    \draw ($(slave2.north west)!.5!(slave2.west)$) to[short,-o]  ++(-\connectlength,0) coordinate (oben_slave2);
    \draw ($(slave2.south west)!.5!(slave2.west)$) to[short,-o] ++(-\connectlength,0) coordinate (unten_slave2);



    \draw (oben_master) to[short] (oben_slave1);
    \draw (unten_master) to[short](unten_slave1);

    \end{tikzpicture}

\end{document}

results in this:

enter image description here

my try to fix node 2-shape (but can't compile)

\documentclass{article}
\usepackage{amsmath}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{shapes.multipart}
\usepackage{flowchart}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows.meta, calc, positioning, shapes, matrix}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}
\usepackage{circuitikz}

\newcommand{\mysize}{2.5cm}
\newcommand{\connectlength}{0.6cm}




\tikzstyle{mynode}=[draw, minimum size=\mysize,
label={[anchor = east]25:$\text{A}$},
label={[anchor = east]-25:$\text{B}$},]

\tikzstyle{mynodemirror} = [draw, minimum size=\mysize,
    label={[anchor = west]155:$\text{A}$},
    label={[anchor = west]205:$\text{B}$},]

\tikzstyle{mynodebelow} = [draw, minimum size=\mysize,
    label={[anchor = north]110:$\text{A}$},
    label={[anchor = north]70:$\text{B}$}]
\begin{document}

    \begin{tikzpicture}[]
    % Hilfslinien
%   \draw[help lines] (0,-7) grid (7,7);
    \node[mynode] (master) {node 0};
    \node[mynodemirror, right=8cm of master] (slave1)  {node 1};
    \node[mynodebelow, below left=2.0cm of slave1] (slave2)  {node 2};
%   \node[vcc, above=2cm of slave1]          (nodevcc) {VCC};


    \draw ($(master.north east)!.5!(master.east)$) to[short,-o]  ++(\connectlength,0) coordinate (oben_master);
    \draw ($(master.south east)!.5!(master.east)$) to[short,-o] ++(\connectlength,0) coordinate (unten_master);


    \draw ($(slave1.north west)!.5!(slave1.west)$) to[short,-o]  ++(-\connectlength,0) coordinate (oben_slave1);
    \draw ($(slave1.south west)!.5!(slave1.west)$) to[short,-o] ++(-\connectlength,0) coordinate (unten_slave1);

    % how to change the following line to make the connections look upwards?
    \draw ($(slave2.west north)!.5!(slave2.north)$) to[short,-o]  ++(-\connectlength,0) coordinate (oben_slave2);
    \draw ($(slave2.east north)!.5!(slave2.north)$) to[short,-o] ++(-\connectlength,0) coordinate (unten_slave2);



    \draw (oben_master) to[short] (oben_slave1);
    \draw (unten_master) to[short](unten_slave1);

    \end{tikzpicture}

\end{document}

i hope you can understand my problem.

Thank you very much.

7

First, there is no anchor west north or east north. And second, the lines for the connections must go up, so it should be ++(0,\connectlength).

The I also changed to[...] to --, because for straight lines -- is prefered. The option for the arrow tip can be given as \draw[-o] ....

I also added the lines from slave2 to the lines between master and slave1. Here -Circle produces a filled circle as arrow tip and shorten >=1.8pt makes the line a bit longer so the circle sits on the horizontal line and not below it (the value was determined by trial and error). The notetion ($(B)!(A)!(C)$) gives the point on the line (B) -- (C) where a line from (A) is perpendicular to (B) -- (C) (see section 13.5.5 of the PGF manual version 3.0.1a).

All this results in:

enter image description here

The code:

\documentclass{article}
\usepackage{amsmath}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{shapes.multipart}
%\usepackage{flowchart}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows.meta, calc, positioning, shapes, matrix}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}
\usepackage{circuitikz}

\newcommand{\mysize}{2.5cm}
\newcommand{\connectlength}{0.6cm}

\tikzstyle{mynode}=[draw, minimum size=\mysize,
    label={[anchor = east]25:$\text{A}$},
    label={[anchor = east]-25:$\text{B}$},]

\tikzstyle{mynodemirror} = [draw, minimum size=\mysize,
    label={[anchor = west]155:$\text{A}$},
    label={[anchor = west]205:$\text{B}$},]

% adapted angles here
\tikzstyle{mynodebelow} = [draw, minimum size=\mysize,
    label={[anchor = north]117:$\text{A}$},
    label={[anchor = north]63:$\text{B}$}]

\begin{document}
    \begin{tikzpicture}[]
    % Hilfslinien
%   \draw[help lines] (0,-7) grid (7,7);
    \node[mynode] (master) {node 0};
    \node[mynodemirror, right=8cm of master] (slave1)  {node 1};
    \node[mynodebelow, below left=2.0cm of slave1] (slave2)  {node 2};
%   \node[vcc, above=2cm of slave1]          (nodevcc) {VCC};

    \draw[-o] ($(master.north east)!.5!(master.east)$) --  ++(\connectlength,0) coordinate (oben_master);
    \draw[-o] ($(master.south east)!.5!(master.east)$) -- ++(\connectlength,0) coordinate (unten_master);

    \draw[-o] ($(slave1.north west)!.5!(slave1.west)$) --  ++(-\connectlength,0) coordinate (oben_slave1);
    \draw[-o] ($(slave1.south west)!.5!(slave1.west)$) -- ++(-\connectlength,0) coordinate (unten_slave1);

    \draw[-o] ($(slave2.north west)!.5!(slave2.north)$) --  ++(0,\connectlength) coordinate (oben_slave2);
    \draw[-o] ($(slave2.north east)!.5!(slave2.north)$) -- ++(0,\connectlength) coordinate (unten_slave2);

    \draw (oben_master)  -- (oben_slave1);
    \draw (unten_master) -- (unten_slave1);

    \draw[-Circle,shorten >=-1.8pt] (oben_slave2)  -- ($(oben_master)!(oben_slave2)!(oben_slave1)$);
    \draw[-Circle,shorten >=-1.8pt] (unten_slave2) -- ($(unten_master)!(unten_slave2)!(unten_slave1)$);
    \end{tikzpicture}
\end{document}
  • thank you it helped me alot. i quite didn't understand the syntax. do you know it is in the pgf manual? – myname Sep 29 '17 at 8:05
  • found it. it's called partway modifiers. – myname Sep 29 '17 at 9:16
1

with use of small pictures pic code for drawing of your picture is simple:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows}

\tikzset{
base/.style = {draw, minimum size=22mm},
  xs/.style = {xshift=#1mm},
  ys/.style = {yshift=#1mm},
    NR/.pic = {\node (@nr) [base] {#1};
        \draw[-o] ([ys=+3] @nr.east) node[left] {A}
        -- ++ (4mm,0) coordinate  (-A);
        \draw[-o] ([ys=-3] @nr.east) node[left] {B}
        -- ++ (4mm,0) coordinate  (-B);
                },
    NL/.pic = {\node (@nr) [base] {#1};
        \draw[-o] ([ys=+3] @nr.west) node[right] {A}
        -- ++ (-4mm,0) coordinate  (-A);
        \draw[-o] ([ys=-3] @nr.west) node[right] {B}
        -- ++ (-4mm,0) coordinate  (-B);
                },
    NA/.pic = {\node (@nr) [base] {#1};
        \draw[-o] ([xs=-3] @nr.north) node[below] {A}
        -- ++ (0,4mm) coordinate  (-A);
        \draw[-o] ([xs=+3] @nr.north) node[below] {B}
        -- ++ (0,4mm) coordinate  (-B);
                }
        }

\begin{document}
    \begin{tikzpicture}
\pic (n1) {NR=node 0};
\pic (n2) at (6, 0) {NL=node 0};
\pic (n3) at (3,-4) {NA=node 0};
\draw (n1-A) -- (n2-A);
\draw (n1-B) -- (n2-B);
%
\draw[fill] (n3-A) -- (n1-A -| n3-A) circle (1pt);
\draw[fill] (n3-B) -- (n1-B -| n3-B) circle (1pt);
    \end{tikzpicture}
\end{document}

enter image description here

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.