有人能帮我写出一个由圆柱体和半球体组成、装满液体至高度 h 的试管的乳胶代码吗?我正在尝试写一个关于试管体积问题的答案。我现在 7 年级(中学一年级)。谢谢!
答案1
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\fill[color=gray!30] (-0.75,-3) arc (180:0:0.75 and 0.2) -- (0.75,-5) arc (0:-180:0.75);
\fill[color=black!70] (0,-3) ellipse (0.75 and .2);
\draw[thick] (0.75,0) -- (0.75,-5) arc (0:-180:0.75) -- (-0.75,0);
\draw[thick] (0,0) ellipse (0.75 and 0.2);
\draw[thick, <->] (1.2,-3) -- (1.2,-5.75);
\node at (1.5,-4.375) {\(h\)};
\end{tikzpicture}
\hspace{1cm}
\begin{tikzpicture}
\fill[color=gray!30] (-0.75,-3) arc (180:0:0.75 and 0.2) -- (0.75,-5) arc (0:-180:0.75);
\fill[color=black!70] (0,-3) ellipse (0.75 and .2);
\draw[thick] (0.75,0) -- (0.75,-5) arc (0:-180:0.75) -- (-0.75,0);
\draw[thick] (0,0) ellipse (0.75 and 0.2);
\draw[thick, <->] (1.2,-3) -- (1.2,-5);
\node at (1.5,-4) {\(h\)};
\end{tikzpicture}
\end{document}
我从中复制了代码在倾斜的试管内抽取液体。