6

How can I redefine \today so that today's current date comes in the format

May 26th, 2016

I need the "th" to be superscript.

It should come to the bottom right corner of the page. The code does not work when I use it in the following environment XeLaTeX.

%  Preamble:
\NeedsTeXFormat{LaTeX2e}
\LoadClass{article}
\usepackage[head=12pt, foot=12pt, top=18mm, bottom=15mm, left=12.7mm, right=12.7mm]{geometry}
\usepackage[absolute]{textpos}
\usepackage[UKenglish]{babel}
\usepackage[en-US]{datetime2}
\DTMlangsetup{ord=raise}
\usepackage{rotating}

%  Main Tex:

\begin{document}
\setlength{\TPHorizModule}{1mm}
\setlength{\TPVertModule}{1mm}
\textblockorigin{0mm}{5mm} 
\begin{textblock}{60}(205,207)
\begin{turn}{90} 
Last Updated on
\today
\end{turn}
\end{textblock}
\end{document}

I need this to come as [Last Updated on May 26th, 2016]. "th / st /nd " raised to superscript height. Rotated 90 Deg. Bottom Right Corner of page. Please Check MWE Link Below.

Also I Keep getting this Warning:

Package datetime2 Warning: Region `english-base' has ignored (datetime2) the following settings: (datetime2) ord=raise on input line 13.

Link to MWE: https://www.overleaf.com/5308800stsrzk#/16764374/

4
  • 1
    This question, at least to me, is very very unclear. Are you talking about the one occasion on the title where you do \date{May 26th, 2016} or are you using a package for formatting the date. Please elaborate.
    – Johannes_B
    Commented May 26, 2016 at 5:32
  • Your new example isn't compilable as is. For sure, replace \LoadClass with \documentclass. More importantly: Where and how is \turn defined?
    – Mico
    Commented May 26, 2016 at 10:42
  • \turn is defined in package rotating. i missed out. apologies
    – Curi0usM3
    Commented May 26, 2016 at 10:48
  • The warning is because you've omitted the optional argument of \DTMlangsetup, so it's trying to apply the setting to all loaded modules, but the base module doesn't recognise the setting. So just do \DTMlangsetup[en-US]{ord=raise} to suppress the warning. Commented May 26, 2016 at 11:48

1 Answer 1

13

I suggest you use the datetime2 package with the option en-US:

enter image description here

The instruction \DTMlangsetup{ord=raise} instructs datetime2 to treat the day number as an ordinal and to raise the st/nd/rd particles to superscript height.

\documentclass{article}
\usepackage[en-US]{datetime2}
\DTMlangsetup{ord=raise}
\begin{document}
\today
\end{document}

Addendum to address the OP's augmented question: It looks like you're using UKenglish as the main language option for babel, yet also wanting a US-style date string ("May 26th, 2016" -- with "th" raised) rather than a UK-style date string ("26th May 2016" -- "th" not raised). To achieve this objective, you need to (a) provide "USenglish" as a secondary language option when loading babel and (b) execute the instruction \selectlanguage{USenglish} inside the textblock environment.

The code shown below should compile equally well under pdfLaTeX, XeLaTeX, and LuaLaTeX.

\documentclass{article}
\usepackage[head=12pt,foot=12pt,top=18mm,bottom=15mm,hmargin=12.7mm]{geometry}
\usepackage[absolute]{textpos}    
\usepackage[USenglish,UKenglish]{babel}   
\usepackage[en-US]{datetime2}
\DTMlangsetup[en-US]{ord=raise}    
\usepackage{rotating} % provides \turn macro

\begin{document}
\setlength{\TPHorizModule}{1mm}
\setlength{\TPVertModule}{1mm}
\textblockorigin{0mm}{5mm} 

\begin{textblock}{60}(205,207)
\selectlanguage{USenglish}
\begin{turn}{90} 
Last Updated on \today
\end{turn}
\end{textblock}

\end{document}
6
  • Yay! worked like a charm. Thanks for providing the root cause of the problem.
    – Curi0usM3
    Commented May 26, 2016 at 12:38
  • Note: If you are trying to use superscript format using british date order you need to remove british from \documentclass[british]{article} (as was my document). I have no idea why and I also cannot find a reference for what setting british does nor how it overrides everything else.
    – AnnanFay
    Commented Nov 7, 2017 at 20:32
  • @Annan - It would help if you provided a bit more information about your document setup. E.g., do you use the babel package?
    – Mico
    Commented Nov 7, 2017 at 20:49
  • @Mico Hmm, so with \documentclass[british]{article} and \usepackage[UKenglish]{babel} it causes problems. With all other combinations, or removing one parameter, it works fine. If neither are specified it fails compilation. It also works when not using babel. What really confuses me is why other combinations don't have the same behaviour. I would expect one of the options to override the other, or for one to have higher priority.
    – AnnanFay
    Commented Nov 7, 2017 at 21:13
  • @Annan - I’m afraid your reply wasn’t exactly illuminating. I suggest you post a new query, in which you provide full details of your document setup and what you’re trying to achieve.
    – Mico
    Commented Nov 7, 2017 at 21:53

You must log in to answer this question.

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