更新

更新

编辑 2 (2017-2-23):更改了标题并添加了此帖子中的示例文件专门适用于 XeLaTeX。

编辑 1 (20-2-2017):应 cfr 的要求,我添加了一个文件。这不是原始文件,而是一个进度文件,可以这么说,它基于 cfr 的示例文件。这个文件适用于 XeLaTeX:

\documentclass[12pt, a4paper, titlepage]{article}

\usepackage[hidelinks]{hyperref}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{verbatim}
\usepackage{afterpage}
\usepackage[top=1.00in, bottom=1.00in, left=1.00in, right=1.00in]{geometry}
\usepackage{setspace}


%% for centering section titles
\usepackage[center]{titlesec}

\usepackage{polyglossia}

\setmainlanguage[variant=british]{english}
\setotherlanguage{hebrew}
\setotherlanguage{greek}
\newfontfamily\hebrewfont{SBL Hebrew}
\newfontfamily\greekfont{SBL Greek}


\title{Title}



%%   BEGIN DOCUMENT
\begin{document}
    \begin{titlepage}
        \maketitle
        \thispagestyle{empty}
    \end{titlepage}
    \pagenumbering{arabic}

\section{First}
\textgreek{αταραξία}. That was in Greek using SBL Greek.

\texthebrew{קֹהֶלֶת}. That was in Hebrew using SBL Hebrew.


\end{document}

旧原始帖子:

在这方面我可能很愚蠢,但是经过长时间的尝试后,我还是无法获得一个以英语为主要语言、偶尔加入希腊语和希伯来语的基本工作文件。

首先,我尝试将希伯来语添加到我现有的 PdfLaTex 文档(接受英语和希腊语)中,但这是一个非常烦人且令人沮丧的过程。然后,由于许多人似乎推荐 XeLaTex 或 LuaLatex,我尝试了这些,但都无济于事(也是一个令人沮丧的过程;事实上,经过这一切之后我还有灵魂吗?技术的意义不就是为用户服务,而不是相反吗?)。

我也遵循了 5.06 版中的说明LaTeX 2ε 的简短介绍。这是第 34 页开始的有关 XeLaTeX 的部分2.5.8 Unicode 选项。好吧,尽管我遵循了它,但它对我没有任何帮助。

那么有人能提供一个基本工作文件对于 PdfLaTeX、XeLaTeX 或 LuaLaTeX(最好是最佳选择),其中英语是主要语言,希腊语和希伯来语是其他语言?

顺便说一下,我已经安装了希伯来语字体SBL 希伯来语。对于英语和希腊语,我只会使用 Computer Modern 或类似的语言。

答案1

像这样吗?

\documentclass{article}
\usepackage{polyglossia}
\setmainfont{Noto Serif}
\setsansfont{Noto Sans}
\setmainlanguage[variant=british]{english}
\setotherlanguage{hebrew}
\setotherlanguage{greek}
\newfontfamily\hebrewfont{Noto Sans Hebrew}[Script=Hebrew]
\newfontfamily\greekfont{Noto Serif}
\begin{document}

This is the main language.

\begin{hebrew}
  עברית
\end{hebrew}

\begin{greek}
  εὐδαιμονία
\end{greek}


\end{document}

使用 XeLaTeX 进行编译。

语言

答案2

更新

babel的 BIDI 支持进展顺利,现在可以相对轻松地实现这一点。babel似乎比 更积极地开发polyglossia,因此这很可能越来越成为一种趋势。 它也适用于xelatexlualatex

\documentclass{article}
\usepackage[nil,bidi=default]{babel}
\babelprovide[import=en-GB,main]{british}
\babelprovide[import=he]{hebrew}
\babelprovide[import=el]{polutonikogreek}
\babelfont[british]{rm}{Latin Modern Roman}
\babelfont[hebrew]{rm}[Contextuals=Alternate]{SBL BibLit}
\babelfont[polutonikogreek]{rm}[Contextuals=Alternate]{SBL BibLit}
\usepackage{parskip}
\pagestyle{empty}
\begin{document}

\textsuperscript{1}In the beginning was the Word, and the Word was with God,
and the Word was God. \textsuperscript{2}He was with God in the beginning.
(John 1:1–2)

\selectlanguage{polutonikogreek}

\textsuperscript{1} Ἐν ἀρχῇ ἦν ὁ λόγος, καὶ ὁ λόγος ἦν πρὸς τὸν θεόν, καὶ θεὸς
ἦν ὁ λόγος. \textsuperscript{2}Οὗτος ἦν ἐν ἀρχῇ πρὸς τὸν θεόν.
\foreignlanguage{british}{(John 1:1–2)}

\selectlanguage{hebrew}

\textsuperscript{1}בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃
\textsuperscript{2}וְהָאָ֗רֶץ הָיְתָ֥ה תֹ֨הוּ֙ וָבֹ֔הוּ וְחֹ֖שֶׁךְ עַל־פְּנֵ֣י תְהֹ֑ום וְר֣וּחַ אֱלֹהִ֔ים מְרַחֶ֖פֶת
עַל־פְּנֵ֥י הַמָּֽיִם׃ \foreignlanguage{british}{(Genesis 1:1–2)}

\selectlanguage{british}

Inline Greek (\foreignlanguage{polutonikogreek}{Ἐν ἀρχῇ ἦν ὁ λόγος} [John 1:1]) and
Hebrew (\foreignlanguage{hebrew}{בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ} [Genesis
1:1]) also
must work.

\end{document}

在此处输入图片描述


原始答案

这是一个稍微扩展的例子,它也适用于lualatex(@cfr 的答案无法编译lualatex——我猜它应该可以,但其中有错误luabidi.sty)。

我还发现在此示例中解决了存在的问题(存在错误\raggedright?)。xelatexbidi.sty

最后,这展示了如何正确使用 SBL BibLit 字体,指定希伯来语所需的脚本和上下文替代。

\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage[variant=british]{english}
\setotherlanguage{hebrew}
\setotherlanguage[variant=ancient]{greek}
\newfontfamily\greekfont{SBL BibLit}%
  [Script=Greek,Contextuals=Alternate,Ligatures=Required]
\newfontfamily\hebrewfont{SBL BibLit}%
  [Script=Hebrew,Contextuals=Alternate,Ligatures=Required,Scale=1.2]
\pagestyle{empty}
\ifluatex
  \let\luatexpardir\pardir % luabidi needs this
  \let\luatextextdir\textdir % luabidi needs this
  % text direction gets stuffed up without these workarounds
  \let\luatextextgreek\textgreek
  \let\luatextextenglish\textenglish
  \AtBeginDocument{%
    \renewcommand{\textgreek}[1]{\bgroup\textdir TLT\luatextextgreek{#1}\egroup}
    \renewcommand{\textenglish}[1]{\bgroup\textdir TLT\luatextextenglish{#1}\egroup}
  }
\fi
% \raggedright stuffs up under xelatex
\let\origraggedright\raggedright
\renewcommand{\raggedright}{%
  \origraggedright
  \ifxetex
    \renewenvironment{hebrew}[1][]{%
      \par
      \raggedleft % add to right align paragraphs
      \begin{otherlanguage}[##1]{hebrew}}%
      {\end{otherlanguage}\par}%
  \fi}
\begin{document}

In the beginning was the Word, and the Word was with God, and the Word was
God. (John 1:1)

\begin{greek}
  Ἐν ἀρχῇ ἦν ὁ λόγος, καὶ ὁ λόγος ἦν πρὸς τὸν θεόν, καὶ θεὸς ἦν ὁ λόγος.
  \textenglish{(John 1:1)}
\end{greek}

\begin{hebrew}
  בְּרֵאשִׁית בָּרָא אֱלֹהִים אֵת הַשָּׁמַיִם וְאֵת הָאָרֶץ. \textenglish{(Genesis 1:1)}
\end{hebrew}

Inline Greek (\textgreek{Ἐν ἀρχῇ}) and Hebrew (\texthebrew{בראשית}) also must
work.

\section*{With \texttt{\textbackslash raggedright}}
\raggedright

In the beginning was the Word, and the Word was with God, and the Word was
God. (John 1:1)

\begin{greek}
  Ἐν ἀρχῇ ἦν ὁ λόγος, καὶ ὁ λόγος ἦν πρὸς τὸν θεόν, καὶ θεὸς ἦν ὁ λόγος.
  \textenglish{(John 1:1)}
\end{greek}

\begin{hebrew}
  בְּרֵאשִׁית בָּרָא אֱלֹהִים אֵת הַשָּׁמַיִם וְאֵת הָאָרֶץ. \textenglish{(Genesis 1:1)}
\end{hebrew}

Inline Greek (\textgreek{Ἐν ἀρχῇ}) and Hebrew (\texthebrew{בראשית}) also must
work.

\end{document}

在此处输入图片描述

相关内容