1

I was wondering if there is a way to redefine the abbreviated months with datetime2 package, such that, when using the command \today, months are written exactly like the first column of the image below.

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

There is already a solution---How to make a lowercase month name with \today---with datetime package to redefine the month style, but this package creates a confit with my document.

Thanks.

enter image description here

EDIT in light of @quark67's solution:

I identified the conflict using quark67's solution to be with \usepackage[USenglish]{babel}, used for hyphenation. I just had to remove the argument [USenglish] to make quark67's solution works, but I would still like to keep \usepackage[USenglish]{babel}.

SOLUTION

In reference to this post: Redefinition of \today -- Clash with babel, placing @quark67's code inside \AtBeginDocument{...} solved it.

AEW
  • 819
  • Please add exactly the document class you need (ruthesis according to a comment) and all package you need to use. My answer needs adjustement for May, June and July. But what is false with the other months? – quark67 Mar 11 '23 at 07:36
  • I have updated my code. But I cannot guess what are the additional packages (which you mentioned in a comment) you uses, so perharps this code don't work for you. – quark67 Mar 11 '23 at 15:01
  • Thank you @quark67 for your help. This is the right solution that I was looking for. I have identified the conflict in \usepackage[USenglish]{babel} that I use for hyphenation. I just needed to remove the argument [USenglish]. I'm not sure how this will impact my document. Would you be able to work around this conflict? – AEW Mar 11 '23 at 20:03

1 Answers1

1

Try this (note the loading of the package datetime2-calc for the conversion from numeric value to the short month name).

Edit: As you say you need the document class ruthesis (https://scholarship.rice.edu/handle/1911/21747) in a comment, I update my code with this document class.

Also, as you have added a new requirement (June must be abbreviated as "June", no "Jun.", and July as "July", no "Jul."), I have updated the code (and corrected my dummy bug, May is never abbreviated as "May.")

Edit 2: "September" is abbreviated "Sept.", not "Sep.", as in the first column of the table.

\documentclass{ruthesis}
\usepackage[en-US]{datetime2}
\usepackage{datetime2-calc}

\DTMnewdatestyle{mydate}{% \renewcommand{\DTMdisplaydate}[4]{% \edef\paramTwo{##2}% \def\monthV{05}% \def\monthVI{06}% \def\monthVII{07}% \def\monthIX{09}% \DTMshortmonthname{##2}% \ifx\paramTwo\monthV% \else\ifx\paramTwo\monthVI% e% \else\ifx\paramTwo\monthVII y% \else\ifx\paramTwo\monthIX t.% \else .% \fi\fi\fi\fi% \ \DTMtwodigits{##3}, ##1}% \renewcommand{\DTMDisplaydate}{\DTMdisplaydate}% }

\DTMsetdatestyle{mydate}

\begin{document} \today % Mar. 11, 2023

\DTMdate{2023-06-11}

\DTMdate{2023-05-11}

\DTMdate{2023-04-11}

\DTMdate{2023-07-11}

\end{document}

Result:

enter image description here

In a comment, you say that the previous code don't work because of a package you uses, but you don't say which additional packages you uses, so I cannot guarantee this code will work in your real usage.

luki
  • 1,796
quark67
  • 4,166
  • Thank you @quark67 for this solution, but for some reason, it is not working with my thesis document. It outputs: "March 10, 2023."

    I need to comply with IEEE standards. I think there is a conflict with this definition that I have:

    \def\@month{\ifcase\month ?\or \textsc{January}\or \textsc{February}\or \textsc{March}\or \textsc{April}\or \textsc{May}\or \textsc{June}\or \textsc{July}\or \textsc{August}\or \textsc{September}\or \textsc{October}\or \textsc{November}\or \textsc{December}\fi}

    – AEW Mar 10 '23 at 23:41
  • Welcome. Can you please provide an MWE? In your code, you uses the article document class. What is the real document class you uses? From where comes the definition \@month? Is it so in your preamble? Add also your required packages. Thanks. – quark67 Mar 10 '23 at 23:48
  • The document class that I'm using is report. It's different from my example, sorry. The definition of\@month? is in a .cls document. Do you know a quick way to copy a long code here, so you can check this document? Thanks. – AEW Mar 10 '23 at 23:55
  • Here is the document class: newtextdocument.com/t/f9e9d1cfab – AEW Mar 11 '23 at 00:25
  • @AEW I have downloaded ruthesis.cls from https://scholarship.rice.edu/handle/1911/21747 (seems to be the same version as yours), installed in ~/Library/texmf/tex/latex/ruthesis (on my Mac), then replaced \documentclass{article} by \documentclass{ruthesis} and all works as expected. – quark67 Mar 11 '23 at 01:09
  • Yes, that's the right document @quark67. I re-downloaded it again, and copied to my source files folder, but still not working. Probably, there Is a conflict with one of the packages that I'm using in the main tex file. – AEW Mar 11 '23 at 01:23
  • Do you know if there is a solution similar to this: link. I would like to even change the months abbreviations as in here: link. – AEW Mar 11 '23 at 01:30
  • @AEW That's why we always needs [Minimal Working Example]{https://tex.meta.stackexchange.com/q/228}. But not too minimal ;). Here try to find the package which make the conflict in your use case, perhaps I can help you. – quark67 Mar 11 '23 at 01:32
  • @AEW you link to the Chicago Manual of Style needs a login. – quark67 Mar 11 '23 at 01:38
  • Yes @quark67, sorry. I have added a screenshot of it to the question. I need to have months written exactly like the first column of the table. – AEW Mar 11 '23 at 05:42