6

This question already has an answer here:

A line to/from a rounded corner ends at the position 'north east' and not at the line around the node.

enter image description here

Is there a simple way to end the line/arrow at the drawn line around A?

MWE:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[draw,rounded corners] (A) {A};
\node[draw] (B) at (1,1) {B};
\fill[red] (A.north east) circle(0.5pt) node[font=\tiny, above, anchor =west]{(A.north east)};
\draw[<->] (A) -- (B);
\end{tikzpicture}
\end{document}

marked as duplicate by Jake, Peter Jansson, Werner, Thorsten, Jesse Dec 18 '13 at 14:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Change this line of code \draw[<->] ($(A.north east)+(-0.35pt,-0.35pt)$) -- (B); will touch the corner, with calc package. – Jesse Dec 18 '13 at 13:04
  • 2
    Here is a solution to your problem without the need for manual adjustments: tex.stackexchange.com/a/68568/10844 – boothby81 Dec 18 '13 at 13:17
  • Another solution, without manual tricks, would be to use the rounded rectangle from the shapes.misc library. – Claudio Fiandrino Dec 18 '13 at 16:17
4

Here is a bit manual approach using shorten.

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[draw,rounded corners] (A) {A};
\node[draw] (B) at (1,1) {B};
%\fill[red] (A.north east) circle(0.5pt) node[font=\tiny, above, anchor =west]{(A.north east)};
\draw[<->,shorten <= -2pt+\pgflinewidth] (A) -- (B);
\end{tikzpicture}
\end{document}

enter image description here

  • This only works reliably if the arrow is coming in at 45°. – Henri Menke Jul 7 '16 at 12:20
2

using an empiric solution :

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\node[draw,rounded corners,yellow,minimum height=1cm, minimum width=1cm] (A) {ABC};
\node[draw] (B) at (1,1) {B};

\coordinate[xshift=-0.3ex,yshift=-0.3ex] (fakeA) at (A.north east);

\draw [<->, blue] (fakeA) -- (B);
\draw [red] (A.north east) -- (B);
\end{tikzpicture}
\end{document}

you can't use A.xx anchor: this point to the real rect. the rounded corner is a path operation.

A node in TikZ is made by two functions : first function wrote effectively the node using path operation, all path parameter can be passed to this command, and rounded corner is a path operation modifier.

The second function need a raytracer like operation. for each point this function should return the intersection point between the line (0,0) -- (this point) and the node.

third, node define some anchor, predefined position. this position are independent of path modifier operation.

With this facts, you have 3 solutions : using rounded rectangle : like this

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\node[draw,rounded rectangle,yellow,minimum height=0.5cm, minimum width=1cm] (A) {ABC};
\node[draw] (B) at (1,1) {B};


\draw [<->, blue] (A) -- (B);
\end{tikzpicture}
\end{document}

But you don't have any way to specify the width and heigth of the rounded portion of the rectangle.

  • Make your own shape that manage better the rounded part (really complicated, need some math knowledge (in raytracing function).
  • Make some fake point like my example of previous example.

NB: you can't use the intersection TikZ library to found the correct point, I have already try it, this library don't really love the rounded corner.

  • But you can say rounded corners=<dimen>! – user11232 Dec 18 '13 at 13:28
  • with the dimen, my first solution can be precise, yes ;) – alexises Dec 18 '13 at 13:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.