Last active
July 5, 2025 16:24
-
-
Save zr-tex8r/fbc385a230daa090e9efbee00e0e9011 to your computer and use it in GitHub Desktop.
イマドキの生成AIのTeXプログラミングを添削する①
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
% --- マクロ定義ここから --- | |
% 計算に使用するカウンタ(整数型変数)を宣言 | |
\newcount\hours | |
\newcount\minutes | |
\newcount\totalminutes | |
% \toMinutes の内部で呼び出されるヘルパーマクロ | |
% #1:#2\relax の形式で引数を取ることで、":"を区切り文字として | |
% 時間と分を分割します。 | |
% #1: 時間 (HH) | |
% #2: 分 (MM) | |
% #3: 結果を格納するマクロ(例: \value) | |
\def\parseTime#1:#2\relax#3{% | |
\hours=#1 | |
\minutes=#2 | |
\totalminutes=\hours | |
\multiply\totalminutes by 60 | |
\advance\totalminutes by \minutes | |
% 計算結果を #3 で指定されたマクロに定義する | |
% \edef は右辺を完全に展開してから定義する | |
\edef#3{\the\totalminutes}% | |
} | |
% ユーザーが呼び出すマクロ本体 | |
% #1: 結果を格納するマクロ(例: \value) | |
% #2: 時刻文字列(例: {12:30}) | |
\def\toMinutes#1#2{% | |
% #2の中身の "HH:MM" を \parseTime マクロに渡します。 | |
\parseTime#2\relax#1% | |
} | |
% --- マクロ定義ここまで --- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
説明
入力
このRuby関数と同じことをするTeX言語マクロ
\toMinutes
を作ってください。インタフェースについてはの代わりに
\toMinutes\value{12:30}
のようにします。
※パッケージは使わないでください。