如何使用fontspec
包正确编译文档?
示例代码(15.1.XeTeX @ LaTeX-wikibooks.pdf)
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Arial}
\begin{document}
Lorem ipsum...
\end{document}
结果$latex fontspec.tex
This is pdfTeXk, Version 3.1415926-1.40.9 (Web2C 7.5.7)
%&-line parsing enabled.
entering extended mode
(./fontspec.tex
LaTeX2e <2005/12/01
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, german-x-2008-06-18, ngerman-x-2008-06-18, ancientgreek, ibycus, ar
abic, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danish, dutc
h, esperanto, estonian, farsi, finnish, french, galician, german, ngerman, mono
greek, greek, hungarian, icelandic, indonesian, interlingua, irish, italian, la
tin, mongolian, mongolian2a, bokmal, nynorsk, polish, portuguese, romanian, rus
sian, sanskrit, serbian, slovak, slovenian, spanish, swedish, turkish, ukenglis
h, ukrainian, uppersorbian, welsh, loaded.
(/usr/share/texmf/tex/latex/base/article.cls
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/size10.clo)) (./fontspec.sty
(/usr/share/texmf/tex/latex/expl3/expl3.sty
(/usr/share/texmf/tex/latex/expl3/l3names.sty)
(/usr/share/texmf/tex/latex/etex-pkg/etex.sty)
(/usr/share/texmf/tex/latex/expl3/l3basics.sty)
(/usr/share/texmf/tex/latex/expl3/l3expan.sty)
(/usr/share/texmf/tex/latex/expl3/l3tl.sty)
(/usr/share/texmf/tex/latex/expl3/l3intexpr.sty)
(/usr/share/texmf/tex/latex/expl3/l3quark.sty)
(/usr/share/texmf/tex/latex/expl3/l3seq.sty
! Undefined control sequence.
l.129 \int_new:N
\g_seq_nesting_depth_int
?
结果$lualatex fontspec.tex
This is LuaTeX, Version snapshot-0.25.4-2009102410 (Web2C 7.5.7)
(fontspec.tex>
LaTeX2e <2005/12/01>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, german-x-2008-06-18, ngerman-x-2008-06-18, ancientgreek, ibycus, ar
abic, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danish, dutc
h, esperanto, estonian, farsi, finnish, french, galician, german, ngerman, mono
greek, greek, hungarian, icelandic, indonesian, interlingua, irish, italian, la
tin, mongolian, mongolian2a, bokmal, nynorsk, polish, portuguese, romanian, rus
sian, sanskrit, serbian, slovak, slovenian, spanish, swedish, turkish, ukenglis
h, ukrainian, uppersorbian, welsh, loaded.
(/usr/share/texmf/tex/latex/base/article.cls
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/size10.clo)) (fontspec.sty
(/usr/share/texmf/tex/latex/expl3/expl3.sty
(/usr/share/texmf/tex/latex/expl3/l3names.sty
(/usr/share/texmf/tex/generic/oberdiek/luatex.sty
(/usr/share/texmf/tex/generic/oberdiek/infwarerr.sty)
(/usr/share/texmf/tex/generic/oberdiek/ifluatex.sty)
(/usr/share/texmf/tex/latex/etex-pkg/etex.sty)
(/usr/share/texmf/tex/generic/oberdiek/luatex-loader.sty
(/usr/share/texmf/scripts/oberdiek/oberdiek.luatex.lua)))
(/usr/share/texmf/tex/generic/oberdiek/pdftexcmds.sty
(/usr/share/texmf/scripts/oberdiek/oberdiek.pdftexcmds.lua)))
(/usr/share/texmf/tex/latex/expl3/l3basics.sty)
(/usr/share/texmf/tex/latex/expl3/l3expan.sty)
(/usr/share/texmf/tex/latex/expl3/l3tl.sty)
(/usr/share/texmf/tex/latex/expl3/l3intexpr.sty)
(/usr/share/texmf/tex/latex/expl3/l3quark.sty)
(/usr/share/texmf/tex/latex/expl3/l3seq.sty
! Undefined control sequence.
l.129 \int_new:N
\g_seq_nesting_depth_int
?
结果$xelatex fontspec.tex
This is XeTeXk, Version 3.1415926-2.2-0.999.6 (Web2C 7.5.7)
%&-line parsing enabled.
entering extended mode
(./fontspec0.tex
LaTeX2e <2005/12/01>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, german-x-2008-06-18, ngerman-x-2008-06-18, ancientgreek, ibycus, ar
abic, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danish, dutc
h, esperanto, estonian, farsi, finnish, french, galician, german, ngerman, mono
greek, greek, hungarian, icelandic, indonesian, interlingua, irish, italian, la
tin, mongolian, mongolian2a, bokmal, nynorsk, polish, portuguese, romanian, rus
sian, sanskrit, serbian, slovak, slovenian, spanish, swedish, turkish, ukenglis
h, ukrainian, uppersorbian, welsh, loaded.
(/usr/share/texmf/tex/latex/base/article.cls
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/size10.clo)) (./fontspec.sty
(/usr/share/texmf/tex/xelatex/expl3/expl3.sty
(/usr/share/texmf/tex/xelatex/expl3/l3names.sty>
! Package l3names Error: Required primitive not found: \pdfstrcmp.>
See the l3names package documentation for explanation.>
Type H <return> for immediate help.>
...>
l.121 }>
第二个示例(#2:3 测试 F-autofake @ fontspec/fontspec-testsuite.pdf)
\documentclass{testsuite}
\usepackage{fontspec}
\begin{document}
\Large
\def\text{ABC \textit{ABC} \textbf{ABC}
\textbf{\textit{ABC}}\\}
\fontspec{Inconsolata}
\fontspec[AutoFakeSlant]{Inconsolata}
\fontspec[AutoFakeBold]{Inconsolata}
\fontspec[AutoFakeSlant,AutoFakeBold]
{Inconsolata}
\fontspec[AutoFakeSlant=0.4]{Inconsolata}
\fontspec[AutoFakeBold=5]{Inconsolata}
\fontspec[AutoFakeSlant=0.4,AutoFakeBold=5]
{Inconsolata}
\end{document}
结果$latex/lualatex/xelatex fontspec1.tex
This is XeTeXk, Version 3.1415926-2.2-0.999.6 (Web2C 7.5.7)
%&-line parsing enabled.
entering extended mode
(./fontspec1.tex
LaTeX2e <2005/12/01>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, german-x-2008-06-18, ngerman-x-2008-06-18, ancientgreek, ibycus, ar
abic, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danish, dutc
h, esperanto, estonian, farsi, finnish, french, galician, german, ngerman, mono
greek, greek, hungarian, icelandic, indonesian, interlingua, irish, italian, la
tin, mongolian, mongolian2a, bokmal, nynorsk, polish, portuguese, romanian, rus
sian, sanskrit, serbian, slovak, slovenian, spanish, swedish, turkish, ukenglis
h, ukrainian, uppersorbian, welsh, loaded.>
! LaTeX Error: File `testsuite.cls' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: cls)
Enter file name:
(./fontspec.sty (/usr/share/texmf/tex/latex/expl3/expl3.sty
(/usr/share/texmf/tex/latex/expl3/l3names.sty)
(/usr/share/texmf/tex/latex/etex-pkg/etex.sty)
(/usr/share/texmf/tex/latex/expl3/l3basics.sty)
(/usr/share/texmf/tex/latex/expl3/l3expan.sty)
(/usr/share/texmf/tex/latex/expl3/l3tl.sty)
(/usr/share/texmf/tex/latex/expl3/l3intexpr.sty)
(/usr/share/texmf/tex/latex/expl3/l3quark.sty)
(/usr/share/texmf/tex/latex/expl3/l3seq.sty
! Undefined control sequence.
l.129 \int_new:N
\g_seq_nesting_depth_int
?
请问您能告诉我这里的问题是什么吗?
答案1
您的 TeX 安装太旧,无法使用fontspec
。您至少需要 XeTeX 0.9994 或 LuaTeX 0.40,详情请参阅LaTeX3 自述文件和其他文档。您需要安装更多最新的二进制文件,这实际上意味着更新的 TeX Live(我看到您使用的是 Unix)。