我有以下 tikz 图。
\begin{tikzpicture}
\draw[thick]
(0.075,0)--(0.825,0);
\draw[thick]
(0.975,0)--(1.725,0);
\draw[thick]
(0.9,0.075)--(0.9,0.925);\draw[thick](0,0.075)--(0,0.925);\draw[thick](0.075,1)--(0.825,1);\draw[thick](0.975,1)--(1.725,1);\draw[thick]
(1.8,0.075)--(1.8,0.925);\draw[thick](1.875,0)--(2.625,0);\draw[thick](1.875,1)--(2.625,1);\draw[thick](2.7,0.075)--(2.7,0.925); \foreach \x in {.9,1.8} \draw[] (\x,0) circle(.075);\foreach \x in {.9,1.8} \draw[] (\x,1) circle(.075);\draw[thick]\draw[fill] (0,0) circle(0.075);\draw[fill] (2.7,0) circle(0.075);
\draw[fill] (0,1) circle(0.075);
\draw[fill] (2.7,1) circle(0.075);
\end{tikzpicture}
当我将这张图片放入新的 latex 文件中时,它正在编译。但是,当我将代码复制到预先存在的文件(我正在撰写的论文)中时,它不会编译。基本上,每次我尝试编译文档时,都会出现超时。
我该如何消除这些错误?可能出了什么问题?
答案1
您的代码中有一个不完整的宏,这将导致编译时出错或超时。如果您将其注释掉或删除,代码应该可以编译。整理代码将帮助您发现此类问题。
但是,由于我们不知道您要在哪个文件中使用上述代码,因此我们无法判断嵌入此代码是否会导致其他问题。这就是为什么您应该始终发布一个最小可编译这里举个例子。
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[thick] (0.075,0)--(0.825,0);
\draw[thick] (0.975,0)--(1.725,0);
\draw[thick] (0.9,0.075)--(0.9,0.925);
\draw[thick] (0,0.075)--(0,0.925);
\draw[thick] (0.075,1)--(0.825,1);
\draw[thick] (0.975,1)--(1.725,1);
\draw[thick] (1.8,0.075)--(1.8,0.925);
\draw[thick] (1.875,0)--(2.625,0);
\draw[thick] (1.875,1)--(2.625,1);
\draw[thick] (2.7,0.075)--(2.7,0.925);
\foreach \x in {.9,1.8}
\draw[] (\x,0) circle (.075);
\foreach \x in {.9,1.8}
\draw[] (\x,1) circle(.075);
% \draw[thick] <== incomplete line
\draw[fill] (0,0) circle(0.075);
\draw[fill] (2.7,0) circle(0.075);
\draw[fill] (0,1) circle(0.075);
\draw[fill] (2.7,1) circle(0.075);
\end{tikzpicture}
\end{document}