TransWikia.com

Indentation of the align environment

TeX - LaTeX Asked by raf on August 29, 2020

My code:

begin{itemize}
  item Case $1$ :
             begin{align*}
                         & 2^x-1 =0\
                         implies & 2^x = 1 \
                         implies & ln(2^x) = ln(1)  & text{ [taking natural  logarithm on both sides]} \ 
                        implies & x ln2 = 0 \
                        therefore & quad x = 0 
             end{align*}
  item Case $2$ :
               begin{align*}
                         & x+3 =0\
                         therefore & quad x = -3 
               end{align*}
  item Case $3$ :
             begin{align*}
                         & x-1 =0\
                         therefore &  quad x = 1 
             end{align*}
end{itemize}

Now the problem is I don’t want to center the equations in the cases 2 and 3. I want to keep them along the red line I have marked on its output.

enter image description here

How can I prove my code for such desired output?

2 Answers

One can use flalign to NOT center equations, but you need an extra && in at least one line to take up the right side of the page. The indentation is achieved using a minipage, effectively reducing textwidth to the remaining space.

documentclass{article}
usepackage{mathtools, amssymb}
usepackage{showframe}% alignment tool

newlength tempwidth
settowidth{tempwidth}{Case $2$ :}

begin{document}

begin{itemize}
  item Case $1$ :begin{minipage}[t]{dimexpr linewidth-tempwidth}
             abovedisplayskip=0pt% or even -baselineskip
             begin{flalign*}
                         & 2^x-1 =0 &&\
                         implies & 2^x = 1 \
                         implies & ln(2^x) = ln(1) & text{ [taking natural logarithm on both sides]} \
                        implies & x ln2 = 0 \
                        therefore & quad x = 0
             end{flalign*}end{minipage}
  item Case $2$ :begin{minipage}[t]{dimexpr linewidth-tempwidth}
             abovedisplayskip=0pt
             begin{flalign*}
                   phantom{implies} & x+3 =0 &&\
                         therefore & quad x = -3
             end{flalign*}end{minipage}
  item Case $3$ :begin{minipage}[t]{dimexpr linewidth-tempwidth}
             abovedisplayskip=0pt
             begin{flalign*}
                   phantom{implies} & x-1 =0 &&\
                         therefore & quad x = 1
             end{flalign*}end{minipage}
end{itemize}

end{document} 

demo

Answered by John Kormylo on August 29, 2020

Like this?

documentclass{article}
usepackage{mathtools, amssymb}

begin{document}

begin{itemize}
  item Case $1$ :
             $ begin{aligned}[t] \
                         & 2^x-1 =0\
                         implies & 2^x = 1 \
                         implies & ln(2^x) = ln(1) & text{ [taking natural logarithm on both sides]} \
                        implies & x ln2 = 0 \
                        therefore & quad x = 0
             end{aligned} $
  item Case $2$ :
              $ begin{aligned}[t] \
                   phantom{implies} & x+3 =0\
                         therefore & quad x = -3
               end{aligned} $
  item Case $3$ :
             $ begin{aligned}[t] \
                   phantom{implies} & x-1 =0\
                         therefore & quad x = 1
             end{aligned} $
end{itemize}

end{document} 

enter image description here

Answered by Bernard on August 29, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP