# How to draw and insert a symbol in TikZ

I want to make a symbol as shown below in TikZ.

\documentclass{standalone}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\draw[thick] (0,0) rectangle (3,1);
\draw[thick] (0.5,0) -- (0.5,1);
\draw[thick] (0.5,0.5) -- (3.5,0.5);
\draw[thick] (0.25,0) -- +(0,-0.3);
\draw[thick] (2.75,0) -- +(0,-0.3);
\end{tikzpicture}
\end{document}


I need to insert it (say cylinder) in TikZ codes, like so:

\draw[cylinder] (2,2); % this inserts the symbol at point (2,2)

-
Have you considered making an ordinary macro for this? \newcommand\cylinder[2]{...} then \cylinder{2}{2} –  John Wickerson May 23 '13 at 9:01
It might be worth to define a new shape in this case. Perhaps the makeshape will help you. –  Claudio Fiandrino May 23 '13 at 9:18

As suggested by John Wickerson, you can write the \cylinder macro:

\documentclass{standalone}
\usepackage{tikz}

\newcommand\cylinder[2][]{
\begin{scope}[shift={(#2)}]
\draw[#1] (0,0) rectangle (3,1);
\draw[#1] (0.5,0) -- (0.5,1);
\draw[#1] (0.5,0.5) -- (3.5,0.5);
\draw[#1] (0.25,0) -- +(0,-0.3);
\draw[#1] (2.75,0) -- +(0,-0.3);
\end{scope}
}

\begin{document}
\begin{tikzpicture}
\cylinder{0,0}
\cylinder[draw=blue,very thick]{2,2}
\coordinate (A) at (4,4);
\cylinder[draw=red,line width=5pt]{A}
\end{tikzpicture}
\end{document}


Result:

-