fontspec:\set...font 带有 Scale 选项导致缺少 \begin{document}

fontspec:\set...font 带有 Scale 选项导致缺少 \begin{document}

我正在尝试使用 LuaLatex 中的 fontspec(最新的 MiKTex+TexStudio)进行基本字体设置,代码取自 Fonspec 手册

\usepackage{fontspec}
\setmainfont{Arial}
\setsansfont{Verdana}[Scale=MatchLowercase]
\setmonofont{Courier New}[Scale=MatchLowercase]

奇数错误

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.26    \setsansfont{Verdana}[
                          Scale=MatchLowercase]
You're in trouble here.  Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

如果我注释掉选项

\usepackage{fontspec}
\setmainfont{Arial}
\setsansfont{Verdana}%[Scale=MatchLowercase]
\setmonofont{Courier New}[Scale=MatchLowercase]

然后它抱怨下一行

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.27    \setmonofont{Courier New}[
                              Scale=MatchLowercase]
You're in trouble here.  Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

注释掉两个选项

\usepackage{fontspec}
\setmainfont{Arial}
\setsansfont{Verdana}%[Scale=MatchLowercase]
\setmonofont{Courier New}%[Scale=MatchLowercase]

编译无错误

我还尝试将选项移到字体名称前面(它应该也可以工作),但结果却更加错误

! Undefined control sequence.
\fontspec_calc_scale:n ...ec_tmpb_dim }\fp_div:Nn 
                                                  \l_fontspec_tmpa_fp {\l_fo...
l.26    \setsansfont[Scale=MatchLowercase]{Verdana}
                                               %[Scale=MatchLowercase]
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.


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "kernel/misused-fp"
! 
! A floating point with value '5.185546875' was misused.
! 
! See the LaTeX3 documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  

l.26    \setsansfont[Scale=MatchLowercase]{Verdana}
                                               %[Scale=MatchLowercase]
|'''''''''''''''''''''''''''''''''''''''''''''''
| To obtain the value of a floating point variable, use '\fp_to_decimal:N',
| '\fp_to_scientific:N', or other conversion functions.
|...............................................


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "kernel/misused-fp"
! 
! A floating point with value '5.4541015625' was misused.
! 
! See the LaTeX3 documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  

l.26    \setsansfont[Scale=MatchLowercase]{Verdana}
                                               %[Scale=MatchLowercase]
|'''''''''''''''''''''''''''''''''''''''''''''''
| To obtain the value of a floating point variable, use '\fp_to_decimal:N',
| '\fp_to_scientific:N', or other conversion functions.
|...............................................

.................................................
. fontspec info: "set-scale"
. 
. Verdana scale = 5.185546875.
.................................................
\g_fontspec_family_Verdana_int=\count290
luaotfload | load : auto-selecting default features for script: dflt
luaotfload | resolve : Font family='verdana', subfamily='regular' found: verdana
.ttf
! Undefined control sequence.
\fontspec_calc_scale:n ...ec_tmpb_dim }\fp_div:Nn 
                                                  \l_fontspec_tmpa_fp {\l_fo...
l.26    \setsansfont[Scale=MatchLowercase]{Verdana}
                                               %[Scale=MatchLowercase]
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.


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "kernel/misused-fp"
! 
! A floating point with value '5.185546875' was misused.
! 
! See the LaTeX3 documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  

l.26    \setsansfont[Scale=MatchLowercase]{Verdana}
                                               %[Scale=MatchLowercase]
|'''''''''''''''''''''''''''''''''''''''''''''''
| To obtain the value of a floating point variable, use '\fp_to_decimal:N',
| '\fp_to_scientific:N', or other conversion functions.
|...............................................


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "kernel/misused-fp"
! 
! A floating point with value '5.4541015625' was misused.
! 
! See the LaTeX3 documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  

l.26    \setsansfont[Scale=MatchLowercase]{Verdana}
                                               %[Scale=MatchLowercase]
|'''''''''''''''''''''''''''''''''''''''''''''''
| To obtain the value of a floating point variable, use '\fp_to_decimal:N',
| '\fp_to_scientific:N', or other conversion functions.
|...............................................

.................................................
. fontspec info: "set-scale"
. 
. Verdana scale = 5.185546875.

     \setsansfont[Scale=MatchLowercase]{Verdana}

从包装手册中复制的代码带来了很多麻烦...

编辑:

\documentclass{report}
\usepackage{fontspec}
\setmainfont{Arial}
\setsansfont{Verdana}[Scale=MatchLowercase]
\setmonofont{Courier New}[Scale=MatchLowercase]
\listfiles
\begin{document}
    Hello
\end{document}


 *File List*
  report.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
fontspec.sty    2013/05/20 v2.3c Font selection for XeLaTeX and LuaLaTeX
   expl3.sty    2015/06/15 v5630 L3 programming layer (loader) 
expl3-code.tex    2015/06/15 v5630 L3 programming layer 
    etex.sty    1998/03/26 v2.0 eTeX basic definition package (PEB)
l3unicode-data.def    2015/03/01 v5544 L3 Unicode data
l3pdfmode.def    2015/05/21 v5613 L3 Experimental driver: PDF mode
  xparse.sty    2015/06/15 v5630 L3 Experimental document command parser
luaotfload.sty    2013/07/23 v2.3b OpenType layout system
luatexbase.sty    2013/05/11 v0.6 Resource management for the LuaTeX macro progr
ammer
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
  luatex.sty    2010/03/09 v0.4 LuaTeX basic definition package (HO)
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
luatex-loader.sty    2010/03/09 v0.4 Lua module loader (HO)
luatexbase-compat.sty    2011/05/24 v0.4 Compatibility tools for LuaTeX
luatexbase-modutils.sty    2013/05/11 v0.6 Module utilities for LuaTeX
luatexbase-loader.sty    2013/05/11 v0.6 Lua module loader for LuaTeX
luatexbase-regs.sty    2011/05/24 v0.4 Registers allocation for LuaTeX
luatexbase-attr.sty    2013/05/11 v0.6 Attributes allocation for LuaTeX
luatexbase-cctb.sty    2013/05/11 v0.6 Catcodetable allocation for LuaTeX
luatexbase-mcb.sty    2013/05/11 v0.6 Callback management for LuaTeX
fontspec-patches.sty    2013/05/20 v2.3c Font selection for XeLaTeX and LuaLaTeX

fixltx2e.sty    2006/09/13 v1.1m fixes to LaTeX
fontspec-luatex.sty    2013/05/20 v2.3c Font selection for XeLaTeX and LuaLaTeX
 fontenc.sty
  eu2enc.def    2010/05/27 v0.1h Experimental Unicode font encodings
  eu2lmr.fd    2009/10/30 v1.6 Font defs for Latin Modern
xunicode.sty    2011/09/09 v0.981 provides access to latin accents and many othe
r characters in Unicode lower plane
 eu2lmss.fd    2009/10/30 v1.6 Font defs for Latin Modern
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2007/01/18 v1.5 graphics configuration of teTeX/TeXLive
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
pdftexcmds.sty    2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
fontspec.cfg
   t3cmr.fd    2001/12/31 TIPA font definitions
supp-pdf.mkii

答案1

原来我无意中安装了两个 MikTeX,这当然会搞乱维护。我卸载了两个,然后重新安装了一个,问题就消失了。真尴尬……

相关内容