TransWikia.com

How to align and center a set of equations?

TeX - LaTeX Asked by Mauricio Mendes on December 9, 2020

I would like to align all equations at the equal sign and center the whole set. I did the following, but it did not work.

begin{align*}
    D_A& =D_C\
{D_A}_0 + Delta D_A &= {D_C}_0 + Delta D_C\
{D_A}_0 + {D_A}_0alpha_ADelta T &= {D_C}_0 + {D_C}_0alpha_CDelta T\
Delta T &= frac{{D_C}_0 - {D_A}_0}{{D_A}_0alpha_A - {D_C}_0alpha_C}\
    T &= frac{{D_C}_0 - {D_A}_0}{{D_A}_0alpha_A - {D_C}_0alpha_C} + 20\
    &= frac{5,998-6}{6times11times10^{-6} - 5,998times17times10^{-6}} + 20\
    &approx 75,61si{degree}C
end{align*}

What is the correct way to do it? Thanks in advance.

2 Answers

The display is centered as a whole and no attempt is made to place the alignment point at the center of the page.

It looks quite unbalanced, in my opinion. You can reduce the effect by avoiding to align equals signs that are not really related to one another, see the second display below.

A few tips: numbers with a decimal part and the comma as separator should be input with num, which takes care of the correct spacing. Also 75,61si{degree}C should be

SI{75,61}{celsius}

For “double subscripts” the syntax is D_{A_0}.

In the following code kantlipsum is just to produce mock text for showing the text block margins.

documentclass{article}
usepackage{amsmath,siunitx}
usepackage{kantlipsum}

sisetup{output-decimal-marker={,}}

begin{document}

kant*[1][1-3]
begin{align*}
D_A &= D_C\
D_{A_0} + Delta D_A
    &= D_{C_0} + Delta D_C\
D_{A_0} + D_{A_0}alpha_ADelta T
    &= D_{C_0} + D_{C_0}alpha_CDelta T\
Delta T
    &= frac{D_{C_0} - D_{A_0}}{D_{A_0}alpha_A - D_{C_0}alpha_C}\
T   &= frac{D_{C_0} - D_{A_0}}{D_{A_0}alpha_A - D_{C_0}alpha_C} + 20\
    &= frac{num{5,998}-6}{6times11times10^{-6} - num{5,998}times17times10^{-6}} + 20\
    &approx SI{75,61}{celsius}
end{align*}
kant*[2][1-3]
begin{align*}
&D_A = D_C \
&D_{A_0} + Delta D_A = D_{C_0} + Delta D_C \
&D_{A_0} + D_{A_0}alpha_ADelta T = D_{C_0} + D_{C_0}alpha_CDelta T \[1ex]
&Delta T = frac{D_{C_0} - D_{A_0}}{D_{A_0}alpha_A - D_{C_0}alpha_C} \[1ex]
&begin{aligned}
T   &= frac{D_{C_0} - D_{A_0}}{D_{A_0}alpha_A - D_{C_0}alpha_C} + 20\
    &= frac{num{5,998}-6}{6times11times10^{-6} - num{5,998}times17times10^{-6}} + 20\
    &approx SI{75,61}{celsius} smash[b]{vphantom{frac{1}{1}}}
end{aligned}
end{align*}
kant[3][1-3]

end{document}

enter image description here

The final smash[b]{vphantom{frac{1}{1}}} is meant to vertically space the approx sign so as to approximately match the spacing between the two equals signs above it (it could be made exact, but it doesn't seem really necessary).

Some vertical space has been added between the main blocks.

Answered by egreg on December 9, 2020

It is centred w.r.t. the margins. So if it doesn't look centred, there's something else in your code that you didn't show.

enter image description here

Answered by Bernard on December 9, 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