如何自动更新 beamer pdf 上的日期

如何自动更新 beamer pdf 上的日期

前一天编译 pdf 并不罕见(至少对我来说)。在其他日子使用相同的 pdf 也并不罕见。因此,如果生成的 pdf 显示正在播放的系统日期而不是编译日期,那将会很方便。可以吗?

答案1

如果您知道显示 PDF 的日期,只需在序言中包含该日期即可:

\date{06/06/66}

答案2

这不是一个真正的解决方案,但是如果你前一天编译了你的文档,你可以使用以下代码来获取命令(如果需要,\Tomorrow请将它和相关的包放入单独的文件中).sty

\documentclass{article}
\usepackage{datetime}
\usepackage{etoolbox} 
\usepackage{calculator}

\makeatletter


\newif\ifIsLeapYear\IsLeapYearfalse

\newcommand*{\YearIsLeapYear}[1]{%
\IsLeapYearfalse%
\MODULO{#1}{4}{\ModuloFourResult}%
\ifnumcomp{\ModuloFourResult}{=}{0}{%
\MODULO{#1}{100}{\ModuloOneHundredResult}%
   \ifnumcomp{\ModuloOneHundredResult}{=}{0}{%
\MODULO{#1}{400}{\ModuloFourHundredResult}%
   \ifnumcomp{\ModuloFourHundredResult}{=}{0}{%
      \IsLeapYeartrue%
}{%
      \IsLeapYearfalse%
}%
}{%
\IsLeapYeartrue% 
}}{\IsLeapYearfalse}%
}%




\newcounter{WorkSheet@@Day}%
\newcounter{WorkSheet@@Month}%
\newcounter{WorkSheet@@Year}%




\newcommand*{\WorkSheet@@SwitchToNextMonth}{%
  \setcounter{WorkSheet@@Day}{1}%
  \refstepcounter{WorkSheet@@Month}%
}%

\newcommand*{\WorkSheet@@SwitchToNextYear}{%
\setcounter{WorkSheet@@Day}{1}%
\setcounter{WorkSheet@@Month}{1}%
\refstepcounter{WorkSheet@@Year}%
}%

\newcommand*{\WorkSheetDayAfterDate}[3]{%
\setcounter{WorkSheet@@Day}{#1}%
\setcounter{WorkSheet@@Month}{#2}%
\setcounter{WorkSheet@@Year}{#3}%
%
\def\MonthsWithThirtyOneDays{1}%
\def\MonthsWithThirtyDays{4}%
%
%
\listadd{\MonthsWithThirtyOneDays}{1}%
\listadd{\MonthsWithThirtyOneDays}{3}%
\listadd{\MonthsWithThirtyOneDays}{5}%
\listadd{\MonthsWithThirtyOneDays}{7}%
\listadd{\MonthsWithThirtyOneDays}{8}%
\listadd{\MonthsWithThirtyOneDays}{10}%
\listadd{\MonthsWithThirtyOneDays}{12}%
%
\listadd{\MonthsWithThirtyDays}{4}%
\listadd{\MonthsWithThirtyDays}{6}%
\listadd{\MonthsWithThirtyDays}{9}%
\listadd{\MonthsWithThirtyDays}{11}%
\YearIsLeapYear{\number\value{WorkSheet@@Year}}%
\xifinlist{\number\value{WorkSheet@@Month}}{\MonthsWithThirtyOneDays}{%  It is a "long month"
%
\ifnumcomp{\value{WorkSheet@@Day}}{=}{31}{% Is the 31st day in the month!
% Check for 12/31/... 

\ifnumcomp{\value{WorkSheet@@Month}}{=}{12}{%
    \WorkSheet@@SwitchToNextYear}{ \WorkSheet@@SwitchToNextMonth}%
}{\refstepcounter{WorkSheet@@Day}}}{%

\ifnumcomp{\value{WorkSheet@@Month}}{=}{2}{% It is February
\ifnumcomp{\value{WorkSheet@@Day}}{=}{28}{% Is the 28th of February
\ifIsLeapYear%
\refstepcounter{WorkSheet@@Day}%
\else%
\WorkSheet@@SwitchToNextMonth%
\fi%
}{%
\ifIsLeapYear%
\ifnumcomp{\value{WorkSheet@@Day}}{=}{29}{% Is the 29th of February
\WorkSheet@@SwitchToNextMonth}{\refstepcounter{WorkSheet@@Day}}%
\else%
\refstepcounter{WorkSheet@@Day}%
\fi%
}}{%
% It is a month with 30 days!!
\xifinlist{\number\value{WorkSheet@@Month}}{\MonthsWithThirtyDays}{%
\ifnumcomp{\value{WorkSheet@@Day}}{=}{30}{% Is the 30st day in the month!
\WorkSheet@@SwitchToNextMonth}{\refstepcounter{WorkSheet@@Day}    

}}}{}%
}%
}%





\providecommand{\Tomorrow}{%
\WorkSheetDayAfterDate{\number\day}{\number\month}{\number\year}%
\newdate{DateOfTomorrow}{\number\value{WorkSheet@@Day}}{\number\value{WorkSheet@@Month}}{\number\value{WorkSheet@@Year}}%
\displaydate{DateOfTomorrow}
}%
\makeatother




\begin{document}
Tomorrow is \Tomorrow%
\end{document}

您可以利用该包的功能datetime来根据您的需要来格式化日期。

当然,您仍然需要在前一天编译您的文档;-)

答案3

这只是为未来的访问者准备的。tdclock 包正好满足了我的期望。它只适用于 Acrobat Reader。

\documentclass{beamer}
\usetheme{madrid}
\usepackage[font=Times,timeinterval=10]{tdclock}
\title{Adding Current date}
\date{\tdclock}
\begin{document}
\initclock
\begin{frame}
\maketitle
\end{frame}
\begin{frame}{Ticking clock}\end{frame}
\end{document}

相关内容