eso-picとbidiの組み合わせ

eso-picとbidiの組み合わせ

私は、各ページの左上隅を基準にしてコンテンツを配置するパッケージを使用するドキュメントクラスを作成しましたeso-pic。このドキュメントクラスを、(部分的に)ヘブライ語のドキュメントで使用しました。ヘブライ語では、polyglossia。このドキュメントクラスを、(部分的に)ヘブライ語のドキュメントで使用しました。ヘブライ語では、パッケージをこの郵便受けXeLaTeX と一緒に使用します。ページ レイアウトを右から左に切り替えるためにpolyglossia使用します。bidi

左上隅の配置を除いてすべて正常に動作しています。次の例は私の問題を示しています。

\documentclass{article}

% set font for hebrew
\usepackage{fontspec}
\setmainfont{DejaVuSans.ttf}

% if polyglossia is commented
\providecommand{\setLTR}{}
\providecommand{\setRTL}{}

% write "test" a few times
\newcounter{loopcounter}
\newcommand{\writetest}{
    \loop
    \ifnum\value{loopcounter}<36
        Test\theloopcounter 
        \stepcounter{loopcounter}
    \repeat
}

% add the test in the top left corner
\usepackage{calc}
\usepackage{picture}
\usepackage{eso-pic}
\AddToShipoutPictureFG{
    \AtPageUpperLeft{%
        % see the bottom of the question for the \put()
        \put(0,0){
            \raisebox{-\height-3pt}{
                % needed to do left to right align and for breaking
                \parbox{\paperwidth}{
                    \setLTR
                    \writetest
                }
            }
        }
    }
}

\usepackage{polyglossia} % <- If those packages are commented the placing
\setmainlanguage{hebrew} % <- of the top left content is correct.

\begin{document}
    תוכן
\end{document}

与えられた例をコンパイルすると、次の図の下部に示す結果が得られます。ただし、左上隅に配置されたコンテンツは左上隅にありません。

2 番目上の画像はまったく同じ例ですが、\usepackage{polyglossia}と が\setmainlanguage{hebrew}コメント化されています。そのため、bidiパッケージは読み込まれません。コーナーのテキストは正しいです。ただし、ヘブライ語のテキストは (当然ですが) 右から左ではありません。

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

提供されたコードを見るとわかるように、私はすでに\put()(パッケージと一緒にpicture) を使用してオフセットを修正しようとしました。しかし、それが何であるかがわかりません。 のようなもののはずです-\textwidth-\marginright。しかし、そうではありません。

はドキュメントクラス内にあることに注意してください\AddToShipoutPictureFG。コンテンツと同じファイルではありません。さまざまなファイルでドキュメントクラスを使用したいので、寸法は変わります。ページ寸法に対するオフセットを知る必要があります。絶対値としてではありません。 を使用してもput(-11.872cm, 0)問題は解決しません。

左上隅にコンテンツを配置しpolyglossiaながら使用するにはどうすればよいですか?eso-pic

答え1

background期待していたものではないかもしれませんが、パッケージとを使用して簡単に実装できるソリューションを次に示しますtikz

\documentclass[letterpaper]{article}

% set font for hebrew
\usepackage{fontspec}
\setmainfont{DejaVuSans.ttf}

% write "test" a few times
\newcounter{loopcounter}
\newcommand{\writetest}{
    \loop
    \ifnum\value{loopcounter}<36
        Test\theloopcounter 
        \stepcounter{loopcounter}
    \repeat
}

% add the test in the top left corner
\usepackage[all]{background}
\backgroundsetup{%
  placement = top,
  color = black,
  opacity=1,
  scale = 1,
  vshift=-6pt,
  contents = {%
    \tikz \node [text width=\paperwidth-12pt, align=justify] {\writetest};
  },
}

\usepackage{polyglossia}
\setmainlanguage{hebrew}

\begin{document}
    תוכן
\end{document}

出力

関連情報