tikz add tag
निरंजन
I have the following code right now -

```
\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (3,0);
\draw (1.5,0) circle (5pt) node{a};
\end{tikzpicture}
\end{document}
```

If we see the output, the circle has the line inside it which I don't want. Also I don't want to draw the line in two parts (i.e. 

```
\begin{tikzpicture}
\draw (0,0) -- (1.3,0);
\draw (1.7,0) -- (3,0);
\draw (1.5,0) circle (5pt) node{a};
\end{tikzpicture}
```
)

This code gives me the output exactly like I want, but I don't want to do that calculation manually and draw so many lines in my entire picture. How to have a circle which is opaque, but also with some text?
Top Answer
Skillmon
The following defines a `circ path` for the `to` syntax. There is most likely a better way to define it, but my Ti*k*Z skills are limited.

```tex
\documentclass[tikz]{standalone}

\usetikzlibrary{calc}

\tikzset
  {%
    circ path/.style=%
      {%
        to path=%
          {%
            ($
              (\tikztostart)
              - \pgfkeysvalueof{/tikz/circ path/pos}*(\tikztostart)
              + \pgfkeysvalueof{/tikz/circ path/pos}*(\tikztotarget)
            $)
              node
                [
                  draw, circle, inner sep=0pt,
                  minimum size={\pgfkeysvalueof{/tikz/circ path/size}}
                ]
                (\pgfkeysvalueof{/tikz/circ path/name}) {#1}
            (\tikztostart) -- (\pgfkeysvalueof{/tikz/circ path/name})
                           -- (\tikztotarget)
          }%
      }
    ,circ path/size/.initial = 10pt
    ,circ path/name/.initial = circ path centre
    ,circ path/pos/.initial = 0.5
  }

\begin{document}
\begin{tikzpicture}
  \draw (0,0) -- (1.5cm-5pt,0) (1.5,0) circle(5pt) node {a} (1.5cm+5pt,0) -- (3,0);
  \draw (0,1) to[circ path=a] (3,1);
  \draw (0,2) to[circ path=b, circ path/name=mypoint] (3,3);
  \draw (mypoint) to[circ path=c, circ path/pos=0.8] (3,4);
\end{tikzpicture}
\end{document}
```

![tikzcirc-1.png](/image?hash=3e6461fc1e0787716c9a34f44c529613b1f4612515ad63c0ebfc8467639cd103)
Answer #2
user 3.14159
This is very much based on [Skillmon's nice answer](https://topanswers.xyz/tex?q=680#a755), but has some modifications. Most importantly, if the fraction is very small or very large, i.e. when the circle is very close to either start or end point, there will be no spurious extra lines. The syntax is also a bit shorter. At the technical level, this variation uses the partway modificator (see section **13.5.3 The Syntax of Partway Modifiers** of pgfmanual v3.1.5) to position the circle.


```
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc}
\tikzset{circ path/.style={circ path pars/.cd,#1,
/tikz/to path={%
  ($(\tikztostart)!\pgfkeysvalueof{/tikz/circ path pars/pos}!(\tikztotarget)$)
   node[draw, circle, inner sep=0pt,
       minimum size={\pgfkeysvalueof{/tikz/circ path pars/size}}]
     (\pgfkeysvalueof{/tikz/circ path pars/name}) 
	 {\pgfkeysvalueof{/tikz/circ path pars/l}}
  let \p1=($(\tikztostart)-(\tikztotarget)$),
   	\p2=($(\pgfkeysvalueof{/tikz/circ path pars/name}.east)-(\pgfkeysvalueof{/tikz/circ path pars/name}.west)$),
   	\n1={\pgfkeysvalueof{/tikz/circ path pars/pos}*veclen(\x1,\y1)-\x2},
 	\n2={(1-\pgfkeysvalueof{/tikz/circ path pars/pos})*veclen(\x1,\y1)-\x2} 
  in
  \ifdim\n1>0pt
 (\tikztostart) -- (\pgfkeysvalueof{/tikz/circ path pars/name})
 \fi
 \ifdim\n2>0pt
 (\pgfkeysvalueof{/tikz/circ path pars/name}) -- (\tikztotarget)
 \fi
}},
  circ path pars/.cd,
  size/.initial=10pt,
  name/.initial=cpc,
  pos/.initial=0.5,
  l/.initial=,}

\begin{document}
\begin{tikzpicture}
  \draw (0,0) -- (1.5cm-5pt,0) (1.5,0) circle(5pt) node {a} (1.5cm+5pt,0) -- (3,0);
  \draw (0,1) to[circ path={l=a}] ++(3,0);
  \draw (0,2) to[circ path={l=a,pos=0.95}] ++(3,0);
  \draw (0,3) to[circ path={l=a,pos=0.05}] ++(3,0);
  \draw (0,4) to[circ path={l=b,name=p1}] ++ (3,-0.5);
  \draw (p1) to[circ path={l=c,pos=0.8,name=p2}] (3,4);
  \draw (p2) to[circ path={l=d,pos=0.95,name=p3}] ++ (2,2);
\end{tikzpicture}
\end{document}
```

![Screen Shot 2020-07-20 at 6.53.14 AM.png](/image?hash=ef094862d4da2f4929d5cac588708a2fa24ca41c3afec061cebafbf959612985)
Answer #3
CarLaTeX
You could fill the node:


```
\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw (0,0) -- node[circle, fill=white, draw, inner sep=1.2pt]{a} (3,0);
\end{tikzpicture}
\end{document}
```

![2020-02-04 (2).png](/image?hash=ab1e916a083a500f3634216f3144dff8e48988e0a72f7ae6c8a27a4317c3e9f3)
Answer #4
निरंजन
```
\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (3,0) -- (6,0) -- (9,0) ;
\draw[fill=white] (0,0) circle[radius=5pt] node{a};
\draw[fill=white] (3,0) circle[radius=5pt] node{a};
\draw[fill=white] (6,0) circle[radius=5pt] node{a};
\draw[fill=white] (9,0) circle[radius=5pt] node{a};
\end{tikzpicture}
\end{document}
```

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.