I would like to say, "I have played piano for 23 years" -- but this document will have to be changed every year so I remember to make it 23, then 24, then 25. Is there a way to do something like:

I have played piano for \calculate{\year - 1986} years.

Perhaps using the calc package and the \year command? I haven't been able to figure this out.


You can use the integer arithmetic of TeX too.

I've played the piano for \number\numexpr\year-1986\relax~years.

Just in case you are going to use tikz in your document, here is an overkill solution with this package.

I have played piano for \pgfmathparse{int(\year-1986)}\pgfmathresult~years.

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.