![使用 luatex \let 指令傳送給其他人](https://rvso.com/image/305773/%E4%BD%BF%E7%94%A8%20luatex%20%5Clet%20%E6%8C%87%E4%BB%A4%E5%82%B3%E9%80%81%E7%B5%A6%E5%85%B6%E4%BB%96%E4%BA%BA.png)
仍在尋找 LuaTeX,我了解如何在 TeX 程式碼中執行 Lua 程式碼(透過\luadirect
),但不知道如何在 Lua 程式碼中執行 TeX 程式碼。
我解釋一下:我想從 luatex 清單中建立一系列 \let 命令。
我的 MWE 是
\def\a{s}
\directlua{
x = {"b","c"}
for y in pairs(x) do
print (y)
% I would like to \let\<y>\a
end
}
我希望 \directlua 產生類似的東西
\let\b\a
\let\c\a
答案1
您可能可以直接從 lua 修改 TeX 的雜湊表,但更簡單的是讓 lua 寫出語句\let
。
> \b=macro:
->s.
l.10 \show\b
?
> \c=macro:
->s.
l.11 \show\c
?
)
No pages of output
生產自:
\def\a{s}
\directlua{
x = {"b","c"}
for n,y in pairs(x) do
tex.print("\string\\let\string\\" .. y .. "\string\\a")
end
}
\show\b
\show\c
\bye