4

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.

0

2 Answers 2

7

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}
5

Mico has suggested better markup, so here I concentrate on explaining the output that you get. Mainly it is (almost always) user error to use align with no alignment points.

I annotated your original example

enter image description here

\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}

Math block left alighted (fleqn, and mathindent is 0), math within the block fush right (as no \&.)
    \begin{align*}
        I=O+P \\
        \int^o_p (x-1)^2 \,dx
    \end{align*}

Math block indented by paragraph indent as inline. Each line of math within the block flush right as no \&

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


As case 1, math block flush left but each line is flush right within the block.
\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*}

Math block flush left , aligned on =
\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.