[Tex/LaTex] Package pgfkeys Error: The key ‘/tikz/opacity’ requires a value

pgfkeystikz-pgf

I'm drawing a diagram for a physical phenomenon, "motion in one dimension". I have this figure with a tikzpicture:

\documentclass{article}
\usepackage{tikz}

\definecolor{particle}{rgb}{1.0,0.7,0.3}

\begin{document}

\begin{figure}[h]
   \centering
   \begin{tikzpicture}
      \draw[help lines] (0,0) grid (8,2);
      \draw[thick] (0,0) -- (8,0);
      \node [right] at (8.25,0) {x (m)};
      \node [below] at (0,0) {-40};
      \node [below] at (1,0) {-30};
      \node [below] at (2,0) {-20};
      \node [below] at (3,0) {-10};
      \node [below] at (4,0) {0};
      \node [below] at (5,0) {10};
      \node [below] at (6,0) {20};
      \node [below] at (7,0) {30};
      \node [below] at (8,0) {40};
      \draw [draw=black, fill=particle, opacity=0.5]
         (1,0) rectangle (2,1);
      \draw [draw=black, fill=particle]
         (6,0) rectangle (7,1);
   \end{tikzpicture}
   \caption{Motion in one dimension} \label{fig:tbh1}
\end{figure}

\end{document}

Compiling with pdflatex, I get this error:

! Package pgfkeys Error: The key '/tikz/opacity' requires a value. I am going to ignore this key.

… on this line:

l.73 ...w [draw=black, fill=particle, opacity=0.5]

Didn't I specify a value for the opacity already? Why am I getting this error?

EDIT: Edited the code to be compilable.

Best Answer

Further investigation of the error led to the fact that when the line

\usepackage[turkish]{babel}

was omitted from the preamble, the code compiled just fine. (I didn't put this line into the code in the question, because, I thought it was irrelevant. Another lesson learned.)

To fix the issue, I added the line

\usetikzlibrary{babel}

to the preamble. It didn't work at first, but when I upgraded PGF/TikZ from 2.10 to 3.00, it did.

Related Question