错误消息和换行符

错误消息和换行符

!以下错误信息中,为什么感叹号( )会重复出现?

\def\error#1#2{%
  \begingroup
  \errhelp{#2}%
  \errmessage{^^J! package Error: #1^^J}%
  \endgroup
}
\error{Stop now.}{Hi, don't go on.}


! 
! package Error: Stop now.

答案1

第一个感叹号是\errmessage单独提供的:

\def\error#1#2{%
  \begingroup
    \errhelp{[ERRHELP: #2]}%
    \errmessage{[ERRMESSAGE: #1]}
  \endgroup
}
\error{Stop now.}{Hi, don't go on.}

文件.log

This is TeX, Version 3.1415926 (TeX Live 2011)
(./test.tex
! [ERRMESSAGE: Stop now.].
\error ...HELP: #2]}\errmessage {[ERRMESSAGE: #1]}
                                                   \endgroup 
l.7 \error{Stop now.}{Hi, don't go on.}

? h
[ERRHELP: Hi, don't go on.]
? x
No pages of output.
Transcript written on test.log.

相关内容