Last active
April 8, 2021 22:06
-
-
Save DSCF-1224/aec5486d5aecf8b01a5104e16ead80eb to your computer and use it in GitHub Desktop.
コンパイル(タイプセット)された時刻をLaTeXの出力に記録する。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% [reference] | |
% https://tex.stackexchange.com/questions/34424/how-do-i-calculate-n-modulo-3-in-latex | |
\RequirePackage{plautopatch} | |
\documentclass[uplatex]{jsarticle} | |
\makeatletter | |
\newcommand{\calcQuotient}[2]{{% | |
\newcount\@quotient% | |
\@quotient=#1\relax% | |
\divide \@quotient by #2 \relax% | |
\number\@quotient% | |
}} | |
\newcommand{\calcModulo}[2]{{% | |
\newcount\@modulo% | |
\@modulo=#1\relax% | |
\divide \@modulo by #2 \relax% | |
\multiply \@modulo by #2 \relax% | |
\multiply \@modulo by -1 \relax% | |
\advance \@modulo by #1 \relax% | |
\number\@modulo% | |
}} | |
\newcommand{\DigitTwo}[1]{\ifnum #1<10 {0#1}\else\relax{#1}\fi} | |
\newcommand{\TimeCompiled}{{% | |
% declare new counters | |
\newcount\@bufferTime% | |
\newcount\@hourCompiled% | |
\newcount\@minuteCompiled% | |
% initialize declared counters | |
\@bufferTime = \number\time% | |
\@hourCompiled = \@bufferTime% | |
\@minuteCompiled = \@bufferTime% | |
% calculate compilied minute (base: \calcModulo) | |
\divide \@minuteCompiled by 60 \relax% | |
\multiply \@minuteCompiled by 60 \relax% | |
\multiply \@minuteCompiled by -1 \relax% | |
\advance \@minuteCompiled by \@bufferTime \relax% | |
% calculate compilied hour (base: \calcModulo) | |
\advance \@hourCompiled by -\@minuteCompiled \relax% | |
\divide \@hourCompiled by 60 \relax% | |
% output | |
\DigitTwo{\number\@hourCompiled}:\DigitTwo{\number\@minuteCompiled}% | |
}} | |
\makeatother | |
\begin{document} | |
\calcQuotient{\number\time}{60} % compilied hour | |
\calcModulo{\number\time}{60} % compilied minute | |
\TimeCompiled | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment