How to put a tikz node on the rounded corner?

This depends a bit on what do you intend for "middle"; I would use intersections generally. In this example, I am using as "middle point" the intersection of the curved path and the rectangle formed by the two parts for the red dot, and with a 45 degree angle in the case of the blue one.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc, intersections}
\begin{document}
\begin{tikzpicture}
    \draw (0,0)|-node{mid}(2,3);
\end{tikzpicture}\quad
\begin{tikzpicture}
    \draw [rounded corners=1cm] (0,0)|-node{mid}(2,3);
\end{tikzpicture}\quad
\begin{tikzpicture}
    \coordinate (one) at (0,0);
    \coordinate (two) at (2,3);
    \draw [rounded corners=1cm, name path=A] (one)|-(two);
    % remove draw=red
    \path [draw=red, name path=B] (one -| two) -- (two -| one);
    \coordinate[name intersections={of=A and B, by=DOT}];
    \node [circle, red, fill] at (DOT){};
\end{tikzpicture}\quad
\begin{tikzpicture}
    \coordinate (one) at (0,0);
    \coordinate (two) at (2,3);
    \draw [rounded corners=1cm, name path=A] (one)|-(two);
    \coordinate (mid) at  (one |- two);
    % remove draw=blue
    \path [draw=blue, name path=B] (mid) -- ($(mid)+(1,-1)$);
    \coordinate[name intersections={of=A and B, by=DOT}];
    \node [circle, blue, fill] at (DOT){};
\end{tikzpicture}
\end{document}

Output of the snippet above

You cal also use a decoration, but in this case you have to guessestimate the pos parameter:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\tikzset{markpos/.style args={#1 at #2}{decoration={
  markings,
  mark=at position #2 with {\coordinate(#1);}},postaction={decorate}}}
\begin{tikzpicture}
    \draw (0,0)|-node{mid}(2,3);
\end{tikzpicture}\quad
\begin{tikzpicture}
    \draw [rounded corners=1cm] (0,0)|-node{mid}(2,3);
\end{tikzpicture}\quad
\begin{tikzpicture}
    \draw [rounded corners=1cm, markpos=mymark at 0.6] (0,0)|-node{mid}(2,3);
    \node [circle, red, fill] at (mymark){};
\end{tikzpicture}
\end{document}

Another one


Here is a broad approach using node anchor that can certainly be improved:

\documentclass{article}
\usepackage{tikz}

    \begin{document}
    \begin{tikzpicture}
    \draw (0,0)|-node{mid}(2,3);
    \end{tikzpicture}
    \begin{tikzpicture}
    \draw [rounded corners=1cm] (0,0)|-node[below right]{mid}(2,3);
    \end{tikzpicture}
 \end{document}

enter image description here


You can use xshift and yshift to place the node properly. The value of these shifts can be obtained with simple geometry calculation.

  \draw [rounded corners=\rndc] (0,0)|-node[xshift=0.293*\rndc),yshift=-0.293*\rndc)]{mid}(2,3);

The number 0.293 is 1-1/sqrt(2).

enter image description here

The complete code

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \draw (0,0)|-node{mid}(2,3);
\end{tikzpicture}
\begin{tikzpicture}
  \def\rndc{1cm}
  \draw [rounded corners=\rndc] (0,0)|-node[xshift=0.293*\rndc),yshift=-0.293*\rndc)]{mid}(2,3);
\end{tikzpicture}
\end{document}

Tags:

Tikz Pgf