更改日期

更改日期
        \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 和 order 之間的距離。

要測試這兩點,請參閱以下 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設定序數日期的方法,類似於中提出的方法費拉菲扎的回答。此外,也對序數的位置進行了細微調整:

在此輸入影像描述

\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}

相關內容