
我需要將數學左對齊。我嘗試[fleqn]
向命令添加選項\documentclass
- 它有效,但現在文檔中的所有方程式都向左對齊,這不是我想要的。
我的 LaTeX 程式碼如下所示
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Classic math which I don't want align to the left
\[
2x + 5
\]
Multiline math which must be left-aligned
\begin{gather*}
x^2 + 3 \\
2x - 5
\end{gather*}
\end{document}
gather*
環境僅用於範例。有沒有更gather*
適合我需求的環境?謝謝
答案1
這是一個相當奇怪的要求,也許最簡單的是如果您使用$$
而不是\[
.$$
是官方不支援的語法,主要問題是它確實支持不是+ 與之合作fleqn
似乎正是您想要的。
請注意,切勿在顯示數學上方留下空行,無論是$$
,\[
或\begin{align}
\documentclass[fleqn]{article}
\usepackage{amsmath}
\begin{document}
Classic math which I don't want align to the left
$$
2x + 5
$$
Multiline math which must be left-aligned
\begin{gather*}
x^2 + 3 \\
2x - 5 \\
\end{gather*}
\end{document}
答案2
gathered
您可以在環境中進行嵌套flalign(*)
:
\documentclass{article}
\usepackage{mathtools}
\usepackage[showframe]{geometry}
\begin{document}
Classic math which I don't want align to the left
\begin{equation}
\begin{gathered}
x^2 + 3 \\
2x - 5 = z
\end{gathered}
\end{equation}
Multiline math which must be left-aligned
\begin{flalign}
\hskip\parindent & \begin{gathered}
x^2 + 3 \\
2x - 5 = z
\end{gathered} &
\end{flalign}
\end{document}