# line/ arrow to node with rounded corners [duplicate]

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

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}

• 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
• 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

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}


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

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