# Aligning equal signs in align environment Is it possible to align the second equal sign to the fourth? So I want to have space in front of the second equal sign, so that all equal signs are pairwise aligned. The code is the following

\documentclass[a4paper,10pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}
\begin{align*}
(dx_1)^2&=d(r\cos\xi)^2=(\cos\xi dr-r\sin\xi d\xi)^2\\
(dx_i)^2&=d(r\omega_i\sin\xi)^2=(\omega_i\sin\xi dr+r\omega_i\cos\xi d\xi+r\sin\xi d\omega_i)^2
\end{align*}
\end{document}


with alignat:

edit: corrected position of ampersands, as suggested egreg in his comment

\documentclass[a4paper,10pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}
\begin{alignat*}{2}
(dx_1)^2 & = d(r\cos\xi)^2         && = (\cos\xi dr-r\sin\xi d\xi)^2\\
(dx_i)^2 & = d(r\omega_i\sin\xi)^2 && = (\omega_i\sin\xi dr+r\omega_i\cos\xi d\xi+r\sin\xi d\omega_i)^2
\end{alignat*}
\end{document} or with array:

\documentclass[a4paper,10pt]{scrartcl}
\usepackage[utf8]{inputenc}

\begin{document}
$\setlength\arraycolsep{1pt} \begin{array}{rll} (dx_1)^2 & = d(r\cos\xi)^2 & = (\cos\xi dr-r\sin\xi d\xi)^2\\ (dx_i)^2 & = d(r\omega_i\sin\xi)^2 & = (\omega_i\sin\xi dr+r\omega_i\cos\xi d\xi+r\sin\xi d\omega_i)^2 \end{array}$
\end{document} addedndum: many people are strict in distinguishing between variables (italic shape) and operators (roman shape). this convention is supported by the package physics (and others) and consider in the first two equations in the next example.

if you prefer to have operator d in italic shape, than it is usual emphasize with small space before it (see second two equations). for this you can define new command, for example :

\newcommand{\df}{\mathop{}\!d}


as suggested egreg:

\documentclass[a4paper,10pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{physics}

\newcommand{\df}{\mathop{}\!d}

\begin{document}
\begin{alignat*}{2}
(\dd x_1)^2 & = \dd(r\cos\xi)^2         && = (\cos\xi \dd r-r\sin\xi \dd \xi)^2\\
(\dd x_i)^2 & = \dd(r\omega_i\sin\xi)^2 && = (\omega_i\sin\xi \dd r+r\omega_i\cos\xi \dd \xi+r\sin\xi \dd \omega_i)^2
\end{alignat*}

\begin{alignat*}{2}
(\df x_1)^2 & = \df(r\cos\xi)^2         && = (\cos\xi \df r-r\sin\xi \df \xi)^2\\
(\df x_i)^2 & = \df(r\omega_i\sin\xi)^2 && = (\omega_i\sin\xi \df r+r\omega_i\cos\xi \df \xi+r\sin\xi \df \omega_i)^2
\end{alignat*}
\end{document} • Wrong spacing around the second = sign. You just need {alignat*}{2} and to write &&= instead of &=& – egreg Sep 28 '18 at 17:43
• @egreg, i notice this. i will look, what i miss. – Zarko Sep 28 '18 at 17:46
• @egreg, thank you for tip. i'm not very familiar with alignat ... corrected now! – Zarko Sep 28 '18 at 17:50
• I'd also recommend to change all differential d into \df after giving the definition \newcommand{\df}{\mathop{}\!d} that will nicely space the differential when needed. – egreg Sep 28 '18 at 17:52
• well, this improvement is for extra bonus. i will add this to answer too asap – Zarko Sep 28 '18 at 17:54