我想创作一本帮助亚洲人学习英语的书。要求是 - 这本书应该包含两种不同语言的文本,例如印地语和英语。
我试过这个多语言示例来自这里
\documentclass{article}
%Always start xelatex files with these in preamble. This helps in defining the script and fonts
\usepackage{fontspec}
%Set the main languge next as main font.
\setmainfont[Script=Devanagari]{Lohit Hindi}
%Set rest of the languages l;ike this. Experiment a bit. script=punjabi did not work. Replaced with gurmukhi and it works.
%English does not need any script specifiction! Just define the font.
\newfontfamily{\eng}{Arial}
\begin{document}
%No need to define script as this is the manin font set. Like defalut.
नमो नारायणाय! \\
{\eng namo bhagavate naraayanaaya}\\
%the next line does not begin liekt he ones above. so it defaults to mainfont which is devanagari.
शुभम।
\end{document}
我使用了以下命令
$ xelatex multilang.tex
但我收到了错误 -
This is XeTeX, Version 3.1415926-2.4-0.9998 (TeX Live 2012/Debian)
restricted \write18 enabled.
entering extended mode
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, et
hiopic, farsi, arabic, pinyin, croatian, bulgarian, ukrainian, russian, slovak,
czech, danish, dutch, usenglishmax, ukenglish, finnish, french, basque, ngerma
n, german, swissgerman, ngerman-x-2012-05-30, german-x-2012-05-30, monogreek, g
reek, ibycus, ancientgreek, hungarian, bengali, tamil, hindi, telugu, gujarati,
sanskrit, malayalam, kannada, assamese, marathi, oriya, panjabi, italian, lati
n, latvian, lithuanian, mongolian, mongolianlmc, nynorsk, bokmal, indonesian, e
speranto, coptic, welsh, irish, interlingua, serbian, serbianc, slovenian, friu
lan, romansh, estonian, romanian, armenian, uppersorbian, turkish, afrikaans, i
celandic, kurmanji, polish, portuguese, galician, catalan, spanish, swedish, th
ai, loaded.
更多输出然后出现此错误 -
(/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.cfg)))kpathsea: Invalid fontname `Lohit Hindi/ICU', contains ' '
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "Lohit Hindi" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................
l.5 \setmainfont[Script=Devanagari]{Lohit Hindi}
问题是 -
- 这里具体是什么问题?看起来好像缺少“Lohit Hindi”字体,但我很困惑
- 如何在 LaTex(或 XeTex)中安装字体或如何使 Linux 上安装的字体可供 XeTex 使用?
答案1
如果这是您希望在 LaTeX / XeTeX 输出中看到的内容……
那么您可能只需要更改字体的名称,该名称在您获得的示例中可能已经过时了。
我修改了您的示例如下(删除了注释):
\documentclass{article}
\usepackage{fontspec}
\setmainfont[Script=Devanagari]{Lohit-Devanagari} % Hindi -> Devanagari
\newfontfamily{\eng}{Arial}
\begin{document}
नमो नारायणाय! \\
{\eng namo bhagavate naraayanaaya}\\
शुभम।
\end{document}
如果你的系统缺少 Lohit 字体,你可能会找到你的运气这里适用于 Fedora 和 Debian,但也可以更粗略地从 git、svn 和类似系统(请参阅那里的说明)。
在 RHEL6 衍生系统 (Scientific Linux) 上为我工作。祝你好运!