There are switches for amsmath
options leqno
and reqno
.
Then, how to define switches for turning on and off the option fleqn
after amsmath
is loaded?
I looked into the source of amsmath.sty
and define the switches as
\makeatletter
\newcommand*{\fleqnon}{\setboolean{@fleqn}{true}}
\newcommand*{\fleqnoff}{\setboolean{@fleqn}{false}}
\makeatother
These two switches work only when amsmath
is loaded with the option fleqn
.
MWE:
\documentclass[b6paper]{scrartcl}
%\usepackage[fleqn]{amsmath} % works with the option `fleqn`
\usepackage{amsmath} % fails without the option `fleqn`
\usepackage{ifthen}
\makeatletter
% https://tex.stackexchange.com/a/212099
\newcommand*{\leqnomode}{\tagsleft@true\let\veqno=\@@leqno}
\newcommand*{\reqnomode}{\tagsleft@false\let\veqno=\@@eqno}
% based on my guess on `amsmath.sty`
\newcommand*{\fleqnon}{\setboolean{@fleqn}{true}}
\newcommand*{\fleqnoff}{\setboolean{@fleqn}{false}}
\makeatother
\begin{document}
\fleqnon
\begin{align}
f(x) &= ax^2 + bx + c \\
g(x) &= dx^2 + ex + f
\end{align}
\fleqnoff
\begin{align}
f(x) &= ax^2 + bx + c \\
g(x) &= dx^2 + ex + f \tag{e}
\end{align}
\fleqnon
\leqnomode
\begin{align}
f(x) &= ax^2 + bx + c \\
g(x) &= dx^2 + ex + f \tag{a}
\end{align}
\fleqnoff
\begin{align}
f(x) &= ax^2 + bx + c \\
g(x) &= dx^2 + ex + f
\end{align}
\begin{equation}
a^2+b^2=c^2.
\end{equation}
\reqnomode
\begin{equation}
-\Delta\phi=4\pi k\rho.\tag{2}
\end{equation}
\end{document}
amsmath
with thefleqn
option, given that it works?leqno
andreqno
, so it may be helpful to have one forfleqn
.leqno
either. I think the answer that you link to is misleading, they work sometimes but not in general. I may fix that later....nccmath
definesfleqn
andceqn
environments, which work somewhat likesubequations
.