基本上,TeX 有很多要说的,而我对其中的大部分都不感兴趣。如果我感兴趣的话,我会阅读日志。silence 包会抑制输出,但它也会抑制输出到日志,而且,它只会抑制部分输出,远远不够。我不希望每次运行命令时都出现数百行输出,但我仍然希望被告知错误并给出提示。
我知道我可以运行类似
lualatex myfile.tex 1>/dev/null
或者批处理模式,简单地抑制所有输出。但是当 LuaTeX 告诉我编译错误时,它很有用,我想保留它,同时删除其他所有内容。
答案1
您可以使用报告回调关闭大多数消息,例如
\documentclass{article}
\usepackage{array}
\begin{document}
\zzz
\end{document}
产生终端输出
This is LuaTeX, Version 1.0.4 (TeX Live 2017)
restricted system commands enabled.
(./pp009.tex
LaTeX2e <2017-04-15>
(using write cache: /usr/local/texlive/2017/texmf-var/luatex-cache/generic)(usi
ng read cache: /usr/local/texlive/2017/texmf-var/luatex-cache/generic /home/dav
idc/.texlive2017/texmf-var/luatex-cache/generic)
luaotfload | main : initialization completed in 0.652 seconds
Babel <3.10> and hyphenation patterns for 1 language(s) loaded.
(/home/davidc/texmf/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/home/davidc/texmf/tex/latex/base/size10.clo(load luc: /usr/local/texlive/2017
/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.luc)))
(/home/davidc/texmf/tex/latex/tools/array.sty) (./pp009.aux)
! Undefined control sequence.
l.7 \zzz
?
(./pp009.aux))
365 words of node memory still in use:
2 hlist, 1 vlist, 1 rule, 2 glue, 4 attribute, 46 glue_spec, 4 attribute_lis
t, 2 write nodes
avail lists: 2:7,3:1,4:1,5:4,7:1,8:1,9:1
warning (pdf backend): no pages of output.
Transcript written on pp009.log.
但
\directlua{
function be_quiet ()
end
luatexbase.add_to_callback('start_run', be_quiet, 'stop start run')
luatexbase.add_to_callback('stop_run', be_quiet, 'stop stop run')
luatexbase.add_to_callback('start_page_number', be_quiet, 'stop start page')
luatexbase.add_to_callback('stop_page_number', be_quiet, 'stop stop page')
luatexbase.add_to_callback('start_file', be_quiet, 'stop start file')
luatexbase.add_to_callback('stop_file', be_quiet, 'stop stop file')
luatexbase.add_to_callback('show_warning_message', be_quiet, 'stop show warning message')
}
\documentclass{article}
\usepackage{array}
\begin{document}
\zzz
\end{document}
产生终端输出
This is LuaTeX, Version 1.0.4 (TeX Live 2017)
restricted system commands enabled.
(./pp009.tex
LaTeX2e <2017-04-15>
(using write cache: /usr/local/texlive/2017/texmf-var/luatex-cache/generic)(usi
ng read cache: /usr/local/texlive/2017/texmf-var/luatex-cache/generic /home/dav
idc/.texlive2017/texmf-var/luatex-cache/generic)
luaotfload | main : initialization completed in 0.664 seconds
Babel <3.10> and hyphenation patterns for 1 language(s) loaded.
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(load luc: /usr/local/texlive/2017/texmf-var/luatex-cache/generic/fonts/otl/lmr
oman10-regular.luc)
! Undefined control sequence.
l.18 \zzz
?