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 Answers1

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\\  
};
percusse
  • 157,807