这是一个常见问题,但我点击的几个链接均未解决我的问题。MWE:
%XeLaTeX
\documentclass{standalone}
\usepackage[T1]{fontenc}
\usepackage[sfdefault]{AlegreyaSans}
%\usepackage{Alegreya} % this works fine!
\begin{document}
Test!
\end{document}
我收到错误信息:
! Undefined control sequence.
<argument> ... AlegreyaSansSC-\Alegreya@boldstyle
}, ItalicFeatures = { Smal...
l.151 {AlegreyaSans}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Undefined control sequence.
<argument> ... AlegreyaSansSC-\Alegreya@boldstyle
Italic },
l.151 {AlegreyaSans}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
Requested font "[AlegreyaSans-Regular.ttf]/OT" at 10.0pt
-> /usr/local/texlive/2016/texmf-dist/fonts/truetype/huerta/alegreya/AlegreyaSans-Regular.ttf
\g__fontspec_family_AlegreyaSans_int=\count124
Requested font "[AlegreyaSansSC-Regular.ttf]/OT" at 10.0pt
-> /usr/local/texlive/2016/texmf-dist/fonts/truetype/huerta/alegreya/AlegreyaSansSC-Regular.ttf
Requested font "[AlegreyaSans-Bold.ttf]/OT" at 10.0pt
-> /usr/local/texlive/2016/texmf-dist/fonts/truetype/huerta/alegreya/AlegreyaSans-Bold.ttf
Requested font "[AlegreyaSansSC-.ttf]/OT" at 10.0pt
-> font not found, using "nullfont"
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "AlegreyaSansSC-" cannot be found.
我不明白的是,例如,/usr/local/texlive/2016/texmf-dist/fonts/truetype/huerta/alegreya/AlegreyaSans-Regular.ttf
绝对存在!是否有权限问题导致无法访问此文件?
我在 Fedora 24 上使用 TeXlive 2016;在安装有 TeXlive 2015 的 Mac 上没有遇到这个问题;这是某种错误吗?
答案1
更新
下面描述的问题已于AlegreyaSans.sty
2016/09/15 版本中修复。
原始答案
这是AlegreyaSans.sty
宏中的错误;在一些地方
\Alegreya@boldstyle
用来代替\AlegreyaSans@boldstyle
。
您应该提交一个错误报告;同时,利用\setsansfont
执行时首次使用未定义的控制序列的事实,您可以使用以下技巧解决该问题:
\documentclass{standalone}
\usepackage[T1]{fontenc}
%%% Fix for the bug in AlegreyaSans
% make sure \setsansfont is defined
\usepackage{fontspec}
% start the fix by temporarily redefining
% \setsansfont to define the wrong macro
% to be the same as the right one
\makeatletter
% save a copy of \setsansfont
\let\fontspec@setsansfont\setsansfont
% redefine it to fix the issue and to redefine
% itself to the original one
\def\setsansfont{%
\let\Alegreya@boldstyle\AlegreyaSans@boldstyle
\let\setsansfont\fontspec@setsansfont
\setsansfont
}
\makeatother
%%% end of fix, now load AlegreyaSans
\usepackage[sfdefault]{AlegreyaSans}
\begin{document}
Test!
\end{document}