无法解决 Xelatex 多语种和希腊语的问题

无法解决 Xelatex 多语种和希腊语的问题

我在排版希腊语时遇到了问题。

这是一个最小代码

\documentclass{article}

\usepackage{fontspec}

\usepackage{polyglossia}

\setmainfont[Mapping=tex-text]{fonts/Times New Roman.ttf}

\newfontfamily\greekfont[Mapping=tex-text]{fonts/Times New Roman.ttf}

\setdefaultlanguage[variant=modern]{greek}

\begin{document}

αβγδε

\end{document}

这会导致多个错误Missing number, treated as zero.,并且Missing = inserted for ifdim.

我究竟做错了什么?

注意:我确认我已经输入Times New Roman.ttffonts/这是为了稍后在 Overleaf 上使用特定的字体)。

编辑:我添加了完整的日志文件

This is XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022) (preloaded format=xelatex 2022.11.18)  1 JAN 2023 19:24
entering extended mode
 \write18 enabled.
 file:line:error style messages enabled.
 %&-line parsing enabled.
**test-stackexchange.tex
(./test-stackexchange.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-02-24>
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2021/10/04 v1.4n Standard LaTeX file (size option)
)
\c@part=\count181
\c@section=\count182
\c@subsection=\count183
\c@subsubsection=\count184
\c@paragraph=\count185
\c@subparagraph=\count186
\c@figure=\count187
\c@table=\count188
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen138
)
(/usr/local/texlive/2022/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3kernel/expl3.sty
Package: expl3 2022-02-24 L3 programming layer (loader) 

(/usr/local/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-xetex.def
File: l3backend-xetex.def 2022-02-07 L3 backend support: XeTeX

(|extractbb --version)
\c__kernel_sys_dvipdfmx_version_int=\count189
\l__color_backend_stack_int=\count190
\g__color_backend_stack_int=\count191
\g__graphics_track_int=\count192
\l__pdf_internal_box=\box50
\g__pdf_backend_object_int=\count193
\g__pdf_backend_annotation_int=\count194
\g__pdf_backend_link_int=\count195
))
Package: xparse 2022-01-12 L3 Experimental document command parser
)
Package: fontspec 2022/01/15 v2.8a Font selection for XeLaTeX and LuaLaTeX

(/usr/local/texlive/2022/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
Package: fontspec-xetex 2022/01/15 v2.8a Font selection for XeLaTeX and LuaLaTe
X
\l__fontspec_script_int=\count196
\l__fontspec_language_int=\count197
\l__fontspec_strnum_int=\count198
\l__fontspec_tmp_int=\count199
\l__fontspec_tmpa_int=\count266
\l__fontspec_tmpb_int=\count267
\l__fontspec_tmpc_int=\count268
\l__fontspec_em_int=\count269
\l__fontspec_emdef_int=\count270
\l__fontspec_strong_int=\count271
\l__fontspec_strongdef_int=\count272
\l__fontspec_tmpa_dim=\dimen139
\l__fontspec_tmpb_dim=\dimen140
\l__fontspec_tmpc_dim=\dimen141

(/usr/local/texlive/2022/texmf-dist/tex/latex/base/fontenc.sty
Package: fontenc 2021/04/29 v2.0v Standard LaTeX package
)
(/usr/local/texlive/2022/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/local/texlive/2022/texmf-dist/tex/latex/polyglossia/polyglossia.sty
Package: polyglossia 2021/04/12 v1.53 Modern multilingual typesetting with XeLa
TeX and LuaLaTeX

(/usr/local/texlive/2022/texmf-dist/tex/latex/etoolbox/etoolbox.sty
Package: etoolbox 2020/10/05 v2.5k e-TeX tools for LaTeX (JAW)
\etb@tempcnta=\count273
)
(/usr/local/texlive/2022/texmf-dist/tex/latex/makecmds/makecmds.sty
Package: makecmds 2009/09/03 v1.0a extra command making commands
)
(/usr/local/texlive/2022/texmf-dist/tex/latex/xkeyval/xkeyval.sty
Package: xkeyval 2020/11/20 v2.8 package option processing (HA)

(/usr/local/texlive/2022/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/xkeyval/xkvutils.tex
\XKV@toks=\toks16
\XKV@tempa@toks=\toks17

(/usr/local/texlive/2022/texmf-dist/tex/generic/xkeyval/keyval.tex))
\XKV@depth=\count274
File: xkeyval.tex 2014/12/03 v2.7a key=value parser (HA)
))
(/usr/local/texlive/2022/texmf-dist/tex/generic/iftex/iftex.sty
Package: iftex 2022/02/03 v1.0f TeX engine tests
)
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty
Package: l3keys2e 2022-01-12 LaTeX2e option processing using LaTeX3 keys
)

