# Removing “de” preposition in Month/Year date format

I want to have the date of my document with a Month/Year format such as "May 2016". To accomplish this I have followed the instructions in this answer and this article.

This is the code:

\documentclass{article}

\usepackage[catalan]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{datetime}

\newdateformat{monthyeardate}{\monthname[\THEMONTH] \THEYEAR}

\title{Title}
\author{Author}
\date{\monthyeardate\today}

\begin{document}
\maketitle

\end{document}


However, since my document is written in Catalan, when I compile it, the date contains the "de" preposition as you can see in the following picture:

This preposition is completely unnecessary and should not appear, so for instance, the date should read "maig 2016".

The default date construction is: "15 de maig de 2016", see how the number 15 and the right-hand side "de" preposition are correctly removed, but not the left-hand side "de".

How can I fix this problem?

• Do you need the date at any later point in the document? If not, try \date{maig 2016}. – Johannes_B May 15 '16 at 18:15
• There's datetime2 as well, but I can't say whether that's easier to use – user31729 May 15 '16 at 18:18
• @Johannes_B Thanks for your comment. Not really, I only need the date at the top of my document. So I guess your solution is the simplest way of staying out of trouble :) However, hardcoding stuff is usually a bad practice. – codeaviator May 15 '16 at 18:22
• It is part of the title, there is nothing wrong in hardcoding the title. You title and your name are also hard coded ;-) – Johannes_B May 15 '16 at 18:24
• Well, ok. If you put it that way. :-) – Johannes_B May 15 '16 at 18:28

A very elementary approach, with an \ifcase... statement and the month and year count registers. This is not hardcoded then (except the month names in \monthcatalan ;-)

The day, month and year registers are always available and can be printed with \the\day etc. By default, they return the date reported by the OS.

\documentclass{article}

\usepackage[catalan]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\def\monthcatalan#1{%
\ifcase#1
\or gener%
\or febrer%
\or març%
\or abril%
\or meig%
\or juny%
\or juliol%
\or agost%
\or setembre%
\or octubre%
\or novembre%
\or deciembre%
\fi
}

\title{Title}
\author{Author}

\date{\monthcatalan{\month} \the\year}

\begin{document}
\maketitle

\end{document}