Home > tikz pgf > Path to midpoint of other path

# Path to midpoint of other path

September 4Hits:1

I would like to end a path at the midpoint of another path. My inclination has been to try and end the path at an offset equal to half the node distance from d.north, but any thing I seem to try will not compile. Here's what I have so far (the end goal being the 'No' path ending at 'HERE' )

\documentclass{article}  \usepackage{tikz} \usetikzlibrary{shapes,arrows,calc} \begin{document} \pagestyle{empty}      % Define block styles \tikzstyle{box} = [rectangle, draw] \tikzstyle{line} = [draw, -latex']  \begin{tikzpicture}[node distance = 3cm, auto]     % Place nodes     \node [box] (a) {A};     \node [box, below of=a] (b) {B};     \node [box, below of=b] (c) {C};     \node [box, below of=c] (d) {D};         % Draw edges     \path [line] (a) -- (b);     \path [line] (b) -- (c);     \path [line] (c) -- node [midway, left] {HERE} (d);     \path [line] (a.east) --node [above] {No}  +(1,0) |- (d.north);       \end{tikzpicture}  \end{document} 


I've seen some things on path decorations, but I'm really unsure how to use them and not sure that I can end the path on them.

Your code already contains a solution (without calc library): midway!

\documentclass{standalone}
\usepackage{tikz}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}

\tikzstyle{box} = [rectangle, draw]
\tikzstyle{line} = [draw, -latex']

\begin{document}
\begin{tikzpicture}[node distance = 3cm, auto]
% Place nodes
\node [box] (a) {A};
\node [box, below of=a] (b) {B};
\node [box, below of=b] (c) {C};
\node [box, below of=c] (d) {D};

% Draw edges
\path [line] (a) -- (b);
\path [line] (b) -- (c);
\path [line] (c) -- coordinate[midway](m) (d);

\path [line] (a.east) --node [above] {No}  +(1,0) |- (m);
\end{tikzpicture}
\end{document}



Like this? (c)!0.5!(d) means halfway between (c) and (d).

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows,calc}
\begin{document}
\pagestyle{empty}

% Define block styles
\tikzstyle{box} = [rectangle, draw]
\tikzstyle{line} = [draw, -latex']

\begin{tikzpicture}[node distance = 3cm, auto]
% Place nodes
\node [box] (a) {A};
\node [box, below of=a] (b) {B};
\node [box, below of=b] (c) {C};
\node [box, below of=c] (d) {D};

% Draw edges
\path [line] (a) -- (b);
\path [line] (b) -- (c);
\path [line] (c) -- node [midway, left] {HERE} (d);

\path[line] let \p1 = ( $(c)!0.5!(d)$ ) in (a.east) --node [above] {No}  +(1,0) |- +(0,\y1);

\end{tikzpicture}

\end{document}



Tags:tikz pgf

## Related Articles

• ### Path to midpoint of other pathSeptember 4

I would like to end a path at the midpoint of another path. My inclination has been to try and end the path at an offset equal to half the node distance from d.north, but any thing I seem to try will not compile. Here's what I have so far (the end go

• ### How to change AppleScript path to a Terminal-style path?December 14

I have a custom Service that I've created in Automater (I'm on OSX 10.6.5). The Service executes an AppleScript which in turn executes a shell script. Here is the AppleScript: on run {input, parameters} -- do shell script "/usr/bin/find " &

• ### How to change a particular path from the environment variable PATH?December 29

I incorrectly declared a variable, and now it has two forward slashes in it. How do I unset/correct it? PATH=...ols-1.3-62308//bin:/bin Thanks. --------------Solutions------------- In this particular example, do nothing: the double slash is exactly e

• ### Copy UNC network path (not drive letter) for paths on mapped drives from Windows ExplorerFebruary 11

I frequently want to share Windows network paths to files with other folks on my team via email or chat. We have a lot of mapped drives here, both ones we set up ourselves and ones set up by our IT overlords. What I'd like to be able to do is to copy

• ### Is there a way to clear paths previously defined with name path global in TikZJune 23

In the solution to Intersections in PGFplots it was pointed out that each \addplot command was drawn in its own scope and using name path would not survive outside of that \addplot command. The solution was to use name path global so that the path na

• ### How put path changing .bat file inside %PATH%?October 22

I have a problem described here (you can read it for better understanding). I need to write .bat file that change path. For example: While sending a command in cmd: cd ~ I want to go to %HOMEPATH%. In fact - I just want to replace ~ by %HOMEPATH% in

• ### How to reuse the right-hand path for the left-hand path such that it is displayed in reverse step by step?August 2

My title may be difficult to understand. Hopefully by seeing the animation, you get the idea. I want the left-hand wing to be drawn step by step as is the right-hand wing but I want to use the reversed path approach such that I can save more keystrok

• ### Second iteration - Is there a way to clear paths previously defined with name path global in TikZAugust 16

In realtion to this pretty old question (back 3 years from now) Is there a way to clear paths previously defined with name path global in TikZ? I would like to know, whether there is actually a nice feature in pgfplots v1.11 (the latest, today) that

• ### How to find the common paths from a list of paths/filesAugust 31

Prelude: Given a sorted input of a list of paths/files, how to find their common paths? Translating into tech term, if feeding the sorted input from stdin, how to pick the shortest proper prefix from the stdin? Here the "prefix" has the normal m

• ### Rewrite /url/path/index.php to /url/pathFebruary 22

I can't quite figure out how to use a regex in my .htaccess file to remove index.php from the end of a URL if and only if it is the last thing in the string. If the url is example.com/path/index.php, it should turn into: example.com/path/ But if the

• ### Is there a big difference between /this/is/a/path and /this/is/a/path/?June 12

I am a CentOS user for many years now, but I am still often not sure how the final slash matters in linux commands, e.g. tar rsync mv file handling in software/php What is the actual difference between paths ending and not ending with a slash? ------

• ### Applying stroke to path in Illustrator moves the path.June 26

As in title, when I apply stroke value to a path created with pen tool in Ai CS 5.5, this path is being moved. That doesn't apply to all shapes I made. Is there a setting that needs changing or what. I'm unable to create a proper, precise drawing bec

• ### Is it possible to edit the path and view the folder path in the Finder?September 12

I'm not sure what it is called on the Mac, but when I open my Downloads folder (or any other folder), I'm referring to this file explorer window that shows me my file structure. I know there are options, like I can view my files and folders in panes,

• ### Defining a point on a path by direction of another pathJanuary 14

Is it possible to define a point when I have two paths such as: beginfig(1); u := 1cm; path p[]; p0 := (1u,3u)--(2u,2u); p1 := (2u,0)--(3u,2u); for i=p0,p1: draw i; endfor; endfig; end so that if continuing p0 to the p1, the wanted point would be the

• ### Robocopy uses relative path for Source and Destination pathsJanuary 25

I'm trying to use RoboCopy in my TFS Build Template to copy some files, but for some reason it inserts "C:\Windows\system32" in front of my Source and Destination paths, even though I am passing in absolute paths. I know that the robocopy.exe is

• ### 'mysql' Command not Connecting as used from PATH but Works if Full Path is UsedAugust 7

Not sure how to fix this but here is the description. I can run the command to a Lampstack MySQL installation like this and it works: /opt/lampstack/mysql/bin/mysql -u root -p And my PATH variable has this path in it, but yet this command doesn't wor