4

What's the best way to vertically align text across two different paths?

I have the text copper along each arrow path. Because the lengths of the paths they're on are different, pos=0.6 positions the text so that they're not vertically aligned with one another across the paths.

Mis-aligned copper text

I can play with the positioning of the second path (e.g. pos=0.65) to get something more aligned, but is there a better way to do this?

Maybe aligned copper text?

Minimum Working Example (MWE)

\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning, calc}

\begin{document}

\begin{tikzpicture}[
    node distance=.25cm,
    block/.style={draw, rectangle, minimum size=1cm, align=center},
    coord/.style={coordinate}
    ]
    
    % Bounding box
    \node[block, minimum size=5cm, thick] (boundingbox) {};

    % External blocks
    \node[coord, right=of boundingbox.east, xshift=3cm] (originright) {};
    \node[block, above=of originright]  (proc1) {Proc1};
    \node[block, below=of originright]  (proc2) {Proc2};

    % Internal blocks
    \node[block, anchor=south]  (interface) at (boundingbox.south)  {Interface};

    % Arrows
    \draw[->]   (proc1) -- +(-1.5cm,0) |- ($ (interface.east)+(0,0.25cm) $) node[fill=white, font=\tiny, pos=0.6] {copper};
    \draw[->]   (proc2) -- +(-1.0cm,0) |- ($ (interface.east)+(0,-.25cm) $) node[fill=white, font=\tiny, pos=0.6] {copper};

\end{tikzpicture}

\end{document}

1 Answer 1

4

for horizontal align of edge labels you need to positioned on the same distance form their destinations, for example with right=2cm:

\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,
                positioning}

\begin{document}
    \begin{tikzpicture}[
node distance =.25cm,
 block/.style = {draw, minimum size=1cm},
    coord/.style={coordinate}
    ]

    % Bounding box
 \node[block, minimum size=5cm, thick] (boundingbox) {};

    % External blocks
\node[coord, right=of boundingbox.east, xshift=3cm] (originright) {};
\node[block, above=of originright]  (proc1) {Proc1};
\node[block, below=of originright]  (proc2) {Proc2};

    % Internal blocks
\node[block, anchor=south]  (interface) at (boundingbox.south)  {Interface};

    % Arrows
\draw[->]   (proc1) -- +(-1.5cm,0) |- ($ (interface.east)+(0,0.25cm) $) node (aux) [fill=white, font=\tiny, right=20mm] {copper};
\draw[->]   (proc2) -- +(-1.0cm,0) |- ($ (interface.east)+(0,-.25cm) $) node[fill=white, font=\tiny, right=20mm] {copper};
    \end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .