我正在尝试用 LaTeX 签订合同,在合同中我表达了签署年份的财产的责任。为此,我需要计算已经过去的一年的百分比。
我需要计算今年有多少天,也就是我们所在的日子,然后进行除法,接近小数点后两位。
还有更简单的想法吗?
上面已经解释过了
你可以使用
pgfcalendar
:
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfcalendar}
\newcounter{julian}
\newcounter{silvester}
\newcounter{newyear}
\newcounter{yeardays}
\newcounter{nowdays}
\makeatletter
\pgfcalendardatetojulian{\year-\month-\day}{\c@julian}
\pgfcalendardatetojulian{\year-12-31}{\c@silvester}
\pgfcalendardatetojulian{\year-01-01}{\c@newyear}
\makeatother
\setcounter{yeardays}{\thesilvester}
\addtocounter{yeardays}{1}
\addtocounter{yeardays}{-\thenewyear}
\setcounter{nowdays}{\thejulian}
\addtocounter{nowdays}{1}
\addtocounter{nowdays}{-\thenewyear}
\begin{document}
\pgfmathparse{\value{nowdays}/\value{yeardays}}
\pgfmathprintnumber{\pgfmathresult}
\end{document}