![最适合使用印地语/梵语的套餐?](https://linux22.com/image/414214/%E6%9C%80%E9%80%82%E5%90%88%E4%BD%BF%E7%94%A8%E5%8D%B0%E5%9C%B0%E8%AF%AD%2F%E6%A2%B5%E8%AF%AD%E7%9A%84%E5%A5%97%E9%A4%90%EF%BC%9F.png)
我正在使用 Overleaf 来编写文档,因为我想使用一些古梵语的引文并为页面提供印地语编号。
因此有任何适合做这样的事情的包。
答案1
不幸的是,我不会说印地语,无法告诉你什么是最好的,或者大多数印度作家使用什么。
我通常建议使用 xelatex 而不是 pdftex 进行编译。由于您使用的是 Overleaf,因此您可以从项目菜单中更改 TeX 引擎。(lualatex 的最新版本增加了对南亚文字的支持,但 Overleaf 尚未升级。)然后您可以加载babel
,正常输入梵文,并以 UTF-8 保存。
babel 包使用\localenumeral
和\localecounter
命令在其他脚本中显示数字。 它支持alphabetic
印地语的编号。您也许还可以更改 的含义\pagenumbering{alph}
。
如果您真的被迫使用 pdftex,并且想要包含一段很长的梵语引文,那么一种解决方法是将该引文standalone
在 xetex 中编译为 PDF,并将其包含在使用 pdftex 编译的文档中,就像它是一个图一样。印地语页码会更复杂。
devanagari
否则,您可能会用到较旧的软件包。
有一种比我最初使用的方法更简单的方法,即使用语言选项来更改数字计数器maparabic
的行为,并使用包选项使章节编号和目录使用当前语言的数字。还可以覆盖印地语的计数器。arabic
layout=sectioning
alph
\tracinglostchars=2 % Show a warning for missing characters
\documentclass{book}
\usepackage[paperwidth=12cm]{geometry} % Solely to crop a MWE on TeX.SX
\usepackage[bidi=default,layout=sectioning]{babel}
\usepackage{fontspec}
\usepackage{microtype}
\babelprovide[import,main,maparabic]{hindi}
\babelprovide[import]{sanskrit-devanagari}
\babelprovide[import]{english}
\babelfont{rm}{Noto Serif}
\babelfont{sf}{Noto Sans}
\babelfont[hindi]{rm}
[Language=Default]{Noto Serif Devanagari}
\babelfont[hindi]{sf}
[Language=Default]{Noto Sans Devanagari}
\babelfont[sanskrit-devanagari]{rm}
{Noto Serif Devanagari}
\babelfont[sanskrit-devanagari]{sf}
[Language=Default]{Noto Sans Devanagari}
\newcommand\texthindi[1]{\foreignlanguage{hindi}{#1}}
\newenvironment{hindi}%
{\begin{otherlanguage}{hindi}}%
{\end{otherlanguage}}
\newcommand\textsanskrit[1]{\foreignlanguage{sanskrit-devanagari}{#1}}
\newenvironment{sanskrit}%
{\begin{otherlanguage}{sanskrit-devanagari}}%
{\end{otherlanguage}}
\newcommand\textenglish[1]{\foreignlanguage{english}{#1}}
\newenvironment{english}%
{\begin{otherlanguage}{english}}%
{\end{otherlanguage}}
\begin{document}
\selectlanguage{english}
Text in English and \texthindi{हिन्दी}. Unless I’ve fallen for a very elaborate
practical joke, this should be an excerpt from the UN Declaration of Human
Rights:
\begin{sanskrit}
सर्वे मानवाः स्वतन्त्राः समुत्पन्नाः वर्तन्ते अपि च, गौरवदृशा अधिकारदृशा च समानाः एव वर्तन्ते। एते सर्वे चेतना-तर्क-शक्तिभ्यां सुसम्पन्नाः सन्ति। अपि च, सर्वेऽपि बन्धुत्व-भावनया परस्परं व्यवहरन्तु।
\end{sanskrit}
\end{document}
原文答案
这是一个在 xelatex 中编译的简单模板。如有错误,敬请谅解:
\tracinglostchars=2 % Show a warning for missing characters
\documentclass{book}
\usepackage[paperwidth=12cm]{geometry} % Solely to crop a MWE on TeX.SX
\usepackage[english, bidi=default]{babel}
\usepackage{fontspec}
\usepackage{microtype}
\usepackage{fancyhdr}
\babelprovide[import]{hindi}
\babelprovide[import]{sanskrit-devanagari}
\babelfont{rm}{Noto Serif}
\babelfont{sf}{Noto Sans}
\babelfont[hindi]{rm}
[Language=Default]{Noto Serif Devanagari}
\babelfont[hindi]{sf}
[Language=Default]{Noto Sans Devanagari}
\babelfont[sanskrit-devanagari]{rm}
{Noto Serif Devanagari}
\babelfont[sanskrit-devanagari]{sf}
[Language=Default]{Noto Sans Devanagari}
\newcommand\texthindi[1]{\foreignlanguage{hindi}{#1}}
\newenvironment{hindi}%
{\begin{otherlanguage}{hindi}}%
{\end{otherlanguage}}
\newcommand\textsanskrit[1]{\foreignlanguage{sanskrit-devanagari}{#1}}
\newenvironment{sanskrit}%
{\begin{otherlanguage}{sanskrit-devanagari}}%
{\end{otherlanguage}}
\pagestyle{fancy}
\fancyhead[LE,RO]{\texthindi{\hindicounter{page}}}
\fancyfoot{}
\begin{document}
Text in English and \texthindi{हिन्दी}. Unless I’ve fallen for a very elaborate
practical joke, this should be an excerpt from the UN Declaration of Human
Rights:
\begin{sanskrit}
सर्वे मानवाः स्वतन्त्राः समुत्पन्नाः वर्तन्ते अपि च, गौरवदृशा अधिकारदृशा च समानाः एव वर्तन्ते। एते सर्वे चेतना-तर्क-शक्तिभ्यां सुसम्पन्नाः सन्ति। अपि च, सर्वेऽपि बन्धुत्व-भावनया परस्परं व्यवहरन्तु।
\end{sanskrit}
\end{document}