2

How can I do this in TikZ:
I want to draw a circular node with a sine curve in it to resemble the symbol of a short sine wave like in the diagram shown in the link below. I can draw a circle but I don't know how to put the sine curve inside. the diagram

  • Welcome to TeX.SX! On this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Questions that look like "Please do this complicated thing for me" tend to get closed because they are either "off topic", "too broad", or "unclear". Please try to make your question clear and simple by giving a minimal working example (MWE): you'll stand a greater chance of getting help. – user31729 Jul 29 '15 at 4:10
3

A simple way of doing this is with a path picture. Using some extra magic, the path picture can be set up so (-1,-1) is the lower left corner and (1,1) is the upper right corner of the picture. This makes it quite straightforward to specify path picture elements.

\documentclass[tikz,border=5]{standalone}
\tikzset{%
  do path picture/.style={%
    path picture={%
      \pgfpointdiff{\pgfpointanchor{path picture bounding box}{south west}}%
        {\pgfpointanchor{path picture bounding box}{north east}}%
      \pgfgetlastxy\x\y%
      \tikzset{x=\x/2,y=\y/2}%
      #1
    }
  },
  sin wave/.style={do path picture={    
    \draw [line cap=round] (-3/4,0)
      sin (-3/8,1/2) cos (0,0) sin (3/8,-1/2) cos (3/4,0);
  }},
  cross/.style={do path picture={    
    \draw [line cap=round] (-1,-1) -- (1,1) (-1,1) -- (1,-1);
  }},
  plus/.style={do path picture={    
    \draw [line cap=round] (-3/4,0) -- (3/4,0) (0,-3/4) -- (0,3/4);
  }}
}
\begin{document}
\begin{tikzpicture}[minimum size=0.75cm]
\node [circle, draw, sin wave] at (-1, 0) {};
\node [circle, draw, plus]     at ( 0, 0) {};
\node [circle, draw, cross]    at ( 1, 0) {};
\end{tikzpicture}
\end{document}

enter image description here

  • Thanks a lot. I have another problem,when using this command to generate a small node of circle, I find the changing of minimum size doesn't work. for example, the node of circle doesn't become smaller when I change the minimum size from 0.05 cm to 0.01 cm. \node[circle,draw=black,minimum size=0.05cm](W) at (0,0){}; – Lu Zhang Jul 29 '15 at 8:35
  • @LuZhang probably you need to add inner sep=0pt to the node options. This is by default set to .333ex (or maybe it's .333em) which - depending on the font - will make the node bigger than 0.05cm, even when it is empty. – Mark Wibrow Jul 29 '15 at 10:22
  • It really works. Thank you, but now I have another problem, I want to generate a node with |.| inside it and a node with ^2 inside it(These have been shown in the diagram of my question). I just type this in {}, but I don't get what I want. Could you please solve this puzzle for me? – Lu Zhang Jul 29 '15 at 11:58
3

You can put a sine curve as a tikz picture inside a node.

\begin{tikzpicture}
\node[draw,circle,inner sep=-0.4pt] at (0,0)
{\tikz \draw[scale=0.15,domain=-3.141:3.141,smooth,variable=\t]
plot (\t,{sin(\t r)});};
\end{tikzpicture}

enter image description here

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.