1

How do you draw the following cylinders in latex using tikzpicture?

What I want to achieve

I have managed to learn how to draw rectangles, triangle and cuboid so far. However I have never drawn that involves circular sides.

Thank you.

8

Please include code showing what you've tried. There are also a lot of questions on this site about drawing cylinders, as well as examples in the TikZ manual.

For example, a few moments looking at the shapes.geometric library suggests something like this:

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
  \node (a) [cylinder, shape border rotate=90, draw, minimum height=15mm, minimum width=7.5mm] {};
  \draw [<->] ([xshift=5pt]a.before bottom) -- ([xshift=5pt]a.after top) node [midway, right] {$h$};
  \draw [<->] ([yshift=-5pt]a.bottom) -- ([yshift=-5pt]a.bottom -| a.before bottom) node [midway, below] {$r$};
\end{tikzpicture}
\end{document}

cylinder

2
  • How do you change the location of the cylinder in a more general Tikz picture? I can only manage to have it at (0,0) – Ander Biguri Jul 3 '18 at 13:44
  • 1
    @AnderBiguri Just place the \node wherever you want it. The other bits are relative to the node a, so a is the only one you need to explicitly put as you wish. – cfr Jul 3 '18 at 22:06

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.