请问一下各位大佬,能给一个画正四面体的例子么?我找了一个画立方体的,可是按照着修改,很多错误。

2020-03-28 12:36发布

% !Mode:: TeX:UTF-8%確保文檔utf-8編碼\documentclass[tikz,border=2pt]{standalone} \begin{document}\begin{ti...

% !Mode:: “TeX:UTF-8”%確保文檔utf-8編碼
\documentclass[tikz,border=2pt]{standalone}

\begin{document}
\begin{tikzpicture}
%draw the axes
\draw[->] (0,0,0) — (3,0,0) node[anchor=west]{$x$};
\draw[->] (0,0,0) — (0,3,0) node[anchor=west]{$y$};
\draw[->] (0,0,0) — (0,0,3) node[anchor=west]{$z$};
%draw the top and bottom of the cube
\draw (0,0,0) — (0,2,0) — (2,2,0) — (2,0,0) — cycle;
\draw[] (0,0,2) — (0,2,2) — (2,2,2) — (2,0,2) — cycle;
%draw the edges of the cube
\draw[] (0,0,0) — (0,0,2);
\draw[] (0,2,0) — (0,2,2);
\draw[] (2,0,0) — (2,0,2);
\draw (2,2,0) — (2,2,2);
\end{tikzpicture}
\end{tikzpicture}

\end{document}

4条回答
frank.xin - frank.xin
2020-03-28 15:12
``` \documentclass[tikz,border=2pt]{standalone} \begin{document} \begin{tikzpicture} %draw the axes \draw[->] (0,0,0) -- (3,0,0) node[anchor=west]{$x$}; \draw[->] (0,0,0) -- (0,3,0) node[anchor=west]{$y$}; \draw[->] (0,0,0) -- (0,0,3) node[anchor=west]{$z$}; %draw the top and bottom of the cube \draw (0,0,0) -- (0,2,0) -- (2,2,0) -- (2,0,0) -- cycle; \draw[] (0,0,2) -- (0,2,2) -- (2,2,2) -- (2,0,2) -- cycle; %draw the edges of the cube \draw[] (0,0,0) -- (0,0,2); \draw[] (0,2,0) -- (0,2,2); \draw[] (2,0,0) -- (2,0,2); \draw (2,2,0) -- (2,2,2); \end{tikzpicture} \end{document} ``` 这样就可以了,主要是因为原来的符号问题,画线用 `--`,但是你复制过来的是 `—` 破折号,肯定不对,另外下面还多了一个 `\end{tikzpicture}`。编辑问题的时候代码用代码块包裹起来,不然会出现偏差。 ![](https://pics.latexstudio.net/data/images/202003/f66d47335c0eb1c.jpg)

一周热门 更多>