TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Welcome to TeX.SX. – Claudio Fiandrino Feb 3 '13 at 14:19
up vote 10 down vote accepted

You can use the integer arithmetic of TeX too.

I've played the piano for \number\numexpr\year-1986\relax~years.
share|improve this answer

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.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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