I do some calculations in my LaTeX document with sage. I want to include the results and do some comparisons. But to do that with \ifthenelse command, I need the value which is saved in the sage file.
How can I get the result or is there another way to compare values from sagetex with an ifthenelse command?
\documentclass{article}
\usepackage{sagetex}
\usepackage{ifthen}
\begin{document}
\begin{sagesilent}
var('x')
f = x^2
\end{sagesilent}
$\ifthenelse{\sage{f(2)}>0}{a}{b}$
\end{document}

outputas empty withoutput = r"",right? And therstands what for? And i also don't understand the expression%s>%s. – typ42 Sep 16 '15 at 22:45ris for "raw" string. LaTeX has lots of characters such as \ that cause a problem if inserted in a string without therbefore it. See here, for example. The%sindicates data is to be put there in the form of a string. %f is float, and %d for decimal. Less common alternative are given here. Your conditional was f(2)>0. Those two values are given at the end of the string. The first value, f(2) gets substituted in for %s and the second value, 0, is substituted for the second %s. – DJP Sep 17 '15 at 00:23sagetex: do the logic at the Sage/Python level. The\sagemacro pulls in its value using LaTeX's\labeland\refmechanism, so if you do really want to useifthenelse, you'd have to figure out how to "dereference" the\ref, which I think is possible but requires TeX wizardry that I don't understand. The corresponding Python "wizardry" isn't wizardry at all. :) – Dan Drake Sep 17 '15 at 00:50