我想用 tikz 制作一个表格 3D 图形。Tikz 运行良好,表格环境运行良好,但是当我将 tikz 图形放入表格环境时,编译会挂起。我做错了什么吗?
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tabular}{cc}
\begin{tikzpicture}[scale=1.,axis/.style={->,blue,thick},
/pgfplots/view={25}{25},
vector/.style={-stealth,red,very thick},
vector guide/.style={dashed,red,thick}]
\begin{axis}[
axis lines=center,
axis on top,
every inner z axis line/.append style={opacity=0},
xlabel={$x$}, ylabel={$y$}, zlabel={$z$},
domain=0:1,
y domain=0:2*pi,
xmin=-0.6, xmax=.6,
ymin=-0.6, ymax=1.5, zmin=0.0,zmax=2.5,ztick={1},
every axis x label/.style={at={(rel axis cs:0,0.5,0)},anchor=south},
every axis y label/.style={at={(rel axis cs:0.5,0,0)},anchor=north},
every axis z label/.style={at={(rel axis cs:0.5,0.5,0.9)},anchor=west},
samples=30]
\addplot3 [domain=0:360,samples y=1,name path=top,draw=none] ({1*cos(deg(x))},{1*sin(deg(x))},{1});
\path[name path=zline] (0,0,0) -- (0,0,1.5) coordinate(ztop);
\path[name intersections={of=top and zline,by={aux1}}];
\draw[-latex] (aux1) -- (ztop);
\end{axis}
\end{tikzpicture}
&a
\end{tabular}
\end{document}
答案1
将 documentclass 的选项更改为preview
。请参阅这里为什么。
将您的文档类从 切换standalone
到其他任何内容,例如article
,编译成功。
我没有发布完整的代码,因为唯一需要更改的是
\documentclass[preview]{standalone}
输出如下(我添加了边框只是为了突出显示表格):