TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm drawing a diagram for a physical phenomenon, "motion in one dimension". I have this figure with a 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);
   \caption{Motion in one dimension} \label{fig:tbh1}


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.

share|improve this question
Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Jubobs Aug 10 '14 at 18:32
I don't get an error with your code! It works as it should – clemens Aug 10 '14 at 18:40
@Jubobs: Thanks for the warm welcoming! I've edited the code to be compilable. – Berk Özbalcı Aug 10 '14 at 18:40
Hi welcome indeed. There shouldn't be a problem with the given code. Do you have another setting that is named particle somewhere? – percusse Aug 10 '14 at 18:41
Not relevant to the issue, but your x-axis labels should be in math mode, particularly as you've otherwise got - appearing as a hyphen not a minus sign. – Joseph Wright Aug 10 '14 at 18:55
up vote 3 down vote accepted

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


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


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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.