General ⇒ Prevent variable from being recalculated each appearance?
Prevent variable from being recalculated each appearance?
Whenever I define a macro, each time it is displayed, it seems to recalculate the macro. For example, if \printtime is a custom macro created with \def that displays the current time to then nearest millisecond, if I have \printtime several times on the document, it appears a different time on each appearance. How do I lock that, so it is calculated only at specific times> E.g. \printtime \printtime \recalculate \printime, would give the first time twice, then a new time after being recalculated.
NEW: TikZ book now 40% off at Amazon.com for a short time.

- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Prevent variable from being recalculated each appearance?
Welcome to the forum!
You could evaluate it, such as by
Stefan
You could evaluate it, such as by
\edef
, or save it into a box, and print that box several times. (\sbox
and \usebox
)Stefan
LaTeX.org admin