更改日期

更改日期
        \documentclass[a4paper,10pt,demo    ]{article} %
    \usepackage{pifont} %bouni
    %-----accent
    \usepackage[latin1]{inputenc} %écrire directement les accents et il peut poser des problème
    \usepackage[T1]{fontenc}
      %-----
    \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
     \usepackage{graphicx}                    % Enable pdflatex
      \usepackage{wrapfig}
      \usepackage{amsmath,amsfonts,amsthm}     % Math packages
      %%%%%%%%%%%%% dimension ancien des marges %%%%%%%%%%%%%%%%%%%%
      \usepackage{geometry}
      \geometry{left=2cm,right=2cm,top=1.5cm,bottom=1.5cm}
      %%%%%%%%%%%%% style des sections %%%%%%%%%%%%%%%%%%%%
     \frenchspacing              % Better looking spacings after periods
      \usepackage{sectsty}
      \sectionfont{%                        % Change font of \section 
         command
    \usefont{OT1}{phv}{b}{n}%       % bch-b-n: CharterBT-Bold font
     \sectionrule{0pt}{0pt}{-5pt}{1pt}}
     %%%%%%%%%%%%%%%% Macros %%%%%%%%%%%%%%%%%%%%
      \newcommand{\sepspace}{\vspace*{1em}}     % Vertical space macro
      \newcommand{\MyName}[1]{ % Name
        \Huge \usefont{OT1}{phv}{b}{n} \hfill #1
        \par \normalsize \normalfont}
      \newcommand{\MySlogan}[1]{ % Slogan}{optional)
    \large \usefont{OT1}{phv}{m}{n}\hfill \textit{#1}
    \par \normalsize \normalfont}
      %%% ------------------------------------------------------------
      \pagestyle{empty}           % No pagenumbers/headers/footers
     %%%%%%%%%%%%%%%%%%%%% Begin Document %%%%%%%%%%%%%%%%%%%%%%%%%
     \begin{document}
     %%%%%%%%%%%%%%%%%% Photo et title %%%%%%%%%%%%%%%%%%%%%%%%%
    %---------------------------
   %---------------------------
   \MyName{Name Name}
    \MySlogan{Curriculum Vitae \\ \null\hfill  (\today)}
    %\MySlogan{Curriculum Vitae (October 2016)}
    %---------------------------
    \sepspace  % Si on ajoute encore \sepspace on aura plus d'espace
    $$$$
     %%%%%%%%%%%%%% Personal details%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \section*{Informations personelles}

    \end{document}

我想在日期中添加“th”,如下所示

在此处输入图片描述

答案1

罪魁祸首就在这里

  1. 找到您想要的日期的正确布局(月日顺序,年)和
  2. 改变 number 和 ord 之间的距离。

要测试这两点,请参阅以下 MWE:

\documentclass{article}

\usepackage[en-GB,en-CA,en-US]{datetime2}

