4
\documentclass{article}
\usepackage{ifthen}

\newcounter{theyear}
\setcounter{theyear}{\number\year}
\newcommand{\shorttoday}
{
\ifthenelse{\number\month<5}{May, }{\ifthenelse{\number\month <8}{August, }
{\addtocounter{theyear}{1} January, }}\value{theyear}}
\begin{document}

%\number\month
\shorttoday

\end{document}

Why this result?

Missing number, treated as zero
<to be read again>
                   \par
l.14 
1
  • 3
    \value{theyear} doesn't print the value; for that you should use \thetheyear. All \number tokens you're using are redundant. – egreg Mar 10 '16 at 15:14
2

There is no problem with \ifthenelse. You have a misplaced \value{theyear}, which should be \thetheyear, for printing the value.

Why does a “Missing number” error shows up? You have to know that \value{theyear} just produces the symbolic name of the counter, not its value; when TeX finds a counter name and it is not looking for a number, it starts an assignment, but it finds no number to assign to the counter.

\documentclass{article}
\usepackage{ifthen}

\newcounter{theyear}
\setcounter{theyear}{\year}
\newcommand{\shorttoday}{%
  \ifthenelse{\month<5}%
    {May, }%
    {\ifthenelse{\month <8}%
      {August, }%
      {\addtocounter{theyear}{1}January, }%
    }%
  \thetheyear
}
\begin{document}

\shorttoday

\end{document}

I reformatted the code, removing all spurious spaces you had and also the redundant \number tokens.

1
  • I will have to say thanks for helping me a lot. – Federico Calio' Mar 10 '16 at 15:32

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.