I'd like to make a document which looks different each time it is built. I thought this would be pretty easy to do using the aux file; however, it seems I am misunderstanding something very basic. For a small proof-of-concept, here is a document that I thought would produce something different on its second run than on its first:

\def\a{never ran}

After running pdflatex test, I can see that test.pdf indeed contains "never ran", and test.aux contains:


However, running pdflatex test a second time changes neither file. Why not? What should I change so that the document contains ran on the second run?


2 Answers 2


You need \gdef as the .aux file is read in inside a group. At least, I think that's why. Certainly, \gdef works.

I changed the name of the command to avoid the complications which ensued from overwriting an existing one. In general, very short macro names - especially single letters - are unsafe and unwise. At the very least, you should ensure that they do not already exist rather than simply redefining them.

\def\abacus{never ran}

Make it a global definition:

\def\hasruncheck{never ran}

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.