%\usepackage{etoolbox}
%\patchcmd{\DTMenglishordinal}% <cmd>
%  {#1 \DTMenglishfmtordsuffix}% <search>
%  {#1\,\DTMenglishfmtordsuffix}% <replace>
%  {}{}% <success><failure>


\begin{document}

british: 
\DTMsetstyle{en-GB}\today.
\DTMlangsetup[en-GB]{ord=raise} % ,monthyearsep={,\space},abbr
\DTMsetstyle{en-GB}\emph{\today} \today

canadian:
\DTMlangsetup[en-CA]{ord=raise} % ,monthyearsep={,\space},abbr  ,ordsep={\,}
\DTMsetstyle{en-CA}\emph{\today} \today

american:
\DTMlangsetup[en-US]{ord=raise} % ,monthyearsep={,\space},abbr
\DTMsetstyle{en-US}\emph{\today} \today

\end{document}

其结果显示您可以选择加拿大或美国版本来获得您想要的日期布局。由于您在文档中使用了斜体字体,因此我在上面的 MWE 中显示了斜体和普通文本作为日期。

变体

您可以看到,在此变体中,number 和 ord 之间的距离比结果中的距离要大一些,但如果您想要更大的距离,请取消注释这些行

%\usepackage{etoolbox}
%\patchcmd{\DTMenglishordinal}% <cmd>
%  {#1 \DTMenglishfmtordsuffix}% <search>
%  {#1\,\DTMenglishfmtordsuffix}% <replace>
%  {}{}% <success><failure>

在上面的 MWE 中激活补丁。此补丁\,在数字后添加了一个小跳过(#1在代码中用 表示)。现在您得到了结果:

与小跳跃约会

好的,现在我们可以将找到的代码(我选择了美国变体)包含到您的代码中:

\documentclass[%
  a4paper,
  10pt,
  demo
]{article}

\usepackage[en-US]{datetime2} % <=======================================
\DTMlangsetup[en-US]{ord=raise}

\usepackage{etoolbox} % <===============================================
\patchcmd{\DTMenglishordinal}% <cmd> <==================================
  {#1 \DTMenglishfmtordsuffix}% <search>
  {#1\,\DTMenglishfmtordsuffix}% <replace>
  {}{}% <success><failure>

\usepackage{pifont} %bouni

\usepackage[latin1]{inputenc} %écrire directement les accents et il peut poser des problème
\usepackage[T1]{fontenc}

\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
\usepackage{graphicx}                    % Enable pdflatex
\usepackage{wrapfig}
\usepackage{amsmath,amsfonts,amsthm}     % Math packages

\usepackage{geometry}
\geometry{left=2cm,right=2cm,top=1.5cm,bottom=1.5cm}

\frenchspacing              % Better looking spacings after periods
\usepackage{sectsty}
\sectionfont{%                        % Change font of \section 
  command % <=================================================== ???????
  \usefont{OT1}{phv}{b}{n}%       % bch-b-n: CharterBT-Bold font
  \sectionrule{0pt}{0pt}{-5pt}{1pt}}

\newcommand{\sepspace}{\vspace*{1em}}     % Vertical space macro
\newcommand{\MyName}[1]{ % Name
        \Huge \usefont{OT1}{phv}{b}{n} \hfill #1
        \par \normalsize \normalfont}
\newcommand{\MySlogan}[1]{ % Slogan}{optional)
    \large \usefont{OT1}{phv}{m}{n}\hfill \textit{#1}
    \par \normalsize \normalfont}

\pagestyle{empty}           % No pagenumbers/headers/footers


\begin{document}

\MyName{Name Name}
\MySlogan{Curriculum Vitae \\ \null\hfill  (\DTMsetstyle{en-US}\today)} % <=======================

\sepspace  % Si on ajoute encore \sepspace on aura plus d'espace

\section*{Informations personelles}

\end{document}

结果如下:

您的代码经过修正

红色下划线的“命令”来自我在代码中用 标记的行。这是你想要的吗?如果不是,请删除代码中<====== ?????的 行。command

答案2

使用datetime包,( datetime.stypdf,第 8 页):

     \documentclass[a4paper,10pt,demo    ]{article} %
      \usepackage{datetime}
      \newdateformat{dashdate}{%
\twodigit{\THEDAY}-\twodigit{\THEMONTH}-\THEYEAR}
\newdateformat{usvardate}{%
\monthname[\THEMONTH] \ordinal{DAY}, \THEYEAR}

    \usepackage{pifont} %bouni
    %-----accent
    \usepackage[latin1]{inputenc} %écrire directement les accents et il peut poser des problème
    \usepackage[T1]{fontenc}
      %-----
    \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
     \usepackage{graphicx}                    % Enable pdflatex
      \usepackage{wrapfig}
      \usepackage{amsmath,amsfonts,amsthm}     % Math packages
      %%%%%%%%%%%%% dimension ancien des marges %%%%%%%%%%%%%%%%%%%%
      \usepackage{geometry}
      \geometry{left=2cm,right=2cm,top=1.5cm,bottom=1.5cm}
      %%%%%%%%%%%%% style des sections %%%%%%%%%%%%%%%%%%%%
     \frenchspacing              % Better looking spacings after periods
      \usepackage{sectsty}
      \sectionfont{%                        % Change font of \section 
         command
    \usefont{OT1}{phv}{b}{n}%       % bch-b-n: CharterBT-Bold font
     \sectionrule{0pt}{0pt}{-5pt}{1pt}}
     %%%%%%%%%%%%%%%% Macros %%%%%%%%%%%%%%%%%%%%
      \newcommand{\sepspace}{\vspace*{1em}}     % Vertical space macro
      \newcommand{\MyName}[1]{ % Name
        \Huge \usefont{OT1}{phv}{b}{n} \hfill #1
        \par \normalsize \normalfont}
      \newcommand{\MySlogan}[1]{ % Slogan}{optional)
    \large \usefont{OT1}{phv}{m}{n}\hfill \textit{#1}
    \par \normalsize \normalfont}
      %%% ------------------------------------------------------------
      \pagestyle{empty}           % No pagenumbers/headers/footers
     %%%%%%%%%%%%%%%%%%%%% Begin Document %%%%%%%%%%%%%%%%%%%%%%%%%
     \begin{document}
     %%%%%%%%%%%%%%%%%% Photo et title %%%%%%%%%%%%%%%%%%%%%%%%%
    %---------------------------
   %---------------------------
   \MyName{Name Name}
    \MySlogan{Curriculum Vitae \\ \null\hfill  (\usvardate\today)}
    %\MySlogan{Curriculum Vitae (October 2016)}
    %---------------------------
    \sepspace  % Si on ajoute encore \sepspace on aura plus d'espace
    $$$$
     %%%%%%%%%%%%%% Personal details%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \section*{Informations personelles}

    \end{document}

  [1]: 

在此处输入图片描述

答案3

下面使用datetime2设定序数日期的方法,类似于Ferahfeza 的回答。此外,对序数的位置进行了微小调整:

在此处输入图片描述

\documentclass{article}

\usepackage[T1]{fontenc}

\usepackage{fmtcount}
\usepackage[calc,english]{datetime2}
\DTMnewdatestyle{usvardate}{%
  \renewcommand{\DTMdisplaydate}[4]{%
    \DTMmonthname{##2} \ordinalnum{##3}, \number##1 }%
  \renewcommand{\DTMDisplaydate}{\DTMdisplaydate}%
}

\makeatletter
\AtBeginDocument{
  \renewcommand{\fmtord}[1]{\,\fc@textsuperscript{#1}}% Add \, before ordinal number
}
\makeatother

\newcommand{\MyName}[1]{ % Name
  \Huge \usefont{OT1}{phv}{b}{n} \hfill #1
  \par \normalsize \normalfont}
\newcommand{\MySlogan}[1]{ % Slogan}{optional)
  \large \usefont{OT1}{phv}{m}{n}\hfill \textit{#1}
  \par \normalsize \normalfont}

\begin{document}

\MyName{Name Name}
\MySlogan{Curriculum Vitae \\ \null\hfill  (\DTMsetdatestyle{usvardate}\today)}

\end{document}

相关内容