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.

Will Kim
  • 2,032

1 Answers1

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

cfr
  • 198,882
  • 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 03 '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 03 '18 at 22:06