無法使用 \left。 ... \右|在自訂環境中

無法使用 \left。 ... \右|在自訂環境中

我正在用方程式編寫希伯來語(RTL)文檔,並使用 xelatex 對其進行編譯。方程式數字是錯誤的,我發現\LTR在方程式之前放置標籤可以解決這個問題。我已經創建了一個環境,​​但有些地方不對勁。例如,當我嘗試編譯它時:

\documentclass[11pt]{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{xltxtra} 
\usepackage{bidi} 
\setmainfont{Arial} 
\tolerance=1000
\providecommand{\alert}[1]{\textbf{#1}}
\newenvironment{ltreq}[1]{
  \LTR
  \begin{equation}
    {1}}
  {\end{equation}
  \RTL}

\begin{document}
\RTL

\begin{ltreq}
\left . \frac{\partial f}{\partial y} \eta \right |_{x_1}^{x_2} -\int_{x_1}^{x_2} \frac{\partial f}{\partial y'} \eta dx
\end{ltreq}
\RTL

\end{document}

我收到此錯誤:

l.22 ...frac{\partial f}{\partial y} \eta \right |
                                                  _{x_1}^{x_2} -\int_{x_1}^{...

我想我的做法太天真了。我怎樣才能實現這個目標?

答案1

您指定ltreq環境有一個參數,因此它吞沒了\left等式開頭的 。如果[1]從定義中刪除它,它會起作用:

\documentclass[11pt]{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{xltxtra} 
\usepackage{bidi} 
\setmainfont{Arial} 
\tolerance=1000
\providecommand{\alert}[1]{\textbf{#1}}
\newenvironment{ltreq}{
  \LTR
  \begin{equation}}
  {\end{equation}
  \RTL}

\begin{document}
\RTL

\begin{ltreq}
\left . \frac{\partial f}{\partial y} \eta \right |_{x_1}^{x_2} -\int_{x_1}^{x_2} \frac{\partial f}{\partial y'} \eta dx
\end{ltreq}
\RTL

\end{document}

相關內容