How to draw an arrow pointing the middle of another arrow using tikz

Antonio Santoro 07/11/2018. 2 answers, 89 views
tikz-pgf arrows

I need to draw the red arrow in the figure but I'm not able to.

enter image description here

Here's my code

\documentclass[10pt,a4paper]{toptesi}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{tikz}
\usetikzlibrary{shapes, positioning}
\author{Antonio Santoro}
\begin{document}
\begin{tikzpicture}[ball/.style={ellipse, minimum width=3cm, minimum height=1.5cm, draw},>=latex]

\node[ball] (classeA) {classe A};
\node[ball, right=2.5cm of classeA] (classeB) {classe B};
\node[ball, above right=2cm of classeA] (loaderL) {loader L};
\node[rectangle,draw,minimum width=2cm,minimum height=1cm, right=4cm of loaderL] (bytecode) {bytecode};

\draw[-] (bytecode) -- node[above] {caricamento} (loaderL);
\draw[->] (loaderL) -- (classeB);
\draw[->] (loaderL) -- (classeA);
\draw[->] (classeA) -- node[above] {intercetta} (loaderL-classeB);

\end{tikzpicture}


\end{document}

but it gives me errors.

2 Answers


Phelype Oleinik 07/11/2018.

Maybe not the most smart solution, but you can add an empty node to the path between loader L and classe B and then draw the arrow to that node:

enter image description here

\documentclass[10pt,a4paper]{toptesi}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{tikz}
\usetikzlibrary{shapes, positioning}
\author{Antonio Santoro}
\begin{document}

\begin{tikzpicture}[ball/.style={ellipse, minimum width=3cm, minimum height=1.5cm, draw},>=latex]

\node[ball] (classeA) {classe A};
\node[ball, right=2.5cm of classeA] (classeB) {classe B};
\node[ball, above right=2cm of classeA] (loaderL) {loader L};
\node[rectangle,draw,minimum width=2cm,minimum height=1cm, right=4cm of loaderL] (bytecode) {bytecode};

\draw[-] (bytecode) -- node[above] {caricamento} (loaderL);
\draw[->] (loaderL) -- node [midway](LtoB){} (classeB);
\draw[->] (loaderL) -- (classeA);
\draw[->] (classeA) -- node [above,sloped] {intercetta} (LtoB);

\end{tikzpicture}

\end{document}

J Leon V. 07/11/2018.

You can define a node in a path like in the visual tikz manual section 7.9. and then draw an arrow usig that point, in this case named M.

enter image description here

\documentclass[border=10pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes, positioning}
\begin{document}
\begin{tikzpicture}[
    ball/.style={
        ellipse,
        minimum width=3cm,
        minimum height=1.5cm,
        draw
    },
    >=latex
]

\node[ball] (classeA) {classe A};
\node[ball, right=2.5cm of classeA] (classeB) {classe B};
\node[ball, above right=2cm of classeA] (loaderL) {loader L};
\node[rectangle,draw,minimum width=2cm,minimum height=1cm, right=4cm of loaderL] (bytecode) {bytecode};

\draw[-] (bytecode) -- node[above] {caricamento} (loaderL);
\draw[->] (loaderL) -- (classeB) node [sloped,midway](M){}; % Declare node in the middle of the path named M
\draw[->] (loaderL) -- (classeA);
\draw[->,red] (classeA) -- (M.center) node[midway,sloped,above]{\sf Label}; %Draw arrow, and put text in a node, declared in the midle again.

\end{tikzpicture}


\end{document}

HighResolutionMusic.com - Download Hi-Res Songs

1 The Chainsmokers

Beach House flac

The Chainsmokers. 2018. Writer: Andrew Taggart.
2 (G)I-DLE

POP/STARS flac

(G)I-DLE. 2018. Writer: Riot Music Team;Harloe.
3 Anne-Marie

Rewrite The Stars flac

Anne-Marie. 2018. Writer: Benj Pasek;Justin Paul.
4 Ariana Grande

​Thank U, Next flac

Ariana Grande. 2018. Writer: Crazy Mike;Scootie;Victoria Monét;Tayla Parx;TBHits;Ariana Grande.
5 Clean Bandit

Baby flac

Clean Bandit. 2018. Writer: Jack Patterson;Kamille;Jason Evigan;Matthew Knott;Marina;Luis Fonsi.
6 BTS

Waste It On Me flac

BTS. 2018. Writer: Steve Aoki;Jeff Halavacs;Ryan Ogren;Michael Gazzo;Nate Cyphert;Sean Foreman;RM.
7 Imagine Dragons

Bad Liar flac

Imagine Dragons. 2018. Writer: Jorgen Odegard;Daniel Platzman;Ben McKee;Wayne Sermon;Aja Volkman;Dan Reynolds.
8 Nicki Minaj

No Candle No Light flac

Nicki Minaj. 2018. Writer: Denisia “Blu June” Andrews;Kathryn Ostenberg;Brittany "Chi" Coney;Brian Lee;TJ Routon;Tushar Apte;ZAYN;Nicki Minaj.
9 Brooks

Limbo flac

Brooks. 2018.
10 BlackPink

Kiss And Make Up flac

BlackPink. 2018. Writer: Soke;Kny Factory;Billboard;Chelcee Grimes;Teddy Park;Marc Vincent;Dua Lipa.
11 Diplo

Close To Me flac

Diplo. 2018. Writer: Ellie Goulding;Savan Kotecha;Peter Svensson;Ilya;Swae Lee;Diplo.
12 Rita Ora

Velvet Rope flac

Rita Ora. 2018.
13 Fitz And The Tantrums

HandClap flac

Fitz And The Tantrums. 2017. Writer: Fitz And The Tantrums;Eric Frederic;Sam Hollander.
14 Little Mix

Woman Like Me flac

Little Mix. 2018. Writer: Nicki Minaj;Steve Mac;Ed Sheeran;Jess Glynne.
15 Billie Eilish

When The Party's Over flac

Billie Eilish. 2018. Writer: Billie Eilish;FINNEAS.
16 K-391

Mystery flac

K-391. 2018.
17 Cher Lloyd

None Of My Business flac

Cher Lloyd. 2018. Writer: ​iamBADDLUCK;Alexsej Vlasenko;Kate Morgan;Henrik Meinke;Jonas Kalisch;Jeremy Chacon.
18 Backstreet Boys

Chances flac

Backstreet Boys. 2018.
19 Lil Pump

Arms Around You flac

Lil Pump. 2018. Writer: Rio Santana;Lil Pump;Edgar Barrera;Mally Mall;Jon Fx;Skrillex;Maluma;Swae Lee;XXXTENTACION.
20 Kelly Clarkson

Never Enough flac

Kelly Clarkson. 2018. Writer: Benj Pasek;Justin Paul.

Related questions

Hot questions

Language

Popular Tags