I want to pass parameters to a TikZ picture. The computation of the parameters is lengthy and done with sage. So I want to use both TikZ and sageTeX. Either the compilation enters an endless loop or I get non explicit errors messages: "\XC@define@color has an extra }".
Error messages:
\documentclass{article}
\usepackage{sagetex}
\usepackage{tikz}
\begin{document}
Begin sagesilent, \ldots
\begin{sagesilent}
x=2.1
y=3.1
\end{sagesilent}
After sagesilent:
print $\sage{x}$
print $\sage{y}$
\def \xf{\sage{x}}
\def \yf{\sage{y}}
we get \xf \, and \, \yf.
\begin{tikzpicture}
\coordinate (P) at (\xf,\yf);
\fill[black] (P) circle [radius=10pt];
\end{tikzpicture}
\end{document}
endless loop:
\documentclass{article}
\usepackage{sagetex}
\usepackage{tikz}
\begin{document}
Begin sagesilent, \ldots
\begin{sagesilent}
r=2.1
\end{sagesilent}
After sagesilent we print $\sage{r}$
\def \cr{\sage{r}}
and we get $r=\cr$.
\begin{tikzpicture}
\draw circle (\cr);
\end{tikzpicture}
\end{document}
The results are the same if I define the variable in the TikZ environnement or if I use \newcommand. It is also the same if I use an integer, 2 instead of 2.1. The new command seems to work in the text environnement but not in the graphic one.
minimalfor examples. It isn't suitable. Willarticleorstandalonework here? – cfr Sep 13 '16 at 23:07\def, I think. It gives you no warning when you overwrite TeX's definition of\cr, for example. – cfr Sep 14 '16 at 00:25\cris mad, frankly. And it will mess up a good manytikzpictures, apart from anything else. – cfr Sep 14 '16 at 16:47