前のセクションが他の言語で終了し、セクションのタイトルが他の言語で始まる場合、メイン言語が正しく再選択されません。

前のセクションが他の言語で終了し、セクションのタイトルが他の言語で始まる場合、メイン言語が正しく再選択されません。

ヘブライ語と英語の 2 つの言語を含む文書で XeLaTeX に問題が発生しています。ヘブライ語には別のフォントを使用しています (ここでは DejaVu Sans ですが、どのフォントでもかまいません)。

問題は、(1) セクションがヘブライ語のテキストで終了し、(2) 次のセクションのタイトルがヘブライ語のテキストで始まる場合、ドキュメントの残りの部分と目次がヘブライ語に使用されるフォントで表示されることです。何らかの理由で、システムはメインのフォントに戻りません (以下の例を参照)。

この問題は2台のマシンのうち1台でのみ発生します。問題のあるマシンは、TeX Live 2022がインストールされたDebian Bookwormを実行しています。ここ.xelatex --versionは次のようになります:

XeTeX 3.141592653-2.6-0.999994 (TeX Live 2022)
kpathsea version 6.3.4
Copyright 2022 SIL International, Jonathan Kew and Khaled Hosny.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the XeTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the XeTeX source.
Primary author of XeTeX: Jonathan Kew.
Compiled with ICU version 70.1; using 70.1
Compiled with zlib version 1.2.11; using 1.2.11
Compiled with FreeType2 version 2.11.1; using 2.11.1
Compiled with Graphite2 version 1.3.14; using 1.3.14
Compiled with HarfBuzz version 3.4.0; using 3.4.0
Compiled with libpng version 1.6.37; using 1.6.37
Compiled with pplib version v2.05 less toxic i hope
Compiled with fontconfig version 2.13.0; using 2.14.1

私の他のマシンでは問題はありません。このマシンは、同じソースからインストールされた TeX Live 2022 を搭載した Debian Bullseye を実行しています。唯一の違いは次のとおりxelatex --versionです。

Compiled with fontconfig version 2.13.0; using 2.13.1

したがって、問題のあるシステムでは新しい fontconfig を使用します (新しいシステムで古いバージョンを使用して問題が解決するかどうかをテストする方法がわかりません)。すべてのパッケージ (とaptの両方tlmgr) は両方のシステムで最新です。

この問題を解決するにはどうすればいいと思いますか?

\documentclass{article}

\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{hebrew}
\newfontfamily\hebrewfont{DejaVu Sans}
\newcommand{\heb}[1]{\bgroup\normalfont\hebrewfont\RL{#1}\egroup}

\begin{document}

\tableofcontents

\section{First section}
\begin{hebrew}
    This section ends with Hebrew text.
\end{hebrew}
\section{\heb{אב} Section title starts with Hebrew}

\end{document}

ここに画像の説明を入力してください

ここでは、「text. Hebrew with ends section This」と「אב」を除くすべてが、DejaVu Sans ではなくデフォルトのフォントになっている必要があります。

答え1

としてウルリケ・フィッシャーの提案、使用

\newcommand{\heb}[1]{\bgroup\selectlanguage{hebrew}\RL{#1}\egroup}

問題を修正します。

ここに画像の説明を入力してください

関連情報