1

enter image description here

How can I make this in LaTeX? So that both the words and the equality symbols are aligned, exactly like in the image

1
  • 4
    Welcome to TeX.SE. We generally frown on questions that simply post an image and ask us to do everything. Do you have an attempt of what you've done so far? Commented Oct 10, 2024 at 22:03

3 Answers 3

1

You can use the aligned environment:

\documentclass{article} \usepackage{amsmath} \begin{document} $\begin{aligned} &\text{If } & a+x&= a\\ &\text{then } & (-a)+(a+x)&= (-a)+a=0;\\ &\text{hence } & ((-a)+a)+x&=0;\\ &\text{hence } & 0+x&=0;\\ &\text{hence } & x&= 0. \end{aligned}$ \end{document} 
2
  • Does aligned add anything over align* in this case? Commented Oct 10, 2024 at 22:03
  • It gives the same thing, or almost. By default, align* centers the equation, while aligned treats it as "text". So since the set of equations is ragged left, I chose aligned. Commented Oct 10, 2024 at 22:07
1

You can use aligned or alignat, depending on how you want to control the spacing:

\documentclass{article} \usepackage{amsmath} \begin{document} \begin{alignat*}{2} & \mathrm{If} & a + x &= a, \\ & \mathrm{then} & (-a)+(a+x)&= (-a)+a=0;\\ & \mathrm{hence}\quad &((-a)+a)+x &= 0; \\ & \mathrm{hence} & 0 + x &= 0; \\ & \mathrm{hence} & x &= 0. \end{alignat*} \begin{equation*} \begin{aligned} &\mathrm{If} & a+x&= a\\ &\mathrm{then} & (-a)+(a+x)&= (-a)+a=0;\\ &\mathrm{hence} & ((-a)+a)+x&=0;\\ &\mathrm{hence} & 0+x&=0;\\ &\mathrm{hence} & x&= 0. \end{aligned} \end{equation*} \end{document} 

enter image description here

1

I know the current answers already answer this question. But here it goes another option. This using an array environment.

\begin{equation*} \begin{array}{lrcl} \text{If} & a+x & = & a,\\ \text{then} & (-a)+(a+x) & = & (-a)+a=0;\\ \text{hence} & ((-a)+a)+x & = & 0;\\ \text{hence} & 0+x & = & 0;\\ \text{hence} & x & = & 0. \end{array} \end{equation*} 

Make sure to replace \text with \rm in case that you do not want the text to match your current font style and want Roman for some reason. Hope it helps!

This is how it looks compiled.

Edit: As suggested below, one should note that the lines are spaced more closely than in other environments. To control this (if you want to) you can add the desired line space after each linebreak, e.g. \\[1 ex]. My impression is that the array environment gives you more freedom, but this also comes with having to develop the skills to tailor it to suit your needs.

2
  • 1
    Note \rm is not defined by default in latex, and this produces unequal spacing around the = compare the two = on the second line Commented Oct 11, 2024 at 0:58
  • You should also mention (as a caveat for readers) that in an array environment, the material is typeset in text-style math mode instead of in display-style math mode and that the lines are spaced more closely than is the case in a usual multi-row math environment (such as align*). Commented Oct 11, 2024 at 7:19

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.