如何在 Markdown 方程式中编写案例

How to write cases in Markdown equations

如何在 markdown 中写这样的东西?

以下是我不知道该怎么做的具体事情:

如果我知道正确的语法,我会这样做:

$$
CE(p, y) = \curlytwo{-\log(p) \tab \text{if }y=1}{-\log(1-p) \tab \text{otherwise.}}
$$

我发明了 \curlytwo\tab

您可以使用 cases 环境编写案例 supported in MathJax:

$$
\mathrm{CE}(p, y) = \begin{cases}
    -\log(p) & \text{if } y = 1 \ % & is your "\tab"-like command (it's a tab alignment character)
    -\log(1-p) & \text{otherwise.}
\end{cases}
$$
\begin{equation}
(p, y) = 
\begin{cases}
    -\log(p) & \text{if }~~ y = 1 \
    -\log(1-p) & \text{otherwise.}
\end{cases}
\end{equation}

here学习并使用数组

$$
CE(p,y)=\left\{
\begin{array}{ll}
-\log(p) &\text{if }y=1 \ 
-\log(1-p) &\text{otherwise}.
\end{array} 
\right.
$$