[Tex/LaTex] Draw crosses in tikz

tikz-pgf

If I do

\draw (1,1) circle (1pt)

tikz draw a little circle with diameter 1pt at (1,1).

How can I define a path cross such that

\draw (1,1) cross (1pt)

draws a little cross with diameter 1pt (adjustable in size just like the circle)?

Best Answer

cross command equivalent to circle doesn't exist in TiKZ but you can use a cross out node from shapes.misc library. This kind of node adds a cross over node's text, but it's easy to adapt it to do what you want.

\tikzset{cross/.style={cross out, draw, 
         minimum size=2*(#1-\pgflinewidth), 
         inner sep=0pt, outer sep=0pt}}

Because circle (1pt) draws a circle with radius=1pt, its total size will be 2pt, then cross node's size is defined with minimum size=2*(#1-\pgflinewidth) and inner and outer separations fixed to 0pt.

If cross angle is not what you want, you can change it with rotate option. Next you have some examples. I've also placed circles over them just to show that circle and crosses have equal size.

\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{shapes.misc}

\tikzset{cross/.style={cross out, draw=black, minimum size=2*(#1-\pgflinewidth), inner sep=0pt, outer sep=0pt},
%default radius will be 1pt. 
cross/.default={1pt}}

\begin{document}
\begin{tikzpicture}[]

\draw (0,0) circle (1pt);

\draw (.5,0) node[cross,rotate=10] {};
\draw (.5,0) circle (1pt);

\draw (0,.5) circle (1pt);
\draw (0,.5) node[cross,red] {};

\draw (.5,.5) node[cross,rotate=30] {};

\draw (0.25,.25) circle (2pt);
\draw (0.25,.25) node[cross=2pt,rotate=45,green]{};
\end{tikzpicture}
\end{document}

enter image description here