ファイルquiz.texのコードは
「引数に指定したトークン列に“ある変換”を適用した結果のトークン列を\Parsedに代入する」
という仕様のマクロ\Parseの実装である。
コードを読んで“ある変換”の内容を把握した上で、\Parseを\futureletを使わずに実装せよ。
※LaTeXまたはplain TeXを前提とする。
| #import "zrsimple.typ" | |
| #show: zrsimple.doc.with( | |
| paper: "a5", | |
| title: "NabeAzz with Typst", | |
| author: "ZR" | |
| ) | |
| #let aho-font = "Allura" | |
| #let nabeazz(lmt) = { |
| #import "zrjasimple.typ" | |
| #show: zrjasimple.doc.with( | |
| title: "Typst でドドスコしてみた", | |
| author: "某 ZR" | |
| ) | |
| // ddsk(seed)は, 乱数種を seed としたときの | |
| // "ドドスコ問題"の出力の文字列. | |
| #let ddsk(seed) = { |
| #let doc(title: "", author: "", body) = { | |
| set document(author: author, title: "☃") | |
| set page(paper: "a5", numbering: none) | |
| set text(size: 320pt) | |
| v(2fr) | |
| align(center)[#emoji.snowman.snow] | |
| v(3fr) | |
| } |
| % LuaLaTeX文書; 文字コードはUTF-8 | |
| \documentclass[a4paper]{ltjsarticle} | |
| \usepackage[noto-jp]{luatexja-preset} | |
| % 欧文はLatin Modernのまま | |
| \usepackage{newunicodechar,luacode} | |
| %↓入力中のU+FFFDを一旦U+F8FDに置き換える | |
| \begin{luacode*} | |
| luatexbase.add_to_callback('process_input_buffer', function (s) | |
| if s:match('\xef\xbf\xbd') then | |
| return s:gsub('\xef\xbf\xbd', '\xef\xa3\xbd') |
| %#!lualatex | |
| \documentclass{article} | |
| \usepackage[papersize={100mm,148mm},margin=0cm, | |
| noheadfoot]{geometry} | |
| \usepackage{luatexja-fontspec} | |
| \usepackage{amsmath,tikz,graphicx,xcolor,xparse,pgfmath} | |
| \ltjsetparameter{jacharrange={-2}} | |
| \usetikzlibrary{calc,positioning} | |
| \colorlet{k}{black} | |
| \newcommand{\cLet}{\pgfmathsetmacro} |
Compile with:
pdftex "\catcode64=11 \input texmas2022.tex"
| % hanoi.satyh: Tower of Hanoi with graphics | |
| % | |
| % Copyright (c) 2022 Takayuki YATO (aka. "ZR") | |
| % GitHub: https://github.com/zr-tex8r | |
| % Twitter: @zr_tex8r | |
| % Distributed under the MIT License. | |
| %=========================================================== module Hanoi | |
| module Hanoi : sig |
| let text-box-board w h ib = | |
| let (tw, th, _) = get-natural-metrics ib in | |
| let gtxt = draw-text ((w -' tw) *' 0.5, (h -' th) *' 0.5) ib in | |
| inline-graphics w h 0pt (fun p -> [shift-graphics p gtxt]) | |
| let text-board ctx w h fname fsize str = | |
| let ctx = ctx |> (set-font-size fsize) | |
| |> (set-font Latin (fname, 1., 0.)) in | |
| let ib = read-inline ctx (embed-string str) in | |
| text-box-board w h ib |