如果我要构建 MWE,我就会得到答案,但我试图避免所有这些反复试验。
所以我使用 XeLaTeX 并直接和间接地加载大量的包。
如果我有类似的东西
% [loads of stuff above this point]
% \newcommand{\Eta}{H} % Latin H causes fewer problems than using Greek.
\begin{document}
\renewcommand{\Eta}{H} % Latin H causes fewer problems than using Greek.
\show\Eta
然后我得到 \Eta 被定义为拉丁语 H。
但如果我这么做
% [loads of stuff above this point]
\newcommand{\Eta}{H} % Latin H causes fewer problems than using Greek.
\begin{document}
% \renewcommand{\Eta}{H} % Latin H causes fewer problems than using Greek.
\show\Eta
然后\show\Eta
告诉我
> \Eta=macro:
->\mitEta .
l.62 \show\Eta
在我使用的文档中的某些地方\Eta
,当字体中没有希腊字母时,我会遇到问题。例如,我收到如下警告
Missing character: There is no
答案1
如果你想知道哪些包在开始文档钩子中留下了代码,你可以使用\ShowHook
\documentclass{article}
% lots of excellent packages
\usepackage{longtable,dcolumn,colortbl,plain,bm,indentfirst,afterpage}
\usepackage{unicode-math}
\ShowHook{begindocument}
\begin{document}
x
\end{document}
生成日志
-> The hook 'begindocument':
> Code chunks:
> color -> \def \KV@Gin@bbllx {\PackageError {luatex.def}{Options `bblly',
`bblly', `bburx', `bbury',\MessageBreak `natheight' and `natwidth' are not\Mess
ageBreak supported by luatex driver:\MessageBreak use `viewport' instead}\@ehc
}\let \KV@Gin@bblly \KV@Gin@bbllx \let \KV@Gin@bburx \KV@Gin@bbllx \let \KV@Gin
@bbury \KV@Gin@bbllx \let \KV@Gin@natwidth \KV@Gin@bbllx \let \KV@Gin@natheight
\KV@Gin@bbllx \def \KV@Gin@bb {\PackageInfo {luatex.def}{Option `bb' equivalen
t to `viewport' with the luatex driver}\KV@Gin@viewport }\let \Gin@iii \Gin@iii
@vp \ifnum \mag =\@m \@ifundefined {stockwidth}{\@ifundefined {paperwidth}{}{\i
fdim \paperwidth >0pt\relax \ifdim \paperheight >0pt\relax \pagewidth =\paperwi
dth \pageheight =\paperheight \fi \fi }}{\ifdim \stockwidth >0pt\relax \ifdim \
stockheight >0pt\relax \setlength {\pagewidth }{\stockwidth }\setlength {\pageh
eight }{\stockheight }\else \ifdim \paperwidth >0pt\relax \ifdim \paperheight >
0pt\relax \setlength {\pagewidth }{\paperwidth }\setlength {\pageheight }{\pape
rheight }\fi \fi \fi \else \ifdim \stockwidth =0pt\relax \ifdim \paperwidth >0p
t\relax \ifdim \paperheight >0pt\relax \setlength {\pagewidth }{\paperwidth }\s
etlength {\pageheight }{\paperheight }\fi \fi \fi \fi }\fi \GPT@LoadSuppPdf \le
t \default@color \current@color \ifx \includegraphics \@undefined \else \@ifpac
kageloaded {pst-pdf}{}{\@ifpackageloaded {pdftricks}{}{\@ifpackageloaded {graph
ics}{\ifnum \directlua {tex.sprint(status.shell_escape)}>0 \edef \Gin@extension
s {\Gin@extensions ,.eps}\RequirePackage {epstopdf-base}[2009/07/12]\fi }{} }}\
fi
> colortbl -> \expandafter \def \expandafter \@tabarray \expandafter {\expa
ndafter \CT@start \@tabarray }\def \@tempa {$\hfil \egroup \box \z@ \box \tw@ }
\ifx \@tempa \DC@endright \def \DC@endright {$\hfil \egroup \ifx \DC@rl \bgroup
\hskip \stretch {-.5}\box \z@ \box \tw@ \hskip \stretch {-.5}\else \box \z@ \b
ox \tw@ \fi }\else \def \@tempa {$\hfil \egroup \hfill \box \z@ \box \tw@ }\ifx
\@tempa \DC@endright \def \DC@endright {$\hfil \egroup \hskip \stretch {.5}\bo
x \z@ \box \tw@ \hskip \stretch {-.5}}\fi \fi \ifx \hhline \@undefined \else \d
ef \HH@box ##1##2{\vbox {{\ifx \CT@drsc@ \relax \else \global \dimen \thr@@ \tw
@ \arrayrulewidth \global \advance \dimen \thr@@ \doublerulesep {\CT@drsc@ \hru
le \@height \dimen \thr@@ \vskip -\dimen \thr@@ }\fi \CT@arc@ \hrule \@height \
arrayrulewidth \@width ##1 \vskip \doublerulesep \hrule \@height \arrayrulewidt
h \@width ##2}}} \def \HH@loop {\ifx \@tempb `\def \next ####1{\the \toks@ \cr
}\else \let \next \HH@let \ifx \@tempb |\if@tempswa \ifx \CT@drsc@ \relax \HH@a
dd {\hskip \doublerulesep }\else \HH@add {{\CT@drsc@ \vrule \@width \doublerule
sep }}\fi \fi \@tempswatrue \HH@add {{\CT@arc@ \vline }}\else \ifx \@tempb :\if
@tempswa \ifx \CT@drsc@ \relax \HH@add {\hskip \doublerulesep }\else \HH@add {{
\CT@drsc@ \vrule \@width \doublerulesep }}\fi \fi \@tempswatrue \HH@add {\@temp
c \HH@box \arrayrulewidth \arrayrulewidth \@tempc }\else \ifx \@tempb ####\if@t
empswa \HH@add {\hskip \doublerulesep }\fi \@tempswatrue \HH@add {{\CT@arc@ \vl
ine \copy \@ne \@tempc \vline }}\else \ifx \@tempb ~\@tempswafalse \if@firstamp
\@firstampfalse \else \HH@add {&\omit }\fi \ifx \CT@drsc@ \relax \HH@add {\hfi
l }\else \HH@add {{\CT@drsc@ \leaders \hrule \@height \HH@height \hfil }}\fi \e
lse \ifx \@tempb -\@tempswafalse \gdef \HH@height {\arrayrulewidth }\if@firstam
p \@firstampfalse \else \HH@add {&\omit }\fi \HH@add {{\CT@arc@ \leaders \hrule
\@height \arrayrulewidth \hfil }}\else \ifx \@tempb =\@tempswafalse \gdef \HH@
height {\dimen \thr@@ }\if@firstamp \@firstampfalse \else \HH@add {&\omit }\fi
\HH@add {\rlap {\copy \@ne }\leaders \copy \@ne \hfil \llap {\copy \@ne }}\else
\ifx \@tempb t\HH@add {\def \HH@height {\dimen \thr@@ }\HH@box \doublerulesep
\z@ }\@tempswafalse \else \ifx \@tempb b\HH@add {\def \HH@height {\dimen \thr@@
}\HH@box \z@ \doublerulesep }\@tempswafalse \else \ifx \@tempb >\def \next ###
#1####2{\HH@add {{\baselineskip \p@ \relax ####2\global \setbox \@ne \HH@box \d
oublerulesep \doublerulesep }}\HH@let !}\else \ifx \@tempb \@sptoken \let \next
\HH@spacelet \else \PackageWarning {hhline}{\meaning \@tempb \space ignored in
\noexpand \hhline argument\MessageBreak }\fi \fi \fi \fi \fi \fi \fi \fi \fi \
fi \fi \next } \lowercase {\def \HH@spacelet } {\futurelet \@tempb \HH@loop } \
fi \ifx \longtable \@undefined \else \def \LT@@hline {\ifx \LT@next \hline \gl
obal \let \LT@next \@gobble \ifx \CT@drsc@ \relax \gdef \CT@LT@sep {\noalign {\
penalty -\@medpenalty \vskip \doublerulesep }}\else \gdef \CT@LT@sep {\multispa
n \LT@cols {\CT@drsc@ \leaders \hrule \@height \doublerulesep \hfill }\cr }\fi
\else \global \let \LT@next \empty \gdef \CT@LT@sep {\noalign {\penalty -\@lowp
enalty \vskip -\arrayrulewidth }}\fi \ifnum 0=`{\fi }\multispan \LT@cols {\CT@a
rc@ \leaders \hrule \@height \arrayrulewidth \hfill }\cr \CT@LT@sep \multispan
\LT@cols {\CT@arc@ \leaders \hrule \@height \arrayrulewidth \hfill }\cr \noalig
n {\penalty \@M }\LT@next } \fi
> fontspec-luatex -> \tl_set_eq:NN \cyrillicencoding \g_fontspec_encoding_t
l \tl_set_eq:NN \latinencoding \g_fontspec_encoding_tl \RenewDocumentCommand \o
ldstylenums {m}{\__fontspec_main_oldstylenums:n {##1}}\fontspec_maybe_setup_mat
hs:
> amsmath -> \reset@strutbox@ \MakeRobust \dddot \MakeRobust \ddddot \Umath
charnumdef \std@minus \Umathcodenum `\-\relax \Umathcharnumdef \std@equal \Umat
hcodenum `\=\relax \expandafter \let \csname overleftarrow \endcsname \@undefin
ed \expandafter \let \csname overrightarrow \endcsname \@undefined \MakeRobust
\overrightarrow \MakeRobust \overleftarrow \MakeRobust \overleftrightarrow \Mak
eRobust \underrightarrow \MakeRobust \underleftarrow \MakeRobust \underleftrigh
tarrow
> unicode-math-luatex -> \__um_define_math_chars: \tl_if_eq:onT {\g__fontsp
ec_mathrm_tl }{\rmdefault }{\__fontspec_setmathrm_hook:nn {}{}}\tl_if_eq:onT {\
g__fontspec_mathsf_tl }{\sfdefault }{\__fontspec_setmathsf_hook:nn {}{}}\tl_if_
eq:onT {\g__fontspec_mathtt_tl }{\ttdefault }{\__fontspec_setmathtt_hook:nn {}{
}}\bool_if:NF \g__um_main_font_defined_bool \__um_load_lm: \__um_setup_mathtext
: \__um_define_prime_commands: \__um_define_prime_chars: \cs_new_protected:Npn
\__um_patch_url: {\tl_put_left:Nn \Url@FormatString {\__um_switch_to:n {literal
}}\tl_put_right:Nn \UrlSpecials {\do \`{\mathchar `\`}\do \'{\mathchar `\'}\do
\${\mathchar `\$}\do \&{\mathchar `\&}}}\@ifpackageloaded {url}{\__um_patch_url
: }{}\cs_new_protected:Npn \__um_patch_mathtools_B: {\cs_set_eq:NN \MToverbrack
et \overbracket \cs_set_eq:NN \MTunderbracket \underbracket \AtBeginDocument {\
msg_warning:nn {unicode-math}{mathtools-overbracket}\cs_set:Npn \downbracketfil
l ####1####2{\tl_set:Nn \l_MT_bracketheight_fdim {.27ex}\downbracketend {####1}
{####2}\leaders \vrule \@height ####1\@depth \z@ \hfill \downbracketend {####1}
{####2}}\cs_set:Npn \upbracketfill ####1####2{\tl_set:Nn \l_MT_bracketheight_fd
im {.27ex}\upbracketend {####1}{####2}\leaders \vrule \@height \z@ \@depth ####
1\hfill \upbracketend {####1}{####2}}\cs_set_eq:NN \Uoverbracket \overbracket \
cs_set_eq:NN \Uunderbracket \underbracket \cs_set_eq:NN \overbracket \MToverbra
cket \cs_set_eq:NN \underbracket \MTunderbracket }}\@ifpackageloaded {mathtools
}{\__um_patch_mathtools_B: }{}\cs_new_protected:Npn \__um_patch_mathtools_C: {\
msg_warning:nn {unicode-math}{mathtools-colon}\DeclareDocumentCommand \dblcolon
{}{\Colon }\DeclareDocumentCommand \coloneqq {}{\coloneq }\DeclareDocumentComm
and \Coloneqq {}{\Coloneq }\DeclareDocumentCommand \eqqcolon {}{\eqcolon }}\@if
packageloaded {mathtools}{\__um_patch_mathtools_C: }{}\Umathcharnumdef \std@min
us \Umathcodenum `-\Umathcharnumdef \std@equal \Umathcodenum `=\debug_suspend:
\__um_resolve_greek: \debug_resume: \@ifpackageloaded {amsmath}{}{\__um_redefin
e_radical: }\__um_setup_active_frac: \g__um_secret_hook_tl
> Document-level (top-level) code (executed last):
> ---
> Extra code for next invocation:
> ---
> Rules:
> ---
> Execution order:
> color, colortbl, fontspec-luatex, amsmath, unicode-math-luatex.
<recently read> }
l.6 \ShowHook{begindocument}
?
每个包留下的确切代码块可能读起来并不令人兴奋,但它确实表明只有这些包才是有趣的
> Execution order:
> color, colortbl, fontspec-luatex, amsmath, unicode-math-luatex.
从那里可以很容易地举一个例子,并一次删除一半的包,缩小查找范围,unicode-math
在这里负责。
答案2
答案似乎是unicode 数学包。其文档的第 6.2 节指出
unicode-math 通过 \AtBeginDocument 定义宏,即延迟定义直到满足 \begin{document}。如果要覆盖 unicode-math 定义的宏,请在加载此包后在 \AtBeginDocument 中重新定义。
它之所以如此行事,是因为它非常合理地希望在定义某些宏之前设置字体。
我没有以任何特别系统的方式识别定义 \Eta 的包,但我确实使用 Google 搜索了 \mitEta(我认为是“Math Italic Eta”)。出现了几个对 unicode-math 的引用。所以我真的没有针对我的问题的一般形式的一般答案。