I would like to create a code to insert in my CV that make it auto update.

The hypotetic sentence is this one:

"Engineer with twenty experience years", where twenty is generated by, e.g., \startyear{1997}.

I have written this code:



    Engineer with \startyear{1997} experience years.

that returns:


Engineer with 20 experience years.


But I would like the number (20) in text.

  • 3
    after a quick google: the fmtcountpackage might be helpful – daleif Aug 28 '17 at 10:13
  • No need to use the calculator package here. \newcommand{\startyear}[1]{\the\numexpr\year-#1} – user31729 Aug 28 '17 at 10:25
  • 3
    And with fmtcount as @daleif suggested: \newcommand{\startyear}[1]{\numberstringnum{\numexpr\year-#1}} – user31729 Aug 28 '17 at 10:29
  • With \usepackage{fmtcount} and \newcommand{\startyear}[1]{\numberstringnum{\numexpr\year-#1‌​}} in the preamble, I obtain the output: "Engineer with twenty experience years.", but with the error: "Missing = inserted for \ifnum. Engineer with \startyear{1997}" in the line where I use \startyear{1997}. – Giacomo Alessandroni Aug 28 '17 at 14:00
  • Isn't this nearly a duplicate of tex.stackexchange.com/questions/28326/…? – Fritz Aug 28 '17 at 16:11

The calculation is pretty easy with \the\numexpr\year-#1 where #1 is considered to hold the number of the starting year.

This is fed into \numberstringnum which 'translates' the number into the number word, i.e. 1 would become one etc.





\foreach \x in {1900,...,\the\year} {
    Engineer with \startyear{\x}\ experience years. 


enter image description here

|improve this answer|||||
  • Thanks. I confirm that the code compile with and without the the command in newcommand and in \foreach. – Giacomo Alessandroni Aug 29 '17 at 9:10

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.