我是排版马拉雅拉姆语的新手。我尝试使用 XeLaTeX 将简单的代码编译为 pdf:
\documentclass[11pt]{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{malayalam}
\setmainfont{[Rachana-Regular.ttf]}
\setlanghyphenmins{malayalam}{3}{4}
\linespread{1.2}
\begin{document}
വിഷയം:
\end{document}
(我放在了Rachana-Regular.ttf
同一个文件夹中)
但编译后xelatex
会出现这样的情况:
This is XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022/Termux) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
(./r.tex
LaTeX2e <2022-11-01> patch level 1
L3 programming layer <2022-11-02>
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/base/articl
e.cls
Document Class: article 2022/07/02 v1.4n Standard LaTeX document class
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/base/size11
.clo))
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/fontspec/fo
ntspec.sty
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/l3packages/
xparse/xparse.sty
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/l3kernel/ex
pl3.sty
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/l3backend/l
3backend-xetex.def)))
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/fontspec/fo
ntspec-xetex.sty
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/base/fonten
c.sty)
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/fontspec/fo
ntspec.cfg)))
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/polyglossia
/polyglossia.sty
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/etoolbox/et
oolbox.sty)
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/makecmds/ma
kecmds.sty)
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/xkeyval/xke
yval.sty
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/generic/xkeyval/x
keyval.tex
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/generic/xkeyval/x
kvutils.tex
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/generic/xkeyval/k
eyval.tex))))
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/generic/iftex/ift
ex.sty)
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/l3packages/
l3keys2e/l3keys2e.sty)
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/polyglossia
/gloss-latex.lde))
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/polyglossia
/gloss-malayalam.ldf
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.3
\ProvidesFile{gloss-malayalam.ldf}[polyglossia: module for Malayalam]
?
与lualatex
:
~ lualatex r.tex
This is LuaHBTeX, Version 1.15.0 (TeX Live 2022/Termux)
restricted system commands enabled.
(./r.tex
LaTeX2e <2022-11-01> patch level 1
L3 programming layer <2022-11-02>
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/base/articl
e.cls
Document Class: article 2022/07/02 v1.4n Standard LaTeX document class
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/base/size11
.clo))
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/fontspec/fo
ntspec.sty
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/l3packages/
xparse/xparse.sty
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/l3kernel/ex
pl3.sty
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/l3backend/l
3backend-luatex.def)))
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/fontspec/fo
ntspec-luatex.sty
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/base/fonten
c.sty)
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/fontspec/fo
ntspec.cfg)))
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/polyglossia
/polyglossia.sty
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/etoolbox/et
oolbox.sty)
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/makecmds/ma
kecmds.sty)
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/xkeyval/xke
yval.sty
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/generic/xkeyval/x
keyval.tex
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/generic/xkeyval/x
kvutils.tex
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/generic/xkeyval/k
eyval.tex))))
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/generic/iftex/ift
ex.sty)
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/l3packages/
l3keys2e/l3keys2e.sty)
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/luatex/luatexbase
/luatexbase.sty
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/luatex/ctablestac
k/ctablestack.sty))
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/polyglossia
/gloss-latex.lde))
(/data/data/com.termux/files/usr/share/texlive/texmf-dist/tex/latex/polyglossia
/gloss-malayalam.ldf
Module polyglossia Warning: Language malayalam not found in language.dat.lua on
input line 15
Module polyglossia Warning: Language malayalam not found in language.dat.lua on
input line 15
Package polyglossia Warning: No hyphenation patterns were loaded for `malayalam
'
(polyglossia) I will use \language=\l@nohyphenation instead on i
nput line 15.
)
Package polyglossia Warning: id:ml on input line 6.
(./r.aux
! Package polyglossia Error: The current latin roman font does not contain the
"Malayalam" script!
(polyglossia) Please define \malayalamfont with \newfontfamily c
ommand.
See the polyglossia package documentation for explanation.
Type H <return> for immediate help.
...
l.3 \selectlanguage *{malayalam}
?
我不确定这是什么意思。多语化似乎存在一些问题。如何解决这个问题?我在 termux 中使用 Texlive 的中等安装
答案1
使用 LuaLaTeX 代替 XeLaTeX。在 LuaLaTeX 中,您的文档就可以正常工作。
如果您由于某种原因必须使用 XeLaTeX,您可以通过将 U+FEFF 的 catcode 设置为忽略(9)来忽略字节顺序标记,从而解决此问题。
还要注意,传递给的字体名称fontspec
不应放在方括号中。这样做只会使速度变慢,并可能导致奇怪的错误。
\documentclass[11pt]{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\catcode"FEFF=9
\setdefaultlanguage{malayalam}
\setmainfont{Rachana-Regular.ttf}
\setlanghyphenmins{malayalam}{3}{4}
\linespread{1.2}
\begin{document}
വിഷയം:
\end{document}