TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


    \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);

enter image description here

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

\draw[cylinder] (2,2); % this inserts the symbol at point (2,2)
share|improve this question
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
up vote 3 down vote accepted

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


    \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);

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


enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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