定義中的“Where”符號

定義中的“Where”符號

我需要定義一個相當複雜的操作。因此我想使用經典的“where”定義風格,即

Foo = Bar(x,y) 
WHERE
x = Baz
y = Fob

到目前為止我在乳膠方面的嘗試是:

\begin{align*}
\text{Foo} = \text{Bar}(x,y) && \mathbf{where} \\
x = \text{Baz}
\end{align*}

不過,我對結果並不是很滿意:

  • where 關鍵字在佈局中並沒有真正脫穎而出
  • 輔助定義與主定義處於同一級別

因此,與其擺弄它,是否有某種(半)規範的方法來佈局此類定義?

答案1

我猜你正在使用\text巨集以羅馬字體排版,但這是不好的做法,因為語意上不正確:\text巨集應該保留用於在顯示數學環境中排版短語,例如“where”、“for all”、“subject to”等(例如equationalign等)不是用於變數或函數名稱。您應該\mathrm在此處使用巨集。

這是我如何寫你的方程式:

在此輸入影像描述

\documentclass{article}

\usepackage{amsmath}

\newcommand\Foo{\mathrm{Foo}}
\newcommand\Barfun{\mathrm{Bar}}
\newcommand\Baz{\mathrm{Baz}}
\newcommand\Fob{\mathrm{Fob}}

\begin{document}
%
\begin{align*}
  \Foo &= \Barfun(x,y) \\
  \intertext{where}    
  x    &= \Baz         \\
  y    &= \Fob
\end{align*}
%
\end{document}

答案2

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align*}
  f &= f(x,y)\\
  \makebox[0.6em][l]{where} & \\
  x &= g(z)\\
  y &= h(z,x)
\end{align*}

\end{document}

在此輸入影像描述

答案3

使用另一種對齊方式和較小的垂直間距:

\documentclass{article}

\usepackage{mathtools}
\DeclareMathOperator{\Barr}{Bar}

\begin{document}
\begin{align*}
  &  Foo   = \Barr(x,y)\\
  \shortintertext{where}
  \begin{cases}
    {} \\ {}
  \end{cases}
  \hspace{-1.1em}
  &
  \begin{array}{@{}l}
    x= Baz\\[6pt]
    y= Fob
  \end{array}
\end{align*}
\end{document} 

在此輸入影像描述

答案4

另外一個選擇。

如果函數名有多個字母,通常是直排的。如果您只使用它一次或兩次,則可以使用\operatorname{Foo},但如果您使用它多次,可能值得為它們定義一個新命令:

\documentclass{scrartcl}

\usepackage{mathtools}
\DeclareMathOperator\Fo{Foo}
\DeclareMathOperator\Ba{Bar}
\DeclareMathOperator\Bz{Baz}
\DeclareMathOperator\Fb{Fob}

\begin{document}

\begin{align*}
  \Fo &= \Ba(x,y) \\ \intertext{where}
  x &= \Bz \\
  y &= \Fb
\end{align*}

\end{document}

經過一番討論後,結果顯示\operatorname{A}+\operatorname{B}\mathrm{A}+\mathrm{B}給出了不同的結果(我不知道)。所以,我的回答不一定是正確的(可能不是)。

我把它留在這裡以防他們實際上是操作員。

相關內容