3

I'm using the datetime package. How could I have a date format with the month name in capital letters?

\usepackage{datetime}
% some code here
\newdateformat{mifecha}{Bilbao, a \THEDAY~de \monthname[\THEMONTH] de \THEYEAR}
\mifecha\date{\today}

Gives me:

Bilbao, a 15 de noviembre de 2013

But I would like:

Bilbao, a 15 de Noviembre de 2013

I have tried the command \capitalisewords without success, but maybe it's because I should use a combination of \expandafter commands or something related.

Werner
  • 603,163
Álvaro
  • 1,210
  • Could you please provide a complete, minimal working example (MWE), since the default output seems to be capitalized. I assume you're using \usepackage[spanish]{babel} as well? – Werner Nov 15 '13 at 01:04
  • If you're writing the document in Spanish is incorrect to write the months starting capitalized. http://rae.es/consultas/mayuscula-o-minuscula-en-los-meses-los-dias-de-la-semana-y-las-estaciones-del-ano – osjerick Nov 15 '13 at 01:46
  • @osjerick you're right, thanks for the correction, RAE after all dictates the norms in Spanish. However, if you see motivation letters you will see that putting the month in capital letters is a generalised error due to the English influence as it's also noted here: http://www.fundeu.es/consulta/forma-de-poner-la-fecha-5224/ – Álvaro Nov 15 '13 at 15:53

1 Answers1

5

If you're loading babel with the spanish option, then your months will start in lowercase as this is the definition enforced by babel. A redefinition of \monthnamespanish corrects this:

enter image description here

\documentclass{article}
\usepackage[spanish]{babel}% http://ctan.org/pkg/babel
\usepackage{datetime}% http://ctan.org/pkg/datetime
\newdateformat{mifecha}{Bilbao, a \THEDAY~de \monthname[\THEMONTH] de \THEYEAR}
\makeatletter
\renewcommand{\monthnamespanish}[1][\month]{%
  \@orgargctr=#1\relax
  \ifcase\@orgargctr
    \PackageError{datetime}{Invalid Month number \the\@orgargctr}{%
      Month numbers should go from 1 to 12}%
    \or Enero%
    \or Febrero%
    \or Marzo%
    \or Abril%
    \or Mayo%
    \or Junio%
    \or Julio%
    \or Agosto%
    \or Septiembre%
    \or Octubre%
    \or Noviembre%
    \or Diciembre%
    \else \PackageError{datetime}{Invalid Month number \the\@orgargctr}{%
      Month numbers should go from 1 to 12}%
  \fi}
\makeatother
\begin{document}
\mifecha\today
\end{document}

You may also be interested in updating \dayofweeknameidspanish and \shortdayofweeknameidspanish.

Werner
  • 603,163
  • I'm not using babel but the polyglossia package, as I'm using XeLaTeX, however I works perfectly with polyglossia too ^^V – Álvaro Nov 15 '13 at 15:47
  • I needed to capitalize the month but only in one occurrence (an only Month-Year date starting the sentence). So I have used this answer with the spanish names capitalized. – arauzo Apr 05 '19 at 11:27