处理 TikZ 错误“扫描 \tikz@cc@parse@factor 的使用时结束”。

处理 TikZ 错误“扫描 \tikz@cc@parse@factor 的使用时结束”。

抱歉,如果标题没有说明太多内容,我会尝试根据答案进行编辑。

很久以前,我使用 TikZ 画了一些图形。现在,当我尝试在论文中包含 TikZ 代码的逐字片段时,我遇到了一个奇怪的问题,我的代码在原始文件中编译时运行正常(即使删除了所有辅助文件),但当我将其提取到单独的 tex 文件中时,我收到了错误消息

扫描使用 \tikz@cc@parse@factor 时文件结束。

你能帮我找出问题出在哪里吗

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,quotes,angles}

 \begin{document}

\begin{tikzpicture}[scale=0.3,font=\scriptsize] % O B L I Q U E9
  % Set coordinates of the parallelogram generated by omega_1 and omega_2
 \coordinate (A) at (0,0);
 \coordinate (B) at (0:3); %Omega_1
 \coordinate (D) at (70:2); %Omega_2
 \coordinate (C) at ($(B) +(D)$);
 %Lattice creation using foreach loop
\foreach \a in { − 1, − 0,...,2.1}
\foreach \b in { − 1, − 0,...,2.1}
\shade [ball color = gray] ($\a∗(B) + \b∗(D)$) circle[radius=7pt];
%
% Draw the generators of the lattice omega_1 and omega_2 with their nods
\draw[thick,>=stealth, − >] (0,0) −− (B) node[midway,below,sloped] {$\omega_1$};
\draw[thick,>=stealth, − >] (0,0) −− (D) node[midway,above,sloped] {$\omega_2$};
% Draw fundamental parallelogram
\draw (A) −− (B) −− (C) −− (D) −− cycle;
% Drow the angle phi
\draw pic["$\varphi$",draw,angle eccentricity=1.6,angle radius=3mm] {angle=B −− A −− D};
% Show the type of lattice with the green like color
\draw[dashed,thick, fill =green!30!yellow, fill opacity=0.2] (A) −− (B) −− (C) −− (D) −− cycle;
% The caption
\node [below=1cm, align= flush center] at ($(1, − 1.5)$) {1. Oblique\\$|\omega_1| \neq |\omega_2|$, and $\varphi \neq \frac{\pi}{2}$};
\end{tikzpicture}

\end{document}

答案1

有两个问题。主要问题是您在代码中使用了非标准字符。我使用以下方法检测并删除了它们此在线服务。那么在角度构造中不能有空格,即您需要使用angle=B--A--D而不是angle=B-- A --D。修复后的代码是

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{calc,quotes,angles}
\begin{document}
\begin{tikzpicture}[scale=0.3,font=\scriptsize] % O B L I Q U E9
 % Set coordinates of the parallelogram generated by omega_1 and omega_2
 \coordinate (A) at (0,0);
 \coordinate (B) at (0:3); %Omega_1
 \coordinate (D) at (70:2); %Omega_2
 \coordinate (C) at ($(B) +(D)$);
 %Lattice creation using foreach loop
\foreach \a in {-1,0,...,2.1}
{\foreach \b in {-1,0,...,2.1}
{
\shade [ball color = gray] ($\a*(B) + \b*(D)$) circle[radius=7pt];}}
% %
% % Draw the generators of the lattice omega_1 and omega_2 with their nods
\draw[thick,-stealth] (0,0) -- (B) node[midway,below,sloped] {$\omega_1$};
\draw[thick,-stealth] (0,0) -- (D) node[midway,above,sloped] {$\omega_2$};
% Draw fundamental parallelogram
\draw (A) -- (B) -- (C) -- (D) -- cycle;
% Drow the angle phi
\draw pic["$\varphi$",draw,angle eccentricity=1.6,angle radius=3mm] 
{angle=B--A--D};
% Show the type of lattice with the green like color
\draw[dashed,thick, fill =green!30!yellow, fill opacity=0.2] (A) -- (B) -- (C)
-- (D) -- cycle;
% The caption
\node [below=1cm, align= flush center] at ($(1, - 1.5)$) {1. Oblique\\$|\omega_1| \neq |\omega_2|$, and $\varphi \neq \frac{\pi}{2}$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容