1

In my thesis class file, I currently have

\begin{center}%
\@date%
\end{center}%

Which generates a date in the format day-month-year on the title page.

How do I change this so it only states the month and year?

Thank you

7
  • 2
    \the\month-\the\year
    – Marijn
    Mar 10, 2018 at 22:06
  • so i would have : \begin{center}% \@date\the\month-\the-year% \end{center}% or something different?
    – user141013
    Mar 10, 2018 at 23:34
  • 2
    All answers assume something, nobody knows what is going on.
    – Johannes_B
    Mar 11, 2018 at 11:39
  • 1
    I voted to close as unclear. A class file should never be changed. What you should do is \date{Wombat} to hopefully get Wombat as the date. Who knows.
    – Johannes_B
    Mar 11, 2018 at 12:03
  • 2
    @Johannes_B This is true. I was assuming that the OP was creating their own custom class file (based on the "my thesis class file" part rather than identifying a specific class). Mar 11, 2018 at 12:08

2 Answers 2

7

Which generates a date in the format day-month-year on the title page.

\@date is usually initialised to \today and the default format of \today is the US style month day, year as illustrated in the simple example:

\documentclass{article}

\begin{document}
\today
\end{document}

March 11, 2018

If your document is producing day-month-year for the default definition of \@date (\today), then you've likely loaded a package that alters \today, such as a language package (babel or polyglossia) or one of the date packages. The solution depends on which package you've loaded that's redefined \today. If it's just babel or polyglossia, then you can use datetime2 with datetime2-english. (Both need installing independently.)

For example:

\documentclass{article}

\usepackage[british]{babel}
\usepackage[useregional]{datetime2}
\DTMlangsetup[en-GB]{showdayofmonth=false}

\begin{document}
\today
\end{document}

March 2018

There are various other regions supported by datetime2-english. Choose the most applicable. For example,

\documentclass{article}
\usepackage[USenglish]{babel}
\usepackage[useregional]{datetime2}
\DTMlangsetup[en-US]{showdayofmonth=false}

\begin{document}
\today
\end{document}

or

\documentclass{article}
\usepackage[english]{babel}
\usepackage[en-IE]{datetime2}
\DTMlangsetup[en-IE]{showdayofmonth=false}

\begin{document}
\today
\end{document}

The other possibility is that \@date has been redefined (so that it no longer expands to \today). Check your class file and document code for any instance of \date or any explicit definition of \@date. You can use \show for debugging. For example, if you (temporarily) modify the code to

\begin{center}%
\show\@date
\@date
\end{center}%

Then the transcript will show the definition of \@date. If you get the message

> \@date=macro:
->\today .

Then it's \today that has been modified, but if you get something different, for example

> \@date=macro:
->11 March 2018.

then \@date has been redefined, in which case you need to find where it's been redefined and modify it accordingly.

4

If you want to see "March 2018" in your thesis; simply enter \date{March 2018} in the text of your thesis. This will initialize macro \@date to March 2018.

Besides, here a simple macro (\printdate) to print the date in the desired format:

\documentclass{article}

\newcommand*{\printdate}{%
   \ifcase \month\or January\or February\or March\or April\or May\or June\or July\or
    August\or September\or October\or November\or December\fi \space \number\year}

\begin{document}

\printdate

\end{document}
0

Not the answer you're looking for? Browse other questions tagged .