2

I want to connect the nodes where the lines or arrows only touch the edges, but instead, the lines and arrows are going to the center of the nodes. Here is my code:

\documentclass[tikz,border=5pt]{standalone}

\begin{document}

\begin{tikzpicture}

\coordinate (a) at (0,0);
\coordinate (b) at (-1,-1);
\coordinate (c) at ( 1,-1);

\node at (a) [circle,draw] () {a};
\node at (b) [circle,draw] () {b};
\node at (c) [circle,draw] () {c};

\draw[-] (a) to (b);
\draw[-] (a) to (c);

\end{tikzpicture}

\end{document}

Here is the output:

enter image description here

Edit: I see the problem now. I fixed by deleting the coordinates and changing

\node at (a) [circle,draw] () {a};

and similar lines to

\node at (0,0) [circle,draw] (a) {a};
2
  • Because the default node's anchor is its center. Also, it is not good to give the same name for a coordinate and for a node.
    – Sigur
    Feb 24, 2020 at 21:08
  • Oh... I see I am drawing from the node to the coordinate (instead of from the node to the node) XD
    – Ralff
    Feb 24, 2020 at 21:09

1 Answer 1

3

For your image you not to need define their coordinates separately:

\documentclass[tikz,border=5pt]{standalone}

\begin{document}
    \begin{tikzpicture}
\node (a) [circle,draw] at ( 0, 0) {a};
\node (b) [circle,draw] at (-1,-1) {b};
\node (c) [circle,draw] at ( 1,-1) {c};

\draw[-] (a) to (b);
\draw[-] (a) to (c);
    \end{tikzpicture}
\end{document}

If those coordinates you need for something else, they are now available as (a.center), (b.center) or (c.center).

enter image description here

You must log in to answer this question.

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