将 hh:mm 添加到研讨会议程的时间?

将 hh:mm 添加到研讨会议程的时间?

我想自动添加时间,以便 Latex 可以制定时间表。

这是已知的日期,但是否有可能存在一个包或类似时间的东西。

\documentclass{article}
\usepackage{datenumber}

\begin{document}

\setdatetoday
\addtocounter{datenumber}{30}%
\setdatebynumber{\thedatenumber}%
In 30 days is \datedate


10:30-\addtime{10:30}{0:45}  - talk 1  \\   %this would add 45min
\addtime{10:30}{0.45}-\addtime{10:30}{1:30}  talk 2   \\ %this would add 1h30min


\end{document}

答案1

我不知道这个包,但可以写一个宏:

overflowdays如果时间超过午夜,则会出现一个包含 1 的 LaTeX 计数器(代码中的示例)。

在此处输入图片描述

\documentclass{article}
\usepackage{datenumber}

\makeatletter
\newcount\@hours
\newcount\@minutes
\newcounter{overflowdays}
\newcommand*{\addtime}[2]{%
    \@add@time#1\@@atendi#2\@@atendii
}
\def\@add@time#1:#2\@@atendi#3:#4\@@atendii{%
    % add hours
    \@hours=#1\advance\@hours#3\relax
    % add minutes
    \@minutes=#2\advance\@minutes#4\relax
    % get full hours from minutes
    \@tempcnta\@minutes\divide\@tempcnta60\relax
    % add them to the hours
    \advance\@hours\@tempcnta
    % full hours from minutes back to minutes
    \multiply\@tempcnta60\relax
    % and subtract from minutes
    \advance\@minutes-\@tempcnta
    % get full days from hours
    \@tempcnta\@hours\divide\@tempcnta24\relax
    % set overflowday
    \setcounter{overflowdays}{\@tempcnta}%
    % full days from hours back to hours
    \multiply\@tempcnta24\relax
    % and subtract from hours
    \advance\@hours-\@tempcnta
    % give out
    \ifnum\@hours<10\relax0\fi% comment out to get rid of leading 0 for hours
    \the\@hours:\ifnum\@minutes<10\relax0\fi\the\@minutes
}
\makeatother

\begin{document}

\setdatetoday
\addtocounter{datenumber}{30}%
\setdatebynumber{\thedatenumber}%
In 30 days is \datedate


10:30-\addtime{10:30}{0:45}  - talk 1  \\   %this would add 45min
\addtime{10:30}{0:45}-\addtime{10:30}{1:30}  talk 2   \\ %this would add 1h30min

Works too (\verb|\addtime{23:30}{2:00}|): \addtime{23:30}{2:00} and we are \theoverflowdays\ day(s) further

There is no input controll (\verb|\addtime{25:90}{30:70}|): \addtime{25:90}{30:70} (days: \theoverflowdays)

\end{document}

相关内容