Which environment should I use to align the equations to the left

alignmentbest practiceshorizontal alignment

I would like to know the "best" environment to align equations to the left. I already use fleqn at the beginning of my document and $\begin{aligned} ... \end{aligned}$ when I write equations in the "enumerate" environment. I would like to align my text like this,

enter image description here

but I don't know what is the best environment to do that and how to do it. Also, sometimes, I get weird indentations, at the beginning of lines depending on the environment and I sometimes have my text left aligned while right aligned (see third block of equation) and I was wondering why Latex aligns my equations like this.

enter image description here

The code:

\documentclass[fleqn, 12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, amsthm, amssymb, mathtools}
\usepackage[margin=1.25in, showframe]{geometry}
\setlength{\mathindent}{0pt}
\setlength{\jot}{1ex}
\usepackage[nodisplayskipstretch]{setspace}
\setstretch{1.25}

\begin{document}
    \begin{align*}
        I=O+P \\
        \int^o_p (x-1)^2 \,dx
    \end{align*}

$\begin{aligned}
    I=O+P \\
    \int^o_p (x-1)^2 \,dx
\end{aligned}$


\begin{align*}
    u_1\in U_1 \Rightarrow u_1\in U_1 \cup U_2 \\
    u_2\in U_2 \Rightarrow u_2\in U_1 \cup U_2 \\
    \textrm{Since } U_1 \cup U_2 \textrm{ is a subspace of $V$, } u_1+u_2\in U_1 \cup U_2 \\
    \Rightarrow u_1+u_2\in U_1 \textrm{ or } u_1+u_2\in U_2
\end{align*}

\begin{align*}
    R_{eq}=\left(\frac{1}{R_1}+\frac{1}{R_2}\right)^{-1} &= \left(\frac{1}{3000}+\frac{1}{1000}\right)^{-1} \\
    &= 750
\end{align*}

\end{document}

Thanks in advance for your answers.

Best Answer

I suggest that you (a) replace the first two align* environments with gather* environments and (b) start using alignment points in the aligned environment (and place a \noindent directive before the aligned environment).

As an alternative to suggestion (a) above, consider (a') keep using the align* environments but start using alignment markers (&), one at the start of both lines in the first align* environment, and one at the start of all four lines in the second align* environment.

You also asked,

sometimes, I get weird indentations, at the beginning of lines depending on the environment and I sometimes have my text left aligned while right aligned (see third block of equation) and I was wondering why Latex aligns my equations like this.

That would be because you're not using a single alignment marker in that align* environment. See suggestion (a') above.

enter image description here

\documentclass[fleqn, 12pt]{article}
%% \usepackage[utf8]{inputenc} % <-- that's the default nowadays
\usepackage[margin=1.25in, showframe]{geometry}

\usepackage{mathtools, amsthm, amssymb}
\setlength{\mathindent}{0pt}
\setlength{\jot}{1ex}

\usepackage[nodisplayskipstretch]{setspace}
\setstretch{1.25}

\begin{document}

\begin{gather*}
     I=O+P \\
     \int^0_p (x-1)^2 \,dx
\end{gather*}

\noindent % <-- important
$\begin{aligned}
    &I=O+P \\
    &{\int^0_p (x-1)^2 \,dx}
\end{aligned}$

\begin{gather*}
    u_1\in U_1 \Rightarrow u_1\in U_1 \cup U_2 \\
    u_2\in U_2 \Rightarrow u_2\in U_1 \cup U_2 \\
    \textrm{Since } U_1 \cup U_2 \textrm{ is a subspace of $V$, } u_1+u_2\in U_1 \cup U_2 \\
    \Rightarrow u_1+u_2\in U_1 \textrm{ or } u_1+u_2\in U_2
\end{gather*}

\begin{align*}
    R_{\mathrm{eq}}=\left(\frac{1}{R_1}+\frac{1}{R_2}\right)^{-1} 
         &= \left(\frac{1}{3000}+\frac{1}{1000}\right)^{-1} \\
         &= 750
\end{align*}

\end{document}
Related Question