【LaTeX】TikZサンプル集~応用編~

LaTeX

 前回

の続き。

 今回は、過去に本ブログで掲載した図のコード+αを紹介していく。

広告

サンプル1:ばねと小球

\begin{figure}[h]
\centering
\begin{tikzpicture}

\fill[black! 20](-4,-1) rectangle(-3,1);
\draw (-3,1) -- (-3,-1);

\draw (-3,0) -- (-2.8,0);
\draw[decorate,decoration={coil,amplitude=9pt}] (-2.8,0) -- (0,0);
\draw (-1.5,0.3) node[above] {$k$};

\draw (0.5,0) circle(0.5);
\draw (0.5,-1) node[above]{$M$};

\draw (3,0) circle(0.3);
\draw (3,-0.5) node[below]{$m$};

\draw[line width=2pt, -stealth] (3,0) -- (1.5,0);
\draw (2,0) node[above]{$-V$};

\end{tikzpicture}
\end{figure}

サンプル2:ばねに吊るされた棒とおもり

\begin{figure}[h]
\centering
\begin{tikzpicture}[thick]

\fill[black! 20](0,2) rectangle(6,2.5);
\draw (0,2)--(6,2);

\draw (2,2)--(2,1.9);
\draw[decorate,decoration={coil,amplitude=9pt}] (2,1.9) -- (2,-0.1);

\draw (0,-0.2) rectangle(6,-0.1);
\draw (2,-0.2) node[below]{O};
\draw (0,-0.1) node[above]{A};
\draw (6,-0.1) node[above]{B};

\draw (-0.6,-1.6) rectangle(0.6,-1);
\draw (0,-0.2)--(0,-1);

\draw (5.6,-1.6) rectangle(6.4,-1);
\draw (6,-0.2)--(6,-1);

\end{tikzpicture}
\end{figure}

 

\begin{figure}[h]
\centering
\begin{tikzpicture}[thick]

\fill[black! 20](0,2) rectangle(6,2.5);
\draw (0,2)--(6,2);

\draw (2,2)--(2,1.9);
\draw[decorate,decoration={coil,amplitude=9pt}] (2,1.9) -- (2,-0.1);

\draw (0,-0.2) rectangle(6,-0.1);
\draw (1.7,-0.15) node[above]{O};
\draw (-0.3,-0.1) node[above]{A};
\draw (6.3,-0.1) node[above]{B};

\draw (-0.6,-1.6) rectangle(0.6,-1);
\draw (0,-0.2)--(0,-1);

\draw (5.6,-1.6) rectangle(6.4,-1);
\draw (6,-0.2)--(6,-1);

\draw[dashed] (0,-3)--(0,2.4);
\draw[dashed] (2,-3)--(2,2.4);
\draw[dashed] (6,-3)--(6,2.4);

\draw (0,0.3)--(0.4,0.3)--(0.4,-0.1);
\draw (6,0.3)--(5.6,0.3)--(5.6,-0.1);

\draw[-latex,line width=2pt](0,-1.3)--(0,-2.5);
\draw (-0.5,-2.3) node{30N};

\draw[-latex,line width=2pt](2,-0.1)--(2,2);
\draw (3.5,1.5) node{$2.5\times10^{2}x$[N]};

\draw[-latex,line width=2pt](6,-1.3)--(6,-2.2);
\draw (6.5,-2.2) node{20N};

\draw (0,-0.2)to[out=-40,in=220](2,-0.2);
\draw (1,-0.6) node[fill=white] {$y$[m]};

\draw (2,-0.2)to[out=-20,in=200](6,-0.2);
\draw (4,-0.6) node[fill=white] {$1.0-y$[m]};

\end{tikzpicture}
\end{figure}

サンプル3:壁に立てかけられた棒

\begin{figure}[h]
\centering
\begin{tikzpicture}

