# Calling pgf rand inside pgfmathsetmacro creates extra text

by iluvatar   Last Updated January 14, 2018 04:23 AM

I am using pgf and tikz for some latex questions. The code below illustrates a problem I am facing: when I use the rand function from pgf inside a pgfmathsetmacro I get some extra text at the beginning of the example text (in my case, I get Y1Y1). If I remove the call to rand then I do not get that extra text, but or course I do not get random values. I have read the docs but haven't found yet a clue. What I am doing wrong? Thanks in advance.

\documentclass{article}

\usepackage{pgfmath}
\usepackage{tikz}
\usepgflibrary{fpu}
\pgfkeys{/pgf/fpu}

\begin{document}
\pgfmathsetseed{1}
\pgfmathsetmacro{\FACTOR}{0.9}
%\pgfmathsetmacro{\QA}{9.0*(1 + \FACTOR*3)}
\pgfmathsetmacro{\QA}{9.0*(1 + \FACTOR*rand} % generates spurious Y1Y1 or similar text
TEST-TEXT \pgfmathparse{3*\QA}\pgfmathprintnumber{\pgfmathresult}
\end{document}
Tags :

## Gaussian random numbers

Updated July 14, 2017 12:23 PM