0

My problem is quite simple, I would like to store values in a paragraph outside the paragraph ( the values stored outside should also not be visible in the final PDF )

Something like below :

\label{name}{Harry}

\label{age}{19}

Dear \ref{Name},

I hope this letter finds you well. Today is a very special day as it marks your \ref{age} birthday!

It is so that I can define my values in one place instead of re-editing all of them, it must be quite simple, it's just that I cannot seem to figure it out.

  • 1
    You could define a macro, say \def\age{19}, and then use \age in your document – samcarter_is_at_topanswers.xyz Apr 29 '23 at 11:26
  • 1
    @samcarter_is_at_topanswers.xyz or \newcommand to be safer – David Carlisle Apr 29 '23 at 11:33
  • ok this is exactly what I needed, thanks :)

    but what happens when your document and macros get large ?

    are they locally or only globally defined ?

    for example if at the start of the document you use \age, but you redefine it on page 300 to something else.

    is there a structured way to do it ?

    – sourcevault Apr 29 '23 at 11:34
  • 1
    Definitions are either local (changing the meaning for everything that follows the definition in the same group) or global (changing the meaning for everything that follows the definition). Beyond that it depends on your use case but maybe you want something like this answer or this one. – Dai Bowen Apr 29 '23 at 12:05

0 Answers0