我正在尝试使用 fontawesome 和 XeLaTeX 编译一个文档(请参阅此模板https://github.com/ReScience/ReScience-submission/tree/master/article)。我在 Ubuntu 中安装了 Texlive 2016(直接从 Texlive 主页安装 - 而不是 Ubuntu 存储库)。Texlivetlmgr
声称已安装 fontawesome。我似乎在这里找到了证据:
$ kpsewhich fontawesome.map
/usr/local/texlive/2016/texmf-dist/fonts/map/dvips/fontawesome/fontawesome.map
为了调试该问题,我尝试编译以下 MWE(test.tex):
\documentclass{article}
\usepackage{fontawesome}
\begin{document}
Test
\end{document}
使用命令xelatex test.tex
。当它似乎达到临界点时,日志显示:
kpathsea: Running mktextfm FontAwesome
/usr/local/texlive/2016/texmf-dist/web2c/mktexnam: Could not map source abbreviation F for FontAwesome.
/usr/local/texlive/2016/texmf-dist/web2c/mktexnam: Need to update /usr/local/texlive/2016/texmf-dist/fonts/map/fontname/special.map?
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input FontAwesome
This is METAFONT, Version 2.7182818 (TeX Live 2016) (preloaded base=mf)
kpathsea: Running mktexmf FontAwesome
! I can't find file `FontAwesome'.
<*> ...our; mag:=1; nonstopmode; input FontAwesome
Please type another input file name
! Emergency stop.
<*> ...our; mag:=1; nonstopmode; input FontAwesome
Transcript written on mfput.log.
grep: FontAwesome.log: Ingen sådan fil eller filkatalog
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input FontAwesome' failed to make FontAwesome.tfm.
kpathsea: Appending font creation commands to missfont.log.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "FontAwesome" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................
我已经运行过updmap-sys
和mktexlsr
,但似乎没有帮助。updmap-sys
说(除其他外):
Files generated:
/usr/local/texlive/2016/texmf-var/fonts/map/dvips/updmap:
15796 2017-05-10 16:22:38 builtin35.map
21269 2017-05-10 16:22:38 download35.map
1688569 2017-05-10 16:22:39 psfonts_pk.map
1903381 2017-05-10 16:22:38 psfonts_t1.map
1903376 2017-05-10 16:22:38 ps2pk.map
14 2017-05-10 16:22:39 psfonts.map -> psfonts_t1.map
/usr/local/texlive/2016/texmf-var/fonts/map/pdftex/updmap:
1903383 2017-05-10 16:22:39 pdftex_dl14.map
1901718 2017-05-10 16:22:39 pdftex_ndl14.map
15 2017-05-10 16:22:39 pdftex.map -> pdftex_dl14.map
/usr/local/texlive/2016/texmf-var/fonts/map/dvipdfmx/updmap:
319 2017-05-10 16:22:38 kanjix.map
是否也应该有一个 xelatex 文件夹?我该怎么做才能解决这个问题?
答案1
fontawesome 通过名称加载字体:\newfontfamily{\FA}{FontAwesome}
。字体(fontawesome.otf)位于 fonts/opentype/public/fontawesome 的 texmf-tree 中。
在 Windows 上这没问题。Linux 系统上,字体配置不会搜索 texmf-tree,因此找不到字体。
可能的解决方案
1.使用文件名:
\documentclass{article}
\usepackage{fontawesome}
\newfontfamily{\FA}{fontawesome.otf}
\begin{document}
\faHourglass
\end{document}
2. 将字体复制到系统字体文件夹。
3. 将 texmf 树添加到你的字体配置中。
https://www.tug.org/texlive/doc/texlive-en/texlive-en.html#x1-340003.4.4
答案2
FontAwesome 文档说您必须使用 fontspec 包才能与 xelatex 一起使用\documentclass{article} \usepackage{fontspec} \usepackage{fontawesome} \begin{document} \faicon{500px} \end{document}
。注意:请参阅文档以获取其定义的所有宏的完整列表。
PS:完全更新的完整版 TeX Live 2016 已经包含 fontawesome,所以我不明白为什么你必须安装它。