Here is my code:
\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\node (circle) [draw, circle, minimum size = 20mm] at (0, 0) {}
(0, 0) node[above] {$I$};
\draw (circle.center) [{Rays[]}-|] -- (circle.east) node[below, midway] {$r$};
\draw (circle.east) -- (2, 0) node[below, midway] {$r$};
\draw (2, 0) [|-{Circle[]}] -- (3, 0) node[below, midway] {$r$} node[above] {P};
\end{tikzpicture}
\end{document}
The line (0, 0) node[above] {$I$};
imposes to be integrated in to this line: \node (circle) [draw, circle, minimum size = 20mm] at (0, 0) {}
. But I couldn't achieve it. How can I make this? Also any other optimization is welcome too.
The desired result (that I want to produce):
Best Answer
I'm not sure I've understood correctly, but do you want something like this?
Remember that a node is not the same as a path, so you cannot label it in the same way.
In effect, your original code places two nodes at the origin: first the circular one; then the
$I$
. This works because\node
is equivalent to\path node
. So you have\path node ... node ...;
Hence, the second node is placed above the path, which consists of the point(0,0)
.EDIT
Addressing the clarified question, just put the node above the line's starting point. For example,
There are other ways to do this, but this seems as straightforward to me as any.