4

I can't find a proper way to force the left hand of the equalities on the second row of the first the equation to stick against the equal sign. Ideally, I would like something that looks like the second equation in terms of the alignment.

Here is the code I used for the first equation using in the LibreOffice extension for Latex:

\begin{alignat*}{3}
(x-2)(5-2x)=0 \quad &\Leftrightarrow \quad x-2&&=0 \quad &&\text{ou} \quad 5-2x&&=0 \\
&\Leftrightarrow \quad x&&=2 \quad &&\text{ou} \quad x&&=\frac{5}{2}
\end{alignat*}
2
  • 1
    Welcome to the site, Your code has a compilation error, plus the fact that it is just a snippet and not a complete example starting with \documentclass. Please edit Jan 18 at 2:04
  • I am using a LibreOffice extension for Latex that will compile the code into an image, it is not a snippet. I think that the \documentclass is implemented through the GUI.
    – BlockNoir
    Jan 18 at 2:59

2 Answers 2

7

Each & provides a right and left alignment point. That is, the content on the left of & is right aligned and the content to the right is left aligned. So, if something ends up being aligned on the wrong side you need to add or remove an & to change that:

enter image description here

Code:

\documentclass[11pt]{article}
\usepackage{mathtools}

\begin{document}
\begin{alignat*}{5}
(x-2)(5-2x)= 0 \quad 
    &\Leftrightarrow \quad & x-2 & = 0 && \quad \text{ou} \quad &5-2x&=0 \\
    &\Leftrightarrow \quad &   x & = 2 && \quad \text{ou} \quad &x   &=\frac{5}{2}
\end{alignat*}
\end{document}
1
  • Thank you very much, your answer was very well explained.
    – BlockNoir
    Jan 18 at 3:09
4

I'm sure there is a proper way using alignat, but here, I use facilities of the tabstackengine package.

\documentclass{article}
\usepackage{amsmath,tabstackengine}
\TABstackMath
\setstackgap{L}{1.2\normalbaselineskip}
\setstacktabulargap{0pt}
\TABbinary
\begin{document}
\[
\tabularCenterstack{rlrlcrl}{
(x-2)(5-2x)=0 \quad &\Leftrightarrow \quad& x-2&=0 \quad &\text{ou}& \quad 5-2x&=0 \\
&\Leftrightarrow  &x&=22 \quad &\text{ou}& \quad x&=\frac{5}{2}
}
\]
\end{document}

enter image description here

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.