LaTeX hooks Warning: Generic hook 'file/after/tracklang.sty' is deprecated.
(hooks)              Use hook 'file/tracklang.sty/after' instead.


LaTeX hooks Warning: Generic hook 'package/after/bidi' is deprecated.
(hooks)              Use hook 'package/bidi/after' instead.


LaTeX hooks Warning: Generic hook 'package/after/luabidi' is deprecated.
(hooks)              Use hook 'package/luabidi/after' instead.

\xpg@normalclass=\XeTeXcharclass1
(/usr/local/texlive/2022/texmf-dist/tex/latex/polyglossia/gloss-latex.ldf
File: gloss-latex.ldf polyglossia: module for default language
The property list \polyglossia@langsetup contains the pairs (without outer
braces):
>  {latex/script}  =>  {latin}
>  {latex/lcscript}  =>  {latin}
>  {latex/scripttag}  =>  {}
>  {latex/language}  =>  {Latex}
>  {latex/langtag}  =>  {ENG}
>  {latex/bcp47}  =>  {}
>  {latex/hyphennames}  =>  {english}
>  {latex/direction}  =>  {LR}
>  {latex/hyphenmins}  =>  {2,3}
>  {latex/frenchspacing}  =>  {false}
>  {latex/indentfirst}  =>  {false}
>  {latex/fontsetup}  =>  {true}
>  {latex/envname}  =>  {latex}
>  {latex/babelname}  =>  {latex}
>  {latex/localnumeral}  =>  {polyglossia@C@localnumeral}
>  {latex/Localnumeral}  =>  {polyglossia@C@localnumeral}.
)
Package polyglossia Info: Default language is latex.
)

Package fontspec Info: Font family 'fonts/TimesNewRoman.ttf(0)' created for
(fontspec)             font 'fonts/Times New Roman.ttf' with options
(fontspec)             [Ligatures=TeX,Mapping=tex-text].
(fontspec)              
(fontspec)              This font family consists of the following NFSS
(fontspec)             series/shapes:
(fontspec)              
(fontspec)             - 'normal' (m/n) with NFSS spec.: <->"[fonts/Times New
(fontspec)             Roman.ttf]/OT:script=latn;language=dflt;mapping=tex-text
;"
(fontspec)             - 'small caps'  (m/sc) with NFSS spec.: 

LaTeX Font Info:    Trying to load font information for TU+fonts on input line 
8.
LaTeX Font Info:    No file TUfonts.fd. on input line 8.


LaTeX Font Warning: Font shape `TU/fonts/TimesNewRoman.ttf(0)/m' undefined
(Font)              using `TU/lmr/m/n' instead on input line 8.

./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing = inserted for ifdim.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 

./test-stackexchange.tex:8: LaTeX Error: Missing begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing = inserted for ifdim.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   def 
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   def 
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing = inserted for ifdim.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing = inserted for ifdim.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   def 
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   def 
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing = inserted for ifdim.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing = inserted for ifdim.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   def 
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   def 
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing = inserted for ifdim.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing = inserted for ifdim.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   def 
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   def 
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing = inserted for ifdim.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing = inserted for ifdim.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   def 
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   def 
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing = inserted for ifdim.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing = inserted for ifdim.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   def 
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   def 
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing = inserted for ifdim.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   <
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing = inserted for ifdim.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt inserted).
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Missing number, treated as zero.
<to be read again> 
                   n
l.8 
    
? 
./test-stackexchange.tex:8: Illegal unit of measure (pt ins

答案1

这对我有用,我希望对你也有用:

\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainfont{Times New Roman}
\newfontfamily\greekfont{Times New Roman}
\setdefaultlanguage{greek}
\begin{document}
    αβγδε
\end{document}

答案2

感谢 David Carlisle,我可以使用密钥[Path=fonts/]而不是将目录放在字体名称中来解决这个问题。

\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainfont[Path=fonts/]{Times New Roman.ttf}
\newfontfamily\greekfont[Path=fonts/]{Times New Roman.ttf}
\setdefaultlanguage{greek}
\begin{document}
    αβγδε
\end{document}

相关内容