多语种环境下的希伯来语和英语

多语种环境下的希伯来语和英语

我正在尝试为物理课程编写一份备忘单,因此文档将使用 分为 3 列左右multicol。我已经设法完成了希伯来语和多列的配置(使用我找到的模板)。
尽管我努力自己解决这些问题,但仍然存在一些问题:

  1. 在我当前的配置中,英文单词是反转的。例如,当我在源代码中写入时,English words reversed它在输出/PDF 中显示为reversed words English
  2. 无法使用某些字体,例如Nachlieli CLM(我一直在 LibreOffice 中使用它)。

tex 代码是(为简洁起见省略了一些代码。您还可以看到我为解决问题所做的一些尝试 - 但无济于事...):

\documentclass[10pt]{article}

\usepackage{multicol}
\usepackage{calc}
\usepackage{ifthen}
\usepackage{geometry}
\usepackage{hyperref}

%%\usepackage[utf8]{inputenc}
\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setmainlanguage{hebrew}

%\setmainfont{Arial}
%\newfontfamily{\hebrewfont}{Arial}
\setmainfont{DejaVu Sans}
\newfontfamily{\hebrewfont}{DejaVu Sans}
%\setmainfont{Nachlieli CLM}
%\newfontfamily{\hebrewfont}{Nachlieli CLM}


%%% The next block of code is a COMMENT
\iffalse
    \usepackage{polyglossia}

    \setdefaultlanguage{hebrew}
    \setmainlanguage{english}
    %\setotherlanguage{hebrew}

    \usepackage{fontspec}
    \setmainfont{DejaVu Sans}
\fi

% This sets page margins to .5 inch if using letter paper, and to 1cm
% if using A4 paper. (This probably isn't strictly necessary.)
% If using another size paper, use default 1cm margins.
\ifthenelse{\lengthtest { \paperwidth = 11in}}
    { \geometry{top=.5in,left=.5in,right=.5in,bottom=.5in} }
    {\ifthenelse{ \lengthtest{ \paperwidth = 297mm}}
        {\geometry{top=0.4cm,left=0.4cm,right=0.4cm,bottom=0.4cm} }
        {\geometry{top=0.4cm,left=0.4cm,right=0.4cm,bottom=0.4cm} }
    }

% Turn off header and footer
\pagestyle{empty}

% Redefine section commands to use less space
\makeatletter
\renewcommand{\section}{\@startsection{section}{1}{0mm}%
                                {-1ex plus -.5ex minus -.2ex}%
                                {0.5ex plus .2ex}%x
                                {\normalfont\large\bfseries}}
\renewcommand{\subsection}{\@startsection{subsection}{2}{0mm}%
                                {-1explus -.5ex minus -.2ex}%
                                {0.5ex plus .2ex}%
                                {\normalfont\normalsize\bfseries}}
\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{0mm}%
                                {-1ex plus -.5ex minus -.2ex}%
                                {1ex plus .2ex}%
                                {\normalfont\small\bfseries}}
\makeatother

% Don't print section numbers
\setcounter{secnumdepth}{0}

\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt plus 0.5ex}

% -----------------------------------------------------------------------

\begin{document}

%\raggedright
\title{שלום עולם}
\author{Dor}
%\maketitle

%\raggedright
\footnotesize
\begin{multicols}{3}

% multicol parameters
% These lengths are set only within the two main columns
%\setlength{\columnseprule}{0.25pt}
\setlength{\premulticols}{1pt}
\setlength{\postmulticols}{1pt}
\setlength{\multicolsep}{1pt}
\setlength{\columnsep}{2pt}

\begin{center}
     \Large{\textbf{שלום עולם}} \\
\end{center}

