or
निरंजन
tikz
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?
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)
CC BY-SA 4.0CarLaTeX
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)

निरंजन

\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}

CarLaTeX replying to निरंजन
I think the old syntax gave problems in some cases, but I'm not an expert. Maybe @marmot's knows the reason well.
निरंजन
Oh yes! How silly mistake I made. Thanks @CarLaTeX. Also @Skillmon I changed the MWE. Can you elaborate why a simpler syntax is changed to a complicated one? (Writing the radius directly in the parentheses seems to be simpler than writing radius=XXunits)
CarLaTeX replying to निरंजन
Yes, it can be done with \draw only :) Just change \filldraw into \draw and compile your minimal example, you can test it immediately
Skillmon
@निरंजन that is equivalent to \draw[fill=white] afaik. As an aside, note that the syntax circle (<radius>) is considered deprecated, the recommended syntax is circle[radius=<radius>].
निरंजन replying to CarLaTeX
I used filldraw because I needed multiple nodes on a line. Thus I made a code like in my answer to achieve it. Please check it and  tell me if it can be done using \draw.
CarLaTeX replying to निरंजन
\filldraw[XXX] is used to fill and draw a path with the same color, it is an abbreviation of \draw[filll=XXX, draw=XXX], where XXX=your color
CarLaTeX
With \draw[fill=white] (0,0) circle (12pt); you'll get the same tesult.
CarLaTeX replying to निरंजन
I think you don't need \filldraw, in this case.
Skillmon replying to निरंजन
If you feel like it has value for future visitors you should.
निरंजन
Shall I add this as an answer for the future readers?
निरंजन
Both of the solutions worked great, but I later realized that I want a line with multiple points like these. On LaTeX wikibook I learnt about \filldraw which also worked great. So I drew a line first and then added multiple \filldraw[fill=white] (0,0) circle (12pt). (It's my fault that in the course of minimization of the code I missed the fact that I need multiple points on the line :P)
Skillmon
Just to make it clear, my solution is *not* opaque, it just doesn't draw the line inside the circle!
निरंजन
Thanks.
CarLaTeX
@निरंजन Welcome on Top TeX!