\fill[black! 20](-1.5,-0.6) rectangle(3.12,0);
\fill[black! 20](2.52,0) rectangle(3.12,5);
\draw (-1.5,0)--(2.52,0)--(2.52,5);
\foreach \x in {-1.5,-1.0,...,2.0} \draw (\x,-0.6) -- (\x+0.5,0);

\draw[rotate=60](0,0) rectangle(5,0.3);

\filldraw[fill=white, draw=black] (0,0) -- (4mm,0mm) arc (0:60:4mm) -- cycle;
\draw (0.5,0.1) node[above]{$\theta$};

\draw (-0.5,0) node[above]{A};
\draw (2,4.4) node[above]{B};

\end{tikzpicture}
\end{figure}

 

\begin{figure}[h]
\centering
\begin{tikzpicture}

\fill[black! 20](-1.5,-0.6) rectangle(3.12,0);
\fill[black! 20](2.52,0) rectangle(3.12,5);
\draw (-1.5,0)--(2.52,0)--(2.52,5);
\foreach \x in {-1.5,-1.0,...,2.0} \draw (\x,-0.6) -- (\x+0.5,0);

\draw[rotate=60](0,0) rectangle(5,0.3);

\filldraw[fill=white, draw=black] (0,0) -- (4mm,0mm) arc (0:60:4mm) -- cycle;
\draw (0.5,0.1) node[above]{$\theta$};

\draw (-0.5,0) node[above]{A};
\draw (2,4.4) node[above]{B};

\draw[-latex,line width=2pt](2.52,4.32)--(1.17,4.32);
\draw (1.4,4.3) node[above left]{$T$};

\draw[-latex,line width=2pt](1.18,2.35)--(1.18,1);
\draw(1.18,1) node[below]{$mg$};

\draw[-latex,line width=2pt](0,0)--(0,1.35);
\draw(0.15,1.25) node[above]{$R$};

\draw[-latex,line width=2pt](0,0)--(1.35,0);
\draw(1.2,-0.1) node[fill=white,below]{$F$};

\draw(2.25,4.48) to[out=180,in=120] (-0.27,0.15);
\draw (0,3.2) node[fill=white] {$L$};

\draw(1.03,2.4) to[out=180,in=120] (-0.27,0.15);
\draw (0.4,2.3) node[fill=white]{$\displaystyle{\frac{L}{2}}$};

\end{tikzpicture}
\end{figure}

 

\begin{figure}[h]
\centering
\begin{tikzpicture}

\fill[black! 20](-1.5,-0.6) rectangle(3.12,0);
\fill[black! 20](2.52,0) rectangle(3.12,5);
\draw (-1.5,0)--(2.52,0)--(2.52,5);
\foreach \x in {-1.5,-1.0,...,2.0} \draw (\x,-0.6) -- (\x+0.5,0);

\draw[rotate=60](0,0) rectangle(5,0.3);

\filldraw[fill=white, draw=black] (0,0) -- (4mm,0mm) arc (0:60:4mm) -- cycle;
\draw (0.5,0.1) node[above]{$\theta$};

\draw (-0.5,0) node[above]{A};
\draw (2,4.4) node[above]{B};

\draw[dashed] (1.18,-0.5)--(1.18,4.7);
\draw[dashed] (-1.05,4.3)--(3,4.3);
\draw (0,0)--(0,4.3);

\draw (0.9,0)--(0.9,0.28)--(1.18,0.28);
\draw (0.28,4.3)--(0.28,4.02)--(0,4.02);

\draw[-latex,line width=2pt](2.52,4.32)--(1.17,4.32);
\draw (1.7,4.4) node[above left]{$T$};

\draw[-latex,line width=2pt](1.18,2.35)--(1.18,1);
\draw(1.2,0.8) node[above right]{$mg$};

\draw (0,0) to[bend left] (0,4.3);
\draw (-0.1,2.15) node[fill=white,left]{$\displaystyle{L\sin\theta}$};

\draw (0,0) to [out=-40,in=220] (1.18,0);
\draw (0.59,-0.21) to[bend right] (1.5,-1.1);
\draw (1.5,-1.2) node[fill=white, right]{$\displaystyle{\frac{L}{2}\cos\theta}$};

\end{tikzpicture}
\end{figure}

 

\begin{figure}[h]
\centering
\begin{tikzpicture}

\fill[black! 20](-1.5,-0.6) rectangle(3.12,0);
\fill[black! 20](2.52,0) rectangle(3.12,5);
\draw (-1.5,0)--(2.52,0)--(2.52,5);
\foreach \x in {-1.5,-1.0,...,2.0} \draw (\x,-0.6) -- (\x+0.5,0);

\draw[rotate=60](0,0) rectangle(5,0.3);

\filldraw[fill=white, draw=black] (0,0) -- (4mm,0mm) arc (0:60:4mm) -- cycle;
\draw (0.5,0.1) node[above]{$\theta$};

\draw (-0.5,0) node[above]{A};
\draw (2,4.4) node[above]{B};

\draw[-latex,line width=2pt](2.52,4.32)--(1.17,4.32);
\draw (1.4,4.3) node[above left]{$T'$};

\draw[-latex,line width=2pt](1.93,3.65)--(1.93,1.5);
\draw(1.93,1.5) node[below]{$Mg$};

\draw[-latex,line width=2pt](1.18,2.35)--(1.18,1);
\draw(1.18,1) node[below]{$mg$};

\draw[-latex,line width=2pt](0,0)--(0,3.5);
\draw(-0.1,3.5) node[above]{$R'$};

\draw[-latex,line width=2pt](0,0)--(1.35,0);
\draw(1.2,-0.1) node[fill=white,below]{$F'$};

\draw(2.25,4.48) to[out=180,in=120] (-0.27,0.15);
\draw (0.5,3.8) node[fill=white] {$L$};

\draw(1.78,3.7) to[out=180,in=120] (-0.27,0.15);
\draw (0.5,3.2) node[fill=white] {$l$};

\draw(1.03,2.4) to[out=180,in=120] (-0.27,0.15);
\draw (0.4,2.27) node[fill=white] {$\displaystyle{\frac{L}{2}}$};

\end{tikzpicture}
\end{figure}

 

\begin{figure}[h]
\centering
\begin{tikzpicture}

\fill[black! 20](-1.5,-0.6) rectangle(3.12,0);
\fill[black! 20](2.52,0) rectangle(3.12,5);
\draw (-1.5,0)--(2.52,0)--(2.52,5);
\foreach \x in {-1.5,-1.0,...,2.0} \draw (\x,-0.6) -- (\x+0.5,0);

\draw[rotate=60](0,0) rectangle(5,0.3);

\filldraw[fill=white, draw=black] (0,0) -- (4mm,0mm) arc (0:60:4mm) -- cycle;
\draw (0.5,0.1) node[above]{$\theta$};

\draw (-0.5,0) node[above]{A};
\draw (2.2,4.4) node[above]{B};

\draw[dashed] (1.93,-0.5)--(1.93,4.7);
\draw[dashed] (-1.05,4.3)--(3,4.3);
\draw[dashed] (1.18,-0.5)--(1.18,4.6);
\draw (0,0)--(0,4.3);

\draw (0.9,0)--(0.9,0.28)--(1.18,0.28);
\draw (1.65,0)--(1.65,0.28)--(1.93,0.28);
\draw (0.28,4.3)--(0.28,4.02)--(0,4.02);

\draw[-latex,line width=2pt](2.52,4.32)--(1.17,4.32);
\draw (1.8,4.4) node[above left]{$T'$};

\draw[-latex,line width=2pt](1.93,3.65)--(1.93,1.5);
\draw(2.45,1.8) node[below,fill=white]{$Mg$};

\draw[-latex,line width=2pt](1.18,2.35)--(1.18,1);
\draw(1.15,0.7) node[above right]{$mg$};

\draw (0,0) to[bend left] (0,4.3);
\draw (-0.1,2.15) node[fill=white,left]{$\displaystyle{L\sin\theta}$};

\draw (0,0) to [out=-40,in=220] (1.18,0);
\draw (0.59,-0.21) to[bend right] (1.5,-1.1);
\draw (1.5,-1.2) node[fill=white, right]{$\displaystyle{\frac{L}{2}\cos\theta}$};

\draw (0,0) to [out=-40,in=220] (1.93,0);
\draw (1.5,-0.24) to[bend right] (3.5,-0.5);
\draw (3.5,-0.5) node[fill=white, right]{$\displaystyle{l\cos\theta}$};

\end{tikzpicture}
\end{figure}

サンプル4:円柱に立てかけられた棒

\begin{figure}[h]
\centering
\begin{tikzpicture}[x=60pt,y=60pt,thick]

\fill [black! 20](-3,-0.4) rectangle(0.5,-0.08);
\draw (-3,-0.08)--(0.5,-0.08);
\foreach \x in {-3,-2.75,...,0.25} \draw (\x,-0.4) -- (\x+0.25,-0.08);

\filldraw[fill=white, draw=black] (-1.48,-0.08) -- (-0.48,-0.08) arc (0:180:1) -- cycle;

\draw [-latex] (-1.48,0.3)--(-1.48,-0.08);
\draw [-latex] (-1.48,0.5)--(-1.48,0.92);
\draw (-1.48,0.4) node{$r$};

\draw[rotate=135](0,0) rectangle(2,0.1);

\filldraw[fill=white, draw=black] (-0.06,-0.08) -- (-0.26,-0.08) arc (180:135:0.2) -- cycle;
\draw [-latex] (-0.41,-0.6)--(-0.41,-0.01)--(-0.25,-0.01);
\draw (-0.35,-0.6) node[below]{45°};

\draw [-latex] (-0.07,-0.6)--(-0.07,-0.08);
\draw (-0.07,-0.6) node[below]{O};

\end{tikzpicture}
\end{figure}

 

\begin{figure}[h]
\centering
\begin{tikzpicture}[x=100pt,y=100pt,thick]

\fill [black! 20](-1.75,-0.3) rectangle(0.25,-0.08);
\draw (-1.75,-0.08)--(0.25,-0.08);
\foreach \x in {-1.75,-1.5,...,0} \draw (\x,-0.3) -- (\x+0.25,-0.08);

\draw (-1.48,-0.08) -- (-0.48,-0.08) arc (0:100:1);

\draw[rotate=135](0,0) rectangle(1.5,0.1);
\draw (0,-0.1) node[below,fill=white]{O};

\draw (-0.06,-0.08) -- (-0.21,-0.08) arc (180:135:0.15)--cycle;
\draw (-0.3,-0.4)--(-0.3,-0.04)--(-0.2,-0.04);
\draw (-0.25,-0.4) node[below,fill=white]{45°};

\draw (-1.48,-0.08)--(-1.48+cos{45},-0.08+sin{45});
\draw (-1.18,-0.08) -- (-1.33,-0.08) arc (0:45:0.15);
\draw (-1.35,0) node[right]{45°};
\draw (-1.48,-0.08)to[out=90,in=180](-1.48+cos{45},-0.08+sin{45}); 
\draw (-1.2,0.5) node[fill=white]{$r$[m]};
\draw (-1.35+0.81*cos{45},-0.08+0.81*sin{45})--(-1.35+0.91*cos{45},-0.08+0.91*sin{45});
\draw (0.81*cos{135}-0.2,0.81*sin{135}-0.08)--(0.91*cos{135}-0.2,0.91*sin{135}-0.08);

\draw [-latex,line width=2pt](-1.48+cos{45},-0.08+sin{45})--(-1.48+1.5*cos{45},-0.08+1.5*sin{45});
\draw (-1.5+1.5*cos{45},-0.11+1.5*sin{45}) node[above right]{$T$[N]};
\draw [-latex,line width=2pt](-1.48+cos{45},-0.08+sin{45})--(-1.48+1.5*cos{45},-0.08+sin{45});
\draw [-latex,line width=2pt](-1.48+cos{45},-0.08+sin{45})--(-1.48+cos{45},-0.08+1.5*sin{45});
\draw [dashed](-0.78,0.975)--(-0.42,0.975);
\draw [dashed](-0.42,0.63)--(-0.42,0.98);
\draw (-1.18+cos{45},-0.08+sin{45}) -- (-1.33+cos{45},-0.08+sin{45}) arc (0:45:0.15);
\draw (-1.35+cos{45},sin{45}) node[right]{45°};

\draw [-latex,line width=2pt](-0.56,0.5)--(-0.56,-0.25);
\draw (-0.6,-0.21) node[left,fill=white]{$mg$[N]};

\draw [-latex,line width=2pt](-0.08,-0.08)--(-0.08,0.85);
\draw (-0.05,0.85) node[above,fill=white]{$R$[N]};

\draw [-latex,line width=2pt](-0.08,-0.08)--(-0.08-0.5*cos{45},-0.08);
\draw (-0.1-0.5*cos{45},-0.4)--(-0.5*cos{45},-0.08);
\draw (-0.2-0.5*cos{45},-0.4) node[below,fill=white]{$F$[N]};

\draw (0,0)to[out=90,in=0](-0.52,0.52); 
\draw (-0.25,0.54) node[fill=white]{$\displaystyle{\frac{L}{2}}$[m]};

\draw (-0.08,-0.08)to[out=150,in=300](-1.48+cos{45},-0.08+sin{45}); 
\draw (-0.38,0.08) node[fill=white]{$r$[m]};

\end{tikzpicture}
\end{figure}

 

\begin{figure}[h]
\centering
\begin{tikzpicture}[x=100pt,y=100pt,thick]

\fill [black! 20](-1.75,-0.3) rectangle(0.25,-0.08);
\draw (-1.75,-0.08)--(0.25,-0.08);
\foreach \x in {-1.75,-1.5,...,0} \draw (\x,-0.3) -- (\x+0.25,-0.08);

\draw (-1.48,-0.08) -- (-0.48,-0.08) arc (0:100:1);

\draw[rotate=135](0,0) rectangle(1.5,0.1);
\draw (0,-0.1) node[below,fill=white]{O};

\draw (-0.06,-0.08) -- (-0.21,-0.08) arc (180:135:0.15)--cycle;
\draw (-0.12,0) node[left]{45°};

\draw [dashed, rotate=45](-1.47,0.99)--(0.62,0.99);
\draw (-1.48,-0.08)--(-1.48+cos{45},-0.08+sin{45});
\draw (-1.18,-0.08) -- (-1.33,-0.08) arc (0:45:0.15);
\draw (-1.35,0) node[right]{45°};
\draw (-1.35+0.81*cos{45},-0.08+0.81*sin{45})--(-1.35+0.91*cos{45},-0.08+0.91*sin{45});
\draw (0.81*cos{135}-0.2,0.81*sin{135}-0.08)--(0.91*cos{135}-0.2,0.91*sin{135}-0.08);

\draw [-latex,line width=2pt](-1.48+cos{45},-0.08+sin{45})--(-1.48+1.5*cos{45},-0.08+1.5*sin{45});
\draw (-1.5+1.5*cos{45},-0.25+1.5*sin{45}) node[above right]{$T$[N]};

\draw [dashed](-0.56,-0.42)--(-0.56,1.02);
\draw [-latex,line width=2pt](-0.56,0.5)--(-0.56,-0.25);
\draw (-0.6,-0.21) node[left,fill=white]{$mg$[N]};
\draw (-0.56,0.02)--(-0.46,0.02)--(-0.46,-0.08);

\draw (-0.08,-0.08)to[out=45,in=45](-1.48+cos{45},-0.08+sin{45}); 
\draw (-0.25,0.5) node[fill=white]{$r$[m]};

\draw (-0.063,-0.08)to[out=220,in=-40](-0.56,-0.08);
\draw (-0.2,-0.15)to[out=270,in=180](0,-0.45); 
\draw (0,-0.45) node[right]{$\displaystyle{\frac{L}{2}\cos45°}$[m]};

\end{tikzpicture}
\end{figure}

サンプル5:静止摩擦力・最大摩擦力・動摩擦力

\begin{figure}[h]
\centering
\begin{tikzpicture}[x=70pt,y=70pt,thick]

\draw (-1.1,0)rectangle(-0.4,0.5);
\fill [black! 20](-1.5,-0.3) rectangle(0,0);
\draw (-1.5,0)--(0,0);
\foreach \x in {-1.5,-1.25,...,-0.25} \draw (\x,-0.3) -- (\x+0.25,0);
\draw (-1.1,0.8) node[above]{静止摩擦力$f$};
\draw (-1.1,0.65) node{静止している};
\draw [-latex,line width=2pt](-1.1,0.25)--(-1.5,0.25);
\draw (-1.5,0.25) node[above right]{$F_{外力}$};
\draw [-latex,line width=2pt](-0.75,0)--(-0.35,0);
\draw (-0.35,-0.05) node[below left,fill=white]{$f$};
\draw (-0.75,-0.4)node[below]{$f=F_{外力}$};

\draw [-stealth,line width=3pt](0.1,0.25)--(0.6,0.25);
\draw (0.35,0.2)node[below]{$F_{外力}$増};

\draw (1.4,0)rectangle(2.1,0.5);
\fill [black! 20](1,-0.3) rectangle(2.5,0);
\draw (1,0)--(2.5,0);
\foreach \x in {1,1.25,...,2.25} \draw (\x,-0.3) -- (\x+0.25,0);
\draw (1.4,0.8) node[above]{最大摩擦力$f_{0}$};
\draw (1.4,0.65) node{滑り出す直前};
\draw [-latex,line width=2pt](1.4,0.25)--(0.8,0.25);
\draw (0.8,0.25) node[above right]{$F_{外力}$};
\draw [-latex,line width=2pt](1.75,0)--(2.35,0);
\draw (2.35,-0.05) node[below left,fill=white]{$f_{0}$};
\draw (1.75,-0.4)node[below]{$f_{0}=\mu_{0}N_{0}=F_{外力}$};

\draw [-stealth,line width=3pt](2.6,0.25)--(3.1,0.25);
\draw (2.85,0.2)node[below]{$F_{外力}$増};

\draw (3.9,0)rectangle(4.6,0.5);
\fill [black! 20](3.5,-0.3) rectangle(5,0);
\draw (3.5,0)--(5,0);
\foreach \x in {3.5,3.75,...,4.75} \draw (\x,-0.3) -- (\x+0.25,0);
\draw (3.9,0.8) node[above]{動摩擦力$f'$};
\draw [-stealth,line width=3pt](4,0.65)--(3.5,0.65);
\draw (4,0.65)node[right]{この方向に運動};
\draw [-latex,line width=2pt](3.9,0.25)--(3.2,0.25);
\draw (3.2,0.25) node[above right]{$F_{外力}$};
\draw [-latex,line width=2pt](4.25,0)--(4.7,0);
\draw (4.7,-0.05) node[below left,fill=white]{$f'$};
\draw (4.25,-0.4)node[below]{$f'=\mu'N_{0}<F_{外力}$};
\draw (4.25,-0.6)node[below]{($\mu'$:動摩擦係数)};

\end{tikzpicture}
\end{figure}
広告

終わりに

 サンプル公開にあたり、過去に描いたLaTeX文書を引っ張り出してみたが、自分でもよく描いたと思う。

 これExcelでも良いんじゃね?というレベルである。

 もうこのレベルの図をTikZで描くことはないだろうが、何かしら新しいスキルや技を習得したら記事にしようと思う。

 

 END

広告

コメント

タイトルとURLをコピーしました