4

I read the page Define a variable in TikZ about how to define a variable in tikz, but I am trying to then put these values in a table and getting errors. It seems latex is not remembering the white space and treating both entries of the table as one.

It also seems to work fine when the variable is an integer.

Minimal example with error:

\def\xmin{-2};
\def\Kone{-1.826110508097425};
\addplot [fill, color=green,solid,forget plot, opacity=0.2]
  table[row sep=crcr]{
 \xmin+0    1\\  
  \Kone     1\\
 -1.826110508097425 0.6\\
  \xmin 0.6\\  
};

The error I get is

" Package pgfplots Error: Sorry, the requested column number '1' in table '' does not exist!? Please verify you used the correct index 0 <= i

Alternatively, if there is a better way round of drawing that filled area using the variables it would be helpful!

  • 1
    You need to put the macro involving entries of the table inside brace pair {} – percusse Dec 11 '14 at 12:48
  • @percusse perhaps you could turn your comment into an answer so OP can accept it? – nnunes Dec 11 '14 at 13:12
3

You need to put the macro involving entries inside a brace pair such as

\addplot [fill, color=green,solid,forget plot, opacity=0.2]
    table[row sep=crcr]{
     {\xmin+0} 1\\  
     {\Kone}   1\\
     -1.826110508097425 0.6\\
     {\xmin} 0.6\\  
};

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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