1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

LaTeXの\todayで月日を2桁表示にする.

Posted at

問題

通常,\date{\today}とすると,2020年1月1日のように月日が1桁で表示されてしまう.
これを,2020年01月01日のようにしたい.

環境

MacTeX

e-pTeX 3.14159265-p3.8.0
-180226-2.6 (utf8.euc) (TeX Live 2018)
kpathsea version 6.3.0
ptexenc version 1.3.6
Copyright 2018 D.E. Knuth.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the e-pTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the e-pTeX source.
Primary author of e-pTeX: Peter Breitenlohner.

解決方法

プレアンブルに,

\makeatletter
\newcommand*{\themonth}{\two@digits\month}
\newcommand*{\theday}{\two@digits\day}
\makeatother
\renewcommand{\today}{{\the\year}年{\themonth}月{\theday}日}

と追記する.
また,5行目の年,月,日をハイフンにすれば2020-01-01と出力される.

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?