编写方程式时缺少插入 {。 \bar

编写方程式时缺少插入 {。 \bar

我想写下以下等式:

在此处输入图片描述

为此,我有以下代码片段:

    \begin{equation}
    s_i = \left\{\begin{matrix}
    \bar{1}, & \text{if } x < -\epsilon \\ 
    0, & \text{if } \left | x \right | \leq \epsilon \\ 
    1, & \text{if } x > \epsilon \
    \end{matrix}\right.
    \end{equation}

当我编译时出现以下错误:

Missing { inserted. \bar
Missing } inserted. \bar
Undefined control sequence. \bar{1}, \& \text
Misplaced alignment tab character &. 0, &
Undefined control sequence. 0, & \text
Misplaced alignment tab character &. 1, &
Undefined control sequence. 1, & \text

有人能帮我解决这个问题吗?

答案1

当我完成代码时,没有出现任何错误消息。但是,由于我无法解释的原因,第三行中的“if”与前两个不太一致。使用环境后,这个问题消失了cases,而且环境的代码更简单:

\documentclass[]{article}
\usepackage{mathtools}

\begin{document}

\begin{equation}
s_i = \begin{cases}
\bar{1}, & \text{if } x < -\epsilon \\
0, & \text{if\,} \left | x \right | \leq \epsilon \\
1, & \text{if } x > \epsilon \
\end{cases}
\end{equation}

\end{document} 

在此处输入图片描述

相关内容