3

Possible Duplicate:
How do I “unprotect” an argument?

I'm trying to print date at title page of a document as NOVEMBER 2012. I'm using the datetime package to format the date as month name-year, but I can not capitalize the month name.

Here is my shot:

\documentclass{minimal}
\usepackage{datetime}

\begin{document}
\newdateformat{mydate}{\monthname~\THEYEAR}
\MakeUppercase{\mydate\today}
\end{document}

This fails to capitalize the month name. I guess the reason is \today is redefined as a macro and there is a \protect somewhere in the chain of definitions. I realized that a possible workaround is not using datetime and defining \today by myself. But I wonder can anyone come up with a neat solution that uses datetime?

2
  • 3
    Related : tex.stackexchange.com/questions/48825/…
    – percusse
    Nov 17, 2012 at 17:16
  • 2
    May I suggest small caps (\textsc{\today}) instead of uppercase? It definitely looks better, and it doesn't have this issue. (Actually, I can't think of a single use case in which I'd recommend uppercase rather than small caps.) Nov 17, 2012 at 17:28

1 Answer 1

3

\MakeUppercase needs expandable commands. The macros of datetime are far from being expandable (protect macros, optional arguments, assignments, …). If you do not need the date in an expandable context, then the month names could be redefined as uppercase strings, e.g.:

\documentclass{minimal}
\usepackage{datetime}

\begin{document}
\newdateformat{mydate}{\monthname~\THEYEAR}
\begingroup
  \makeatletter
  \renewcommand*{\monthnameenglish}[1][\month]{%
    \@orgargctr=#1\relax
    \ifcase\@orgargctr
      \PackageError{datetime}%
        {Invalid Month number \the\@orgargctr}%
        {Month numbers should go from 1 (January) to 12 (December)}%
    \or JANUARY\or FEBRUARY\or MARCH\or APRIL\or MAY\or JUNE\or JULY%
    \or AUGUST\or SEPTEMBER\or OCTOBER\or NOVEMBER\or DECEMBER%
    \else
      \PackageError{datetime}%
        {Invalid Month number \the\@orgargctr}%
        {Month numbers should go from 1 (January) to 12 (December)}%
    \fi
  }%
  \mydate\today
\endgroup
\end{document}

RESULT

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