方程式的定位(开始方程式命令)

方程式的定位(开始方程式命令)

这是我上一个问题的后续, 方程式的定位。我设法将方程式对齐到左侧,但在我的乳胶文档中,我还一直在使用:

\begin{equation}
X^2 := x^2 - 123. \nonumber
\end{equation}

我还有很多其他方程式需要居中。例如,对于我的所有方程式,我都将其环绕:

\begin{equation}
\end{equation}

我该如何将其居中?谢谢,我的代码如下。

在此处输入图片描述

\documentclass[11pt,a4paper]{report}
\usepackage[fleqn]{amsmath}
\setlength{\mathindent}{0pt}
\usepackage{amsfonts,amssymb,amsthm,epsfig,epstopdf,titling,url,array}

\theoremstyle{plain}
\newtheorem{thm}{Theorem}[chapter] % reset theorem numbering for each chapter
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
\newtheorem*{cor}{Corollary}

\theoremstyle{definition}
\newtheorem{defn}[thm]{Definition} % definition numbers are dependent on theorem numbers
\newtheorem{exmp}[thm]{Example} % same for example numbers
\newtheorem{conj}[thm]{Conjecture}

\theoremstyle{remark}
\newtheorem*{rem}{Remark}
\newtheorem*{note}{Note}


\title{My Thesis Title}
\author{My Name}
\date{\today}
\renewcommand\labelenumi{(\theenumi)}
\renewcommand\theenumi{\roman{enumi}}
\setlength{\parindent}{1em}

\begin{document}

\chapter{Addition}

\begin{exmp} 
Here is an example.
\begin{align} \nonumber
(a+b)^3 &= (a+b)^2(a+b)\\ \nonumber
&=(a^2+2ab+b^2)(a+b)\\ \nonumber
&=(a^3+2a^2b+ab^2) + (a^2b+2ab^2+b^3)\\ \nonumber
&=a^3+3a^2b+3ab^2+b^3 \nonumber
\end{align}
\end{exmp}

\begin{exmp}
A simple equation:
\begin{equation}
X^2 := x^2 - 123. \nonumber
\end{equation}
\end{exmp}
\end{document}

答案1

更通用的解决方案是加载nccmath包并将您想要在环境中左对齐的每个方程包装起来fleqn

\documentclass{article}
\usepackage{nccmath}
\begin{document}
\begin{fleqn}
    \begin{align*}
    a&=b\\
    &=c
    \end{align*}
\end{fleqn}
Which implies
    \begin{equation}
    a=c
    \end{equation}
But
\begin{fleqn}
    \[ 0\ne 5 \]
And
    \[ 2\ne 3 \]
\end{fleqn}
\end{document}

如果nccmath出现问题,您也可以fleqn这样定义:

\makeatletter
\newenvironment*{fleqn}{
    \@fleqntrue
    \setlength\@mathmargin{0pt}%
    \ignorespaces
}{%
    \ignorespacesafterend
}
\makeatother

答案2

不要使用[fleqn]全局选项,而要保留默认的居中行为,但在需要左对齐时使用flalign而不是环境。align

相关内容