4

There are many question on this community website asking about how to align equations at = sign. It is not too hard, I already did it and your answers helped me a lot. This is my code:

\documentclass[a4paper, 12pt]{article}

\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}
\usepackage{color}
\usepackage{amsfonts}
\usepackage{amstext}
\usepackage{amsmath}

\begin{document}

\setlength\parindent{0pt}
\definecolor{darkGreen}{RGB}{0, 128, 0}
\nonumber

$Q=\sqrt2$

\begin{align}
P&=\sqrt2\\
&=Q
\end{align}

\end{document}

And this is rendered into PDF like this:

enter image description here

However, you can notice that the first equation $Q = \sqrt {2}$ is rendered left, but aligned one is rendered on the center. It is aligned properly, but I want it to be rendered left.

I want it to look like this:

enter image description here

So, I want it to be rendered left, but to remain alignment at the equality sign.

So, what I'm trying to achieve is to render it such that the longest equation in the alignment block touches left margin of the document (like on the second image). How hard is to achieve that?

Is there a simple way to achieve that? Is there some builtin? Or do I need to do everything from scratch? Do I need to create a new command for that?

Thank you in advance :)

0

2 Answers 2

3

You can use the aligned environment (inside math-mode) to be able to align the lines of an equation at the equality signs without centering the whole equation:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{color}
\usepackage{amsmath}

\setlength\parindent{0pt}

\begin{document}

$\begin{aligned}
    Q&=\sqrt2
\end{aligned}$

$\begin{aligned}
P&=\sqrt{2} \\
&=Q
\end{aligned}$

\end{document}

enter image description here

(frame added to show where the page margins are)

5
  • 1
    So I was using wrong environment? Align and aligned? Oh thank you. That exactly solved my problem. Aug 28, 2017 at 7:23
  • 1
    Well, most people will most of the time want to use the align environment. However, if you specifically don't want to center the equation in the page, then you are better of with aligned.
    – Tiuri
    Aug 28, 2017 at 7:25
  • @МногочленыЧебышёва Note that with $\begin{aligned}..\end{aligned}$ you will not get equation numbers, unlike align. Aug 28, 2017 at 7:26
  • @TorbjørnT. In the MWE, the numbering feature of align was explicitly turned off.
    – Tiuri
    Aug 28, 2017 at 7:26
  • Ah, right, didn't notice that \nonumber. Didn't even know it worked like that, I usually see it for a single line of a multi-line display. Aug 28, 2017 at 7:31
1

align is a displayed environment, meaning it will always be set in a separate block. $..$+aligned is inline math. This also affects the default rendering, as $...$ uses \textstyle, while align uses \displaystyle. This affects for example the size of operators, and the position of sub/superscripts for operators. See example below, and also Show inline math as if it were display math

You could add fleqn as an option the the class, or to amsmath, and set \mathindent to zero. That will make all displayed equations flush against the left margin.

output of code

\documentclass[a4paper, 12pt]{article}

\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}
\usepackage{color}
\usepackage{amsfonts}
% fleqn option = flush left equations, except for \mathindent
\usepackage[fleqn]{amsmath}

% sets zero parindent, and increases parsep
\usepackage{parskip}

% set \mathindent to zero
\setlength\mathindent{0pt}

\definecolor{darkGreen}{RGB}{0, 128, 0}
\begin{document}
$Q=\sqrt{2}\int_{a}^{b} f(x)\, dx$ And then some text.
\begin{align*}
P&=\sqrt{2}\int_{a}^{b} f(x)\, dx\\
&=Q
\end{align*}
And then some text.
\end{document}
3
  • Thank you, this works too. Can you just please explain the difference between align and align*? Aug 28, 2017 at 8:17
  • @МногочленыЧебышёва The starred versions of the amsmath environments are unnumbered. Aug 28, 2017 at 8:18
  • Thanks for explaining. However, I'm not able to accept multiple answers and I don't have enough rep to upvote, so sorry about that :/ Aug 28, 2017 at 8:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .