如何在使用 \[\] [重复] 时禁用方程式的自动居中

如何在使用 \[\] [重复] 时禁用方程式的自动居中

是的,我试图停止使用 $$ 来表示方程式,但\[自动将方程式放在中心的事实有点烦人,有没有命令可以禁用此功能。

答案1

您可以使用该fleqn选项amsmath

\documentclass{article}
\usepackage[fleqn]{amsmath}
\setlength{\mathindent}{0cm} % This controls the indent

\begin{document}
    \noindent
    Some text before the equation.
    \[
    x = y + z
    \]
    Some text after the equation.
\end{document}

输出:

在此处输入图片描述

答案2

您似乎正在使用如下输入

This is some text before an equation\\
$x+y=y+x$\\
and this text follows

因为无论如何使用$$...$$都会使方程式居中。

这种编写 TypeScript 代码的方式在很多方面都是错误的,即使你使用类似

This is some text before an equation\\[1ex]
$x+y=y+x$\\[1ex]
and this text follows

获取数学显示周围的垂直空间。

绝不用于\\结束普通段落中的行。TeX 不是文字处理器!

如果希望方程式放在左边,则可以使用\[...\]或其他amsmath显示环境,但要避免将显示数学运算与左边距齐平打印。

\documentclass[fleqn]{article}
\usepackage{amsmath}

\begin{document}

\section{Bad display}

The following fact should be known to every mathematician \\[1ex]
$\int_{-\infty}^{\infty} e^{-x^{2}}\,dx=\sqrt{\pi}$\\[1ex]
and was definitely a surprise when it was discovered.

\section{Good display}

The following fact should be known to every mathematician
\[
\int_{-\infty}^{\infty} e^{-x^{2}}\,dx=\sqrt{\pi}
\]
and was definitely a surprise when it was discovered.

\end{document}

在此处输入图片描述

如果你确实希望显示屏与左对齐,

\documentclass[fleqn]{article}
\usepackage{amsmath}

\setlength{\mathindent}{0pt}

\begin{document}

\section{Not so good display}

The following fact should be known to every mathematician
\[
\int_{-\infty}^{\infty} e^{-x^{2}}\,dx=\sqrt{\pi}
\]
and was definitely a surprise when it was discovered.

\end{document}

在此处输入图片描述

为什么不太好?因为通常采用左对齐显示,并在左侧显示方程式数字。请看以下内容。

\documentclass[fleqn,leqno]{article}
\usepackage{amsmath}

\begin{document}

\section{Unnumbered}

The following fact should be known to every mathematician
\[
\int_{-\infty}^{\infty} e^{-x^2}\,dx=\sqrt{\pi}
\]
and was definitely a surprise when it was discovered.

\section{Numbered}

The following fact should be known to every mathematician
\begin{equation}
\int_{-\infty}^{\infty} e^{-x^2}\,dx=\sqrt{\pi}
\end{equation}
and was definitely a surprise when it was discovered.

\end{document}

在此处输入图片描述

如果设置\mathindent为零,则会得到次优输出。

在此处输入图片描述

相关内容