Skip to content

Instantly share code, notes, and snippets.

@zr-tex8r
Last active July 10, 2025 12:31
Show Gist options
  • Save zr-tex8r/46759670e0d2a6aa26f0595f27f2bbef to your computer and use it in GitHub Desktop.
Save zr-tex8r/46759670e0d2a6aa26f0595f27f2bbef to your computer and use it in GitHub Desktop.
イマドキの生成AIのTeXプログラミングを添削する④
\ProvidesExplPackage {ai-coding-4} {2025-07-07} {0.1}
{NabeAzz by AI coding}
\RequirePackage{xparse}
%=============== フォント定義 ===============
% Computer Modern Funny Italic (cmfi10) を OT1/cmfr/m/it に割り当て
\DeclareFontFamily{OT1}{cmfr}{}
\DeclareFontShape{OT1}{cmfr}{m}{it}{<-> cmfi10}{}
%=============== マクロ定義 ===============
\NewDocumentCommand{\NabeAzz}{ m }
{
\int_step_inline:nn { #1 }
{
\int_compare:nF { ##1 == 1 } { ~ }
\exp_args:Ne \str_if_in:nnTF { \int_to_arabic:n {##1} } { 3 }
{ \bool_set_true:N \l_tmpa_bool }
{ \bool_set_false:N \l_tmpa_bool }
\bool_if:nTF
{
( \int_compare_p:n { \int_mod:nn { ##1 } { 3 } == 0 } )
||
\l_tmpa_bool
}
{
{ \large \usefont{OT1}{cmfr}{m}{it} \int_to_arabic:n {##1} }
}
{
\int_to_arabic:n {##1}
}
}
}
@zr-tex8r
Copy link
Author

説明

  • 1回目のコミットがAIが出力したコード、2回目が私が修正したもの。
  • Gemini 2.5 Pro(無料枠)を使用。

入力

以下の動作を行うTeX言語のマクロ\NabeAzzを作れ。

\NabeAzz{<整数n>}は1からnまでの整数の十進表記を順に空白区切りで出力する。ただし、整数が「3の倍数である」または「(その十進表記に)数字3を含む」場合は、フォントを「Computer Modern Funny Italic」でサイズを\largeに変えて出力する。その他の条件は以下の通り。

  • LaTeXフォーマットを前提とする。パッケージを使用してもかまわない。
  • 引数の<整数n>は正であり、かつ数字列で与えられると仮定してよい。想定外の引数を与えた場合の動作は何も規定しない。
  • 「Computer Modern Funny Italic」のTeXでのTFM名)はcmfi10である。LaTeX では「エンコーディングOT1、ファミリcmfr、シリーズm、シェープit」に割り当てられている。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment