如何左對齊方程

如何左對齊方程

我在我的文檔中使用下面的等式。預設情況下,它在中心對齊。我想將方程式左對齊——僅此方程,而不是文檔中的所有方程。誰能告訴我如何做到這一點?

\begin{equation}
d_j =
  \begin{cases}
    newval_i,  & \quad i = j\\
    randval_k, & \quad k = j\\
    bestval_j, & \quad \text{otherwise}
  \end{cases}
\end{equation}

答案1

您可以將方程式嵌套在fleqn環境中(來自nccmath)。此環境接受一個可選參數,表示與左邊距的距離(0 pt預設):

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}
\usepackage{mathtools, nccmath}

\begin{document}

\begin{equation}
d_j =
  \begin{cases}
    \text{newval}_i, & \quad i = j\\
    \text{randval}_k, & \quad k = j\\
    \text{bestval}_j, & \quad \text{otherwise}
  \end{cases}
\end{equation}

\begin{fleqn}
\noindent\texttt{With fleqn: }
\begin{equation}
d_j =
  \begin{cases}
    \text{newval}_i, & \quad i = j\\
    \text{randval}_k, & \quad k = j\\
    \text{bestval}_j, & \quad \text{otherwise}
  \end{cases}
\end{equation}
\end{fleqn}

\begin{fleqn}[3em]
\noindent\texttt{With fleqn and optional argument [3em]: }
\begin{equation}
d_j =
  \begin{cases}
    \text{newval}_i, & \quad i = j\\
    \text{randval}_k, & \quad k = j\\
    \text{bestval}_j, & \quad \text{otherwise}
  \end{cases}
\end{equation}
\end{fleqn}

    \end{document} 

在此輸入影像描述

相關內容