I'm using pgfmath in my code since I need some randomness and I want the seed used for the randomness to be updated each time I compile. I read that pgfmath is updating the seed every minute, which is not enough for what I'm doing. Is there a way to force him to update every second or, even better, every millisecond?

Here is a toy example of code which prints randomly 4 elements in the list {one, two, three, four}

  • Can you add a simple code example to play with? If you use pdflatex then maybe \pgfmathsetseed{\pdfrandomseed} might do. – egreg Nov 12 '13 at 15:29
  • I added a toy example. I' compiling with latex and not with pdflatex and I would prefer continuing so. – ocalex86 Nov 12 '13 at 15:36

If you use pdflatex or LuaLaTeX, then




will pick a random seed each time. With XeLaTeX there's nothing similar. The value of \pdfrandomseed doesn't change during a run, though.

| improve this answer | |
  • Thanks, but as said above, I would prefer to use LaTeX if possible. If not, I will have to adapt and use pdfLaTeX – ocalex86 Nov 12 '13 at 15:39
  • 9
    @ocalex86 You are using pdflatex also when running latex for DVI output. – egreg Nov 12 '13 at 15:40
  • Oh, sorry, then. I just tried, it works well. Thanks a lot ! – ocalex86 Nov 12 '13 at 15:42
  • 2
    For LuaLaTeX this (now) requires just \randomseed instead of \pdfrandomseed. – Alan Munn Jul 2 '17 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.