Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在公式环境里面出现 \hat 出错 #1

Closed
hqyyqh opened this issue Jan 16, 2019 · 3 comments
Closed

在公式环境里面出现 \hat 出错 #1

hqyyqh opened this issue Jan 16, 2019 · 3 comments

Comments

@hqyyqh
Copy link

hqyyqh commented Jan 16, 2019

文件 :elegantpaper-cn.tex
情况复现:

\begin{equation}
\hat{a}
\end{equation}

提示:

Package hyperref Warning: Rerun to get /PageLabels entry.

*geometry* driver: auto-detecting
*geometry* detected driver: xetex

Package microtype Warning: One or more slots in the configuration are unknown.
(microtype)                Make sure that no text commands are used.
(microtype)                See the documentation for details (the note
(microtype)                on `xeCJK' in section 9: `Hints and caveats').

(/usr/local/texlive/2018/texmf-dist/tex/latex/newtx/untxmia.fd)
(/usr/local/texlive/2018/texmf-dist/tex/latex/newtx/untxsym.fd)
(/usr/local/texlive/2018/texmf-dist/tex/latex/newtx/untxsyc.fd)
! Internal error: bad native font flag in `map_char_to_glyph'

希望东哥有时间能看看哦

@EthanDeng
Copy link
Member

EthanDeng commented Jan 16, 2019

根据 TeX.StackExchange 的描述:

This a bug in XeTeX resulting from mixing the OpenType (AKA "native") font Libertine with accent from the TFM font newtxmath.

也就是字体的搭配问题,然后我查到的解决方法是:重新定义重音符号命令(\hat\dot 等)。这个方法我试了下,可以解决,但是治标不治本,而且代码繁琐,需要往 cls 里面加很多自定义代码。然后我想到会不会是我造成的问题,因为之前当时为了让公式中的数字使用 Times New Roman 字体(默认是 Computer Modern 字体, newtxmath 宏包导致的)使用了下面代码(需要删除):

\DeclareSymbolFont{operators}{\encodingdefault}{\familydefault}{m}{n}

然后我就搜了下,发现其实让数字使用 Times New Roman /Times 族字体还有其他方式:

  1. 借壳
\setmainfont{Times New Roman}

改为

\setmainfont{Times New Roman}[NFSSFamily=ntxtlf]
  1. 设定字体
\DeclareSymbolFont{operators}{OT1}{ntxtlf}{m}{n}
\SetSymbolFont{operators}{bold}{OT1}{ntxtlf}{b}{n}

这两种方法都能解决这个问题,你可以试下。

最后,我把修正过的代码上传了,谢谢反馈!

@hqyyqh
Copy link
Author

hqyyqh commented Jan 16, 2019

问题解决了。很详细的回复,非常感谢。

@Liam0205
Copy link
Member

@EthanDeng 赞高效,赞详细~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants