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)?


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}

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


\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]{};

enter image description here


Alternative solution using pic:



    cross/.pic = {
    \draw[rotate = 45] (-#1,0) -- (#1,0);
    \draw[rotate = 45] (0,-#1) -- (0, #1);



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

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

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

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

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


enter image description here

  • Notice that this solution always requires specification of the cross size. Is there anyone who knows how to modify this solution to add a default size? – Angelos Oct 15 '19 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.