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
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityWhich 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}
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}
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.
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}
\the\month-\the\year
\date{Wombat}
to hopefully get Wombat as the date. Who knows.