TransWikia.com

Reverse arrow tip but keep line length

TeX - LaTeX Asked on May 9, 2021

I am wondering if there is a way to reverse the arrow tip but keep the length of the line constant? I checked the arrow.meta documentation, but could not find something like rotate

MWE

documentclass[border=5pt]{standalone}

usepackage{tikz}
usetikzlibrary{arrows.meta}

begin{document}
    begin{tikzpicture}
        
        draw[orange, very thin] (0.93,-0.5) -- (0.93,1.5);
        draw[orange, very thin] (1,-0.5) -- (1,1.5);
%       draw[orange, very thin] (1.07,-0.5) -- (1.07,1.5);

        draw[-{>[length=0.07cm]}] (0,0) -- (1,0);
        draw[-{<[length=0.07cm]}] (0,0.5) -- (1,0.5);
%       draw[-{>[rotate=180]}] (0,1) -- (1,1);
        draw[-{<[length=0.07cm]}] (0,1) -- (1.07,1);

    end{tikzpicture}
end{document}

enter image description here

In my example, I defined the length of the tip and added the length to the total length, but maybe there is an easier way to do it?

One Answer

In addition to the great comment from Sandy G, I recommend to create a tikzset for this, to let you use it even with predfined nodes and not having to do any calculation everytimes.

documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{arrows.meta}

tikzset{%
        revarrow/.style={-{<[length=#1]},shorten >=-#1},
        circ/.style={circle,inner sep=1pt,fill=black,label={#1}}}

begin{document}
    begin{tikzpicture}
        path (0,0) node[circ=A](A){} --++ (3,0) node[circ=B](B){};
        draw[orange,revarrow=.5cm,thick] (A.center)--(B.center);
    end{tikzpicture}
end{document}

shorten reverse arrow

Correct answer by SebGlav on May 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP