Horizontal alignment of two lines of text

I am trying to horizontally align the words "if", as depicted in the image below.

I have tried to use a minipage environment, but this did not yield the desired result. The code for this section of text is shown below.

\documentclass[a4paper,12pt]{extarticle}

\usepackage{graphicx,float}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{float}

\begin{document}
\textit{Case 2}:
If $s=0$, then
$\sum_{r=1}^{N} \exp\left(\frac{2\pi irs}{N}\right)=\sum_{r=1}^{N} 1=N.$ If $s=N$, then
$\sum_{r=1}^{N} \exp\left(\frac{2\pi irs}{N}\right)=\sum_{r=1}^{N} \exp (2\pi ir)=\sum_{r=1}^{N} [\cos(2\pi r)+i\sin(2\pi r)]=N.$
\end{document}


A simple solution in this case is to use an \hphantom{}:

\hphantom{\textit{Case 2}:}


There are two outcomes, depending on if the initial indent was desired or not:

Notes:

• Besides \hphantom{} which provides the exact horizontal space as its paramter, there is als \vphantom{} which provides only the vertical spacing (with zero horizontal space). For this case you could also have just used the \phatom{} macro which inserts both the horizontal and vertical spacing of its parameter.

Code:

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\noindent
\textit{Case 2}:
If $s=0$, then
$\sum_{r=1}^{N} \exp\left(\frac{2\pi irs}{N}\right)=\sum_{r=1}^{N} 1=N.$
\hphantom{\textit{Case 2}:}
If $s=N$, then
$\sum_{r=1}^{N} \exp\left(\frac{2\pi irs}{N}\right)=\sum_{r=1}^{N} \exp (2\pi ir)=\sum_{r=1}^{N} [\cos(2\pi r)+i\sin(2\pi r)]=N.$

\hrule\medskip\par

\textit{Case 2}:
If $s=0$, then
$\sum_{r=1}^{N} \exp\left(\frac{2\pi irs}{N}\right)=\sum_{r=1}^{N} 1=N.$

\hphantom{\textit{Case 2}:}
If $s=N$, then
$\sum_{r=1}^{N} \exp\left(\frac{2\pi irs}{N}\right)=\sum_{r=1}^{N} \exp (2\pi ir)=\sum_{r=1}^{N} [\cos(2\pi r)+i\sin(2\pi r)]=N.$
\end{document}

• This did not appear to work. Are you able to provide the whole code? – M B Jan 27 at 8:43
• @MB: Yeah, I was working on getting the image to include. – Peter Grill Jan 27 at 8:45
• What a handy command! Thanks for that! – M B Jan 27 at 8:46
• @MB: Yeah I have used it quite often. I will update the answer to mention the other variants. – Peter Grill Jan 27 at 8:47

Do you mean like this?:

\documentclass[a4paper,12pt]{extarticle}

\usepackage{graphicx,float}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{float}

\begin{document}

\begin{align*}
&\text{If} s=0, \text{then}
\sum_{r=1}^{N} \exp\left(\frac{2\pi irs}{N}\right)=\sum_{r=1}^{N} 1=N. \\
&\text{If} s=N, \text{then}
\sum_{r=1}^{N} \exp\left(\frac{2\pi irs}{N}\right)=\sum_{r=1}^{N} \exp (2\pi ir)=\sum_{r=1}^{N} [\cos(2\pi r)+i\sin(2\pi r)]=N.
\end{align*}

\end{document}


or

\documentclass[a4paper,12pt]{extarticle}

\usepackage{graphicx,float}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{float}

\begin{document}

\begin{align*}