2

Sorry if title doesn't say much, I will try to edit it according to the answers.

A long time ago, I had drawn some figures using TikZ. Now as I try to include a verbatim snippet of the TikZ code in my thesis, I stumbled with a weird problem where my code works perfectly when compiled in the original file(even after deleting all the auxiliary files), but when I extracted it to a separate tex file, I got the error message

File ended while scanning use of \tikz@cc@parse@factor.

Can you help me please figuring out where is the problem

\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}
4
  • You have strange characters in your code that cannot be parsed. For instance, the star in \a∗(B) is such a character.
    – user121799
    Commented Dec 6, 2018 at 18:41
  • @marmot thank you very much for the answer. In fact, what I did is include the code in my thesis using listings package, then I copied the code from the generated pdf. I think something wrong happened in the process, also the additional spaces in the angle was added. Do you have any insight? Commented Dec 6, 2018 at 19:30
  • 1
    Unfortunately I do not. This depends AFAIK on the viewer and editor. For instance, my editor did not even want to copy your code, which allowed me to conclude that there are nonstandard characters in. I guess that would make a nice separate question.
    – user121799
    Commented Dec 6, 2018 at 19:38
  • @marmot Thank you anyways, I will when I find some time. For the record: for the editor, I am using texStudio and for the viewer, I used Sumatra PDF. Commented Dec 6, 2018 at 19:50

1 Answer 1

2

There are two issues. The main issue is that you use non-standard characters in your code. I detected and removed them using this online service. Then you cannot have spaces in the angle construction, i.e. you need to use angle=B--A--D instead of angle=B-- A --D. The repaired code is

\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}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .