tex.error()
我们可以在 luatex 中犯错误,比如\PackageError
在 .sty 或\ClassError
.cls 中,但是如何在 luatex 中发出警告和信息,比如\PackageWarning
或\PackageInfo
?
答案1
LuaLaTeX 为此类用例提供module_info
了三个module_warning
函数:module_error
luatexbase
\documentclass{article}
\directlua{
luatexbase.module_info('mypackage', "For your information")
}
\directlua{
luatexbase.module_warning('mypackage', "Please don't do this")
}
\directlua{
luatexbase.module_error('mypackage', "That's not allowed")
}
\stop
答案2
我正在使用texio.write_nl()
,它在 vscode 中运行良好。但我不知道这是否是最好的方法。
texio.write_nl("term and log","(file.name")
texio.write_nl("term and log","Package package_name Warning: Your warning")
texio.write_nl("term and log","\n)")
texio.write_nl("term and log","(file.name")
texio.write_nl("term and log","Package package_name Info: Your info")
texio.write_nl("term and log","\n)")