\section{English words reversed}
כוח לורנץ  
$ \int_0^\infty x d x $
העיר מקודשת ליהדות, לנצרות ולאסלאם, והיוותה מרכז חיי העם היהודי בימי
קדם ומושא געגועיו בזמן שהייתו בגלות. משום מרכזיותה בעולמם של המאמינים,
הייתה העיר מוקד למלחמות וסכסוכים הנמשכים עד עצם היום הזה. מאז סוף המאה
ה-19 התפתחו סביב העיר העתיקה שכונות העיר החדשה, המהוות כיום את רובה
המוחלט של העיר. במרכזה של ירושלים השלמה עומד הר הבית, שמפריד בין מערב
ירושלים למזרח ירושלים.

בשנת 1981 הוכרזה העיר העתיקה של ירושלים כאתר מורשת עולמית על ידי ארגון
אונסק"ו של האומות המאוחדות, והיא נמצאת ברשימת האתרים בסיכון.


\end{multicols}
\end{document}

执行xelatex产生以下输出/PDF:

在此处输入图片描述

我尝试了很多在网上看到的建议,但都没有用。我也试过用 Lyx,但它也有自己的问题。

对我来说,“理想”的文件是这样的:

  1. 允许使用 UTF8 编码编写文档。
  2. 通过所编写的语言识别方向(RTL/LTR)——这正是 LibreOffice 和每个常规程序所发生的情况。
  3. 允许使用系统中已安装的字体。

答案1

要修复问题 1,请删除以下内容:

\setdefaultlanguage{hebrew}
\setmainlanguage{hebrew}

%\setmainfont{Arial}
%\newfontfamily{\hebrewfont}{Arial}
\setmainfont{DejaVu Sans}
\newfontfamily{\hebrewfont}{DejaVu Sans}
%\setmainfont{Nachlieli CLM}
%\newfontfamily{\hebrewfont}{Nachlieli CLM}


%%% The next block of code is a COMMENT
\iffalse
    \usepackage{polyglossia}

    \setdefaultlanguage{hebrew}
    \setmainlanguage{english}
    %\setotherlanguage{hebrew}

    \usepackage{fontspec}
    \setmainfont{DejaVu Sans}
\fi

并将其替换为:

\usepackage{polyglossia}
    \setdefaultlanguage{hebrew}
    \setotherlanguage{english}
    \newfontfamily\hebrewfont[Script=Hebrew]{DejaVu Sans}
    \newfontfamily\englishfont[Ligatures=NoCommon]{Linux Libertine O}

然后写成\section{\textenglish{English words reversed}}而不是\section{English words reversed}。现在的英语是 LTR。

至于问题 2,您的系统可能没有这些字体,而这正是您所XeLaTeX需要的。下载它们并将它们放在您的字体文件夹中。

答案2

AML 已经为双向问题提供了很好的答案。使用\textenglish{hello}\texthebrew{שלום}表示短语,\begin{english}\begin{hebrew}表示段落的部分或更长的部分。这些对于您的主要语言来说是可选的,但可以更轻松地将其复制并粘贴到使用其他主要语言的文档中。

对于字体,请确保您已经安装了culmus使用包管理器安装了包,或者从 SourceForge 下载文件。(作为 Linux 的普通用户,您可能希望将文件复制.otf~/.fonts/仅供自己安装字体。在其他操作系统上,双击文件.otf以启动预览和安装程序。)您可能需要使用名称Nachlieli CLM LightNachlieliCLM-Light.otf。以下方法可能适合您:

\newfontfamily\hebrewfont{NachlieliCLM-Light.otf}[
  BoldFont = NachlieliCLM-Bold.otf,
  ItalicFont = NachlieliCLM-LightOblique.otf,
  BoldItalicFont = NachlieliCLM-BoldOblique.otf,
  Script = Hebrew,
  Scale = MatchUppercase
]

您可能还想polyglossia使用\setmainlanguage\setotherlanguage而不是来配置\setdefaultlanguage

如果您确定字体已安装,并且您使用的是 Linux,请尝试find /usr -iname "Nachlieli*.otf" -print查找字体文件。如果某个目录当前不在您的字体路径中,但您想让所有应用程序都可以使用那里的字体,您可以在 下放置指向它的符号链接/usr/local/share/fonts

相关内容