I'm writing a (supposedly) simple financial tracking program using tikz and the fp package.
Within a tabular environment I compute a value using \pgfmathparse{adding some numbers}\pgfmathresult. The trouble comes when I attempt to access the value of \pgfmathresult outside the tabular environment.
I know that I can use pgfmathsetmacro to assign the value of \pgfmathresult, but the macro is only defined locally, i.e. within the same cell where it was defined. How can I define the macro to be global? Here is an MWE:
\documentclass{article}
\usepackage{tikz}
\usepackage{etoolbox}
\usepackage[landscape]{geometry}
\usepackage{fp}
\usetikzlibrary{decorations.text,fixedpointarithmetic}
\newcommand{\compute}[1]{%
\pgfmathparse{#1}%
\pgfmathprintnumber{\pgfmathresult}
}%
\begin{document}
\pgfkeys{/pgf/fixed point arithmetic}
\pgfkeys{/pgf/number format/.cd,fixed,fixed zerofill,precision=2}
\begin{tabular}{c}
\compute{1.3+7.5} \gdef\mySum{\pgfmathresult}
\end{tabular}
This line should just print the value: \mySum %But I'm told \mysum is undefined
This line should use mySum in a calculation: \pgfmathparse{2*\mySum}\pgfmathresult %Same error
This line should plot a point using mySum: \tikz\draw (0,0) circle (\mySum); %Same error
\end{document}
I have tried variations of the definition of \mySum shown above that used \edef, \xdef, or \let, and tried various placements of \expandafter, all to no avail. I keep thinking this should be fairly simple....