TransWikia.com

Alignment in latex

TeX - LaTeX Asked by rmp on May 5, 2021

I am putting my solutions in latex format but I can’t write it properly because I can’t align (see image). Is there any way that I can align the u and du to the integrands in the image?

enter image description here

2 Answers

Like this?

enter image description here

documentclass{article}
usepackage{amsmath}

begin{document}

begin{align}
intfrac{cos y}{sin y}, dy  & = intfrac{cos x}{sin x}, dx  
begin{aligned}
 u & = sin y                           
du & = cos(y), dy
end{aligned}                   &qquad begin{aligned}
                                     u & = cos x       
                                    du & = -sin(x), dx
                                        end{aligned}
end{align}

end{document}

or

enter image description here

documentclass{article}
usepackage{amsmath}

begin{document}

begin{equation}
underbrace{intfrac{cos y}{sin y}, dy}_{%
           begin{aligned}
            u & = sin y       
           du & = cos(y), dy
           end{aligned}}     = underbrace{intfrac{cos x}{sin x}, dx}_{%
                                   begin{aligned}
                                    u & = cos x       
                                   du & = -sin(x), dx
                                       end{aligned}}
end{equation}

end{document}

Correct answer by Zarko on May 5, 2021

You may want to have the substitutions right aligned with the integral on the left and left aligned with the one on the right.

You can use alignat in order to make multiple alignment points.

documentclass{article}
usepackage{amsmath}

begin{document}

begin{alignat*}{2}
intfrac{cos(y)}{sin(y)}, dy  & ={} &&! intfrac{cos(x)}{sin(x)}, dx  
begin{aligned}
 u & = sin(y) 
du & = cos(y), dy
end{aligned}
&&&
begin{aligned}
 u & = cos(x) 
du & = -sin(x), dx
end{aligned}
end{alignat*}

end{document}

enter image description here

I won't question the math, which seems just a mockery for a real situation.

Notes.

  1. ={} is needed in order to get correct spacing: no space after the = sign would be added by TeX, otherwise.
  2. ! before int is needed to avoid incorrect spacing: after an odd-numbered &, alignat adds {} (that is responsible for the correct spacing of the relation symbol that usually starts even-numbered columns); in this case it would add a thin space because int follows immediately.

Answered by egreg on May 5, 2021

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