# Connecting 2 coordinates in tikz

In tikz, when it comes to connecting 2 coordinates, what is the difference between the different amounts of +s and -s, such as -+ , --++ , -++ , --+.

• Please, ilustrate your problem with small document with tikz picture and show what is your problem. To make yourself more familiar with tikz package, please read TikZ & PGF manula, first tutorial and part III: TikZ ist kein Zeichenprogramm Sep 18 '21 at 9:37
• Specifically, the differences between + and ++ is explained in section 2.15 Specifying Coordinates on page 40 of the PGF/TikZ manual (section/page numbers for version 3.1.9a as currently on CTAN). Sep 18 '21 at 10:10
• Note that I think this is actually a good question, asking things that are in the manual is perfectly fine on the site, especially when the manual is for TikZ and 1321 pages long. Sep 18 '21 at 10:12
• Does tex.stackexchange.com/q/113283/86 help? Sep 18 '21 at 11:29

Note that in TikZ, there is -- (two dashes) operation, but there is no - (one dash) operation. The command \draw (A)--(B); means drawing a straight segment from (A) to (B). The command \draw (A)-(B); returns an error. Operations -|, |-, ->, ... have different meanings.

Many TikZ beginners seem confusing about + and ++. To understand these, we need 2 things: connected path component, and the point for the next plus.

Connected path components A path is often composed by some connected path components. For example,

\draw
(A)--(B)        % 1st connected path component
(C)--(D)--(E)   % 2nd connected path component
(F) node{$F$}   % 3rd connected path component
;


In a connected path component without + or ++, the point for the next plus is exactly the starting point of that current connected path component.

\draw (A);            % the point for the next plus is A, but we do not care this.
\draw (A)--(B);       % the point for the next plus is A, but we do not care this.
\draw (A)--(B)--(C);  % the point for the next plus is A, but we do not care this.


When moving along a connected path component with + or ++: Both + and ++ mean to plus with the point for next plus (that TikZ has already known just before). The only difference between them is: + keeps unchanged the point for next plus, while ++ updates the new point for the next plus:

\draw (A)--+(B); %  \draw (A)--($(A)+(B)$); the point for the next plus is A

\draw (A)--++(B); %  \draw (A)--($(A)+(B)$); the point for the next plus is A+B (useless in this case, since there is nothing to plus)

\draw (A)--++(B)--+(C); %  \draw (A)--($(A)+(B)$)--($(A)+(B)+(C)$); the point for the next plus is A+B (uselful in this case: to plus with C)


Now, please copy line by line of the following code, and compile to see different effects of + and ++. That is all!

Hope this helps!

\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw[gray!30] (-2,-3) grid (6,5);
\fill (0,0) circle(2pt);
\path
(-1,-2) coordinate (A)  node[left]{$A$}
(4,1) coordinate (B) node[right]{$B$}
(1,3.5) coordinate (C) node[above]{$C$}
($(A)+(B)$) node[right]{$A+B$}
($(A)+(C)$) node[above]{$A+C$}
($(B)+(C)$) node[above]{$B+C$}
($(A)+(B)+(C)$) node[above]{$A+B+C$}
;
\draw (A)--(B)--(C);

% tpftnp=the point for the next plus

\draw (A)--(B)--+(C);           % same as (A)--(B)--($(A)+(C)$), tpftnp is A
\draw[blue] (A)--+(B)--(C);     % same as (A)--($(A)+(B)$)--(C), tpftnp is A
\draw[red] (A)--+(B)--+(C);     % same as (A)--($(A)+(B)$)--($(A)+(C)$), tpftnp is A

\draw[green] (A)--(B)--++(C);    % same as (A)--(B)--+(C), tpftnp is A, then C

\draw[violet] (A)--+(B)--++(C);  % same as (A)--+(B)--+(C), tpftnp is A, then C

\draw[orange] (A)--++(B)--(C); % same as (A)--+(B)--(C), tpftnp is A, then B
\draw[cyan] (A)--++(B)--+(C);  % same as (A)--($(A)+(B)$)--($(A)+(B)+(C)$) tpftnp is A, then B

\draw[blue] (A)--++(B)--++(C); % same as (A)--++(B)--+(C), tpftnp is A, then B, then C
\end{tikzpicture}
\end{document}


Summary. Going from the start to the end of each small piece of a path (called a connected path component), first take the starting point to be the point for the next plus, say (P); then

• if you meet a +(A) meaning (P)+(A), keep unchanged (P) and go next;
• if you meet a ++(A) meaning (P)+(A), updating (P) as (P)+(A), and go next;

till the end of the piece.

• Where does the line from the origin to (A) get drawn? It isn't part of the original \draw (A)--(B)--(C); is it? Sep 18 '21 at 16:15
• @BillNace It was my mistake in posting image. I corrected with some changes. Sep 18 '21 at 16:42