I have a set of equations and I want to have them left-aligned instead of center-aligned. Also, I want them all to be numbered. I searched a bit and found that using flalign
we can achieve this. But the results are not what I want. I want all the equations to start from the left at same position. What am I missing?
Here's the minimal working example showing what I have tried:
\documentclass{article}
\usepackage[fleqn]{amsmath}
\begin{document}
\begin{flalign}
f_1 = \sigma(W_{1}x_1+W_{2}h_{1}+W_{3}c_{1}+b_1) \\
f_2 = \sigma(W_{2}x_2+b_2) \\
c = f_i c+i\; \mathrm{cos}(W_{3}x_1+W_{3}h_{1}+b_3) \\
y=c\; \mathrm{tanh}(f_1.f_2)
\end{flalign}
\end{document}
Best Answer
Under any of the
align
-like environments, each row follows ar
ight-&
-l
eft alignment. As such, the first element in each row will necessarily ber
ight-aligned, as you observed. If you want al
eft-alignment, consider adding "an empty first group" by just prepending each row by&
.Here are some options:
You might be interested in the first representation. I prefer the second.
Note that there already exist operators for the math function you write in
r
om
an font:\cos
and\tanh
. If you wish to define additional ones (and therefore provide the appropriate spacing) use\operatorname
and/or\DeclareMathOperator{<macro>}{<name>}
. See What's the difference between\mathrm
and\operatorname
? and Define additional math operators to be typeset in roman.