Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
3  
Related : tex.stackexchange.com/questions/48825/… –  percusse Nov 17 '12 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.) –  Federico Poloni Nov 17 '12 at 17:28
add comment

marked as duplicate by Guido, egreg, Kurt, Thorsten, Andrew Swann Nov 17 '12 at 18:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

\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

share|improve this answer
add comment

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