我是 TikZ 新手,也是 LaTeX 新手。因此,使用 TikZ 绘制此图时遇到了困难。
这是我的尝试:
\documentclass[12pt]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[help lines] (0,0) grid (6,6);
\draw (2,3.0) circle (0.5);
\draw (2,1) -- (2,2.5);
\draw (1.5,0)--(2,1.0);
\draw (2.5,0)--(2,1);
\draw (1,1.5)--(2,2);
\draw (3,1.5)--(2,2);
\draw (2.5,3.5) circle (0.1);
\draw (2.75,3.75) circle (0.15);
\draw (2,4) rectangle (6,6);
\node at (4,5) {So it has come to this.};
\end{tikzpicture}
\end{document}
答案1
也许您想要如下所示的蓝色线条和无衬线字体:
\documentclass[12pt]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[thick]
\draw[help lines] (0,0) grid (6,6);
\draw (2,3.0) circle (0.5);
\draw (2,1) -- (2,2.5);
\draw (1.5,0)--(2,1.0);
\draw (2.5,0)--(2,1);
\draw (1,1.5)--(2,2);
\draw (3,1.5)--(2,2);
\draw[blue] (2.5,3.5) circle (0.1);
\draw[blue] (2.75,3.75) circle (0.15);
\draw[blue] (2,4) rectangle (6,6) ;
\node[font=\sffamily] at (4,5) {So it has come to this.};
\end{tikzpicture}
\end{document}
答案2
对于矩形中的居中文本,不需要定义新的坐标。请参阅下面的 MWE:
\documentclass[12pt]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[font=\sffamily]
\draw[help lines] (0,0) grid (6,6);
\draw (2,3.0) circle (0.5);
\draw (2,1) -- (2,2.5);
\draw (1.5,0)--(2,1.0) -- (2.5,0);
%\draw (2.5,0)--(2,1);
\draw (1,1.5)--(2,2) -- (3,1.5);
%\draw (3,1.5)--(2,2);
\draw (2.5,3.5) circle (0.1);
\draw (2.75,3.75) circle (0.15);
\draw (2,4) rectangle (6,6)
node[midway]% this will put text in the middle of rectangle
{So it has come to this.};
\end{tikzpicture}
\end{document}
在上面的代码中我还加入了“手”和“腿”线条的绘制。