Cylinder Question about LaTeX (Evgeny.Makarov)

In summary, Evgeny.Makarov tried using \filldraw with the arc command to round and shade the circular sides but it wasn't going so well.
  • #1
Dustinsfl
2,281
5
I can't seem to make a cylinder that is circular on the yz axis and runs length wise down the x.
Evgeny.Makarov do you know how to accomplish this?

I tried using \filldraw with the arc command to round and shade the circular sides but it wasn't going so well.
 
Physics news on Phys.org
  • #2
Re: cylinder (Evgeny.Makarov)

Code:
\usetikzlibrary{arrows}
\begin{tikzpicture}[>=stealth']
\newcommand{\rx}{.5cm}
\newcommand{\ry}{1.5cm}
\filldraw[right color=gray!70,left color=white,middle color=gray!30,shading=axis,opacity=1] (6,0) circle ({\rx} and \ry);
\filldraw[top color=gray!70!black,bottom color=gray!70!black,middle color=gray!30,shading=axis,opacity=1] (0,-\ry) -- (6,-\ry) arc (-90:-270:{\rx} and \ry) -- (0,\ry) arc (90:270:{\rx} and \ry);
\draw[dashed] (0,-\ry) arc (-90:90:{\rx} and \ry);

\draw[dashed] (0,0) -- (6,0); \draw[->] (6,0) -- (7.5,0) node[below] {$x$};
\draw[dashed] (0,0) -- (0,\ry); \draw[->] (0,\ry) -- (0,\ry+1cm) node[left] {$z$};
\draw[dashed] (0,0) -- (\ry,\ry); \draw[->] (\ry,\ry) -- (\ry+.5cm,\ry+.5cm) node[below right] {$y$};
\end{tikzpicture}

gives this.

View attachment 638

(Used code from StackExchange.)
 

Attachments

  • cylinder.png
    cylinder.png
    4.9 KB · Views: 68
  • #3
Re: cylinder (Evgeny.Makarov)

Evgeny.Makarov said:
Code:
\usetikzlibrary{arrows}
\begin{tikzpicture}[>=stealth']
\newcommand{\rx}{.5cm}
\newcommand{\ry}{1.5cm}
\filldraw[right color=gray!70,left color=white,middle color=gray!30,shading=axis,opacity=1] (6,0) circle ({\rx} and \ry);
\filldraw[top color=gray!70!black,bottom color=gray!70!black,middle color=gray!30,shading=axis,opacity=1] (0,-\ry) -- (6,-\ry) arc (-90:-270:{\rx} and \ry) -- (0,\ry) arc (90:270:{\rx} and \ry);
\draw[dashed] (0,-\ry) arc (-90:90:{\rx} and \ry);

\draw[dashed] (0,0) -- (6,0); \draw[->] (6,0) -- (7.5,0) node[below] {$x$};
\draw[dashed] (0,0) -- (0,\ry); \draw[->] (0,\ry) -- (0,\ry+1cm) node[left] {$z$};
\draw[dashed] (0,0) -- (\ry,\ry); \draw[->] (\ry,\ry) -- (\ry+.5cm,\ry+.5cm) node[below right] {$y$};
\end{tikzpicture}

gives this.

https://www.physicsforums.com/attachments/638

(Used code from StackExchange.)

I have seen that one but one you change $x$ to come out of the paper it doesn't translate well.
 

FAQ: Cylinder Question about LaTeX (Evgeny.Makarov)

What is LaTeX?

LaTeX is a typesetting language used for creating high-quality documents, particularly in the fields of mathematics, science, and technical writing.

What is the "Cylinder Question" in LaTeX?

The "Cylinder Question" refers to a common problem in LaTeX where the user is trying to typeset a cylinder shape but is having trouble with the formatting and equations.

Who created LaTeX?

LaTeX was created by Leslie Lamport in the 1980s as an extension of the typesetting language TeX, created by Donald Knuth.

Is LaTeX difficult to learn?

LaTeX can be challenging to learn for beginners, but with practice and familiarity, it can be a powerful tool for creating professional-looking documents.

Are there any alternatives to LaTeX?

Yes, there are other typesetting languages and software programs available, such as Microsoft Word and Adobe InDesign, but LaTeX is often preferred by scientists and academics for its precision and ability to handle complex equations and formatting.

Similar threads

Replies
3
Views
880
Replies
4
Views
2K
Replies
4
Views
4K
Replies
1
Views
3K
Replies
4
Views
4K
Replies
16
Views
2K
Replies
9
Views
2K
Back
Top