# Aligning multiple equations on multiple points

I'm trying to generate the following output in LaTeX:

However I am failing pretty hard at aligning those correctly, this is what I've tried so far:

\begin{align*}
&(a)\hspace{20pt}\lfloor{n/2}\rfloor &< p &\leq\hspace{19pt} n &\Rightarrow {l}_{p}(n\wr)&=1 \\
&(b)\hspace{20pt}\lfloor{n/3}\rfloor &< p &\leq \lfloor{n/2}\rfloor &\Rightarrow {l}_{p}(n\wr)&=0 \\
&(c)\hspace{20pt}\sqrt{n} &< p &\leq \lfloor{n/3}\rfloor &\Rightarrow {l}_{p}(n\wr)&=\lfloor{n/p}\rfloor\mod 2\\
&(d)\hspace{20pt}2 &< p &\leq \sqrt{n} &\Rightarrow {l}_{p}(n\wr)&<\log_2(n)\\
&(d)\hspace{20pt}{} p &= 2 &\Rightarrow {l}_{p}(n\wr)={\sigma}_{2}(\lfloor{n/2}\rfloor)
\end{align*}


How can I do this alignment the right way as presented in the example?

For multiple points (and no big spacing between the blocks) there is alignat. Let's examine your problem, recalling that alignat makes pairs of “right aligned/left aligned” columns.

You have: left aligned column (for the item labels); right aligned column (for the lower bounds); left aligned column (for the relations); right aligned column (for the variable); left aligned column (for the upper bounds); column that can be either left or right aligned (the arrows); left aligned column (for the final conditions).

So we should have

&\text{(a)}\qquad
&\lfloor n/2\rfloor
&<{}
&p
&&\le n
&\implies
&l_p(n\wr)=1
\\


and we should repeat the pattern. We have a total of eight &, which makes for five pairs. The empty group after the relation is to ensure correct spacing. I use \implies that adds some space at either end by itself. I took advantage from the fact that the final condition all have the same structure, so the alignment is automatic; otherwise, follow the same pattern analysis.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{alignat*}{5}
&\text{(a)}\qquad &\lfloor n/2\rfloor &<{} &p &\leq n                  &\implies &l_{p}(n\wr)=1 \\
&\text{(b)}\qquad &\lfloor n/3\rfloor &<{} &p &\leq \lfloor n/2\rfloor &\implies &l_{p}(n\wr)=0 \\
&\text{(c)}\qquad &\sqrt{n}           &<{} &p &\leq \lfloor n/3\rfloor &\implies &l_{p}(n\wr)=\lfloor n/p\rfloor \bmod 2\\
&\text{(d)}\qquad &2                  &<{} &p &\leq \sqrt{n}           &\implies &l_{p}(n\wr)<\log_2(n)\\
&\text{(e)}\qquad &                   &    &p &= 2                     &\implies &l_{p}(n\wr)=\sigma_{2}(\lfloor n/2\rfloor)
\end{alignat*}

\end{document}


I removed all the useless braces (none is needed for \lfloor x\rfloor). Note that “mod” as a binary operation should be \bmod, not \mod.

You may want to consider a space saving macro \floor:

\documentclass{article}
\usepackage{amsmath,mathtools}

\DeclarePairedDelimiter{\floor}{\lfloor}{\rfloor}

\begin{document}

\begin{alignat*}{5}
&\text{(a)}\qquad &\floor{n/2} &<{} &p &\leq n           &\implies &l_{p}(n\wr)=1 \\
&\text{(b)}\qquad &\floor{n/3} &<{} &p &\leq \floor{n/2} &\implies &l_{p}(n\wr)=0 \\
&\text{(c)}\qquad &\sqrt{n}    &<{} &p &\leq \floor{n/3} &\implies &l_{p}(n\wr)=\floor{n/p} \bmod 2\\
&\text{(d)}\qquad &2           &<{} &p &\leq \sqrt{n}    &\implies &l_{p}(n\wr)<\log_2(n)\\
&\text{(e)}\qquad &            &    &p &= 2              &\implies &l_{p}(n\wr)=\sigma_{2}(\floor{n/2})
\end{alignat*}

\end{document}


For example can you use alignat instead of align. I prette printed your code to see better where the columns are. See that I doubled the last two & in each row.

MWE:

\documentclass[a4paper,12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{amsmath}

\begin{document}

\begin{alignat*}{5}
&(a)\hspace{20pt}\lfloor{n/2}\rfloor &< p &\leq\hspace{19pt} n      &&\Rightarrow {l}_{p}(n\wr)&&=1 \\
&(b)\hspace{20pt}\lfloor{n/3}\rfloor &< p &\leq \lfloor{n/2}\rfloor &&\Rightarrow {l}_{p}(n\wr)&&=0 \\
&(c)\hspace{20pt}\sqrt{n}            &< p &\leq \lfloor{n/3}\rfloor &&\Rightarrow {l}_{p}(n\wr)&&=\lfloor{n/p}\rfloor\mod 2\\
&(d)\hspace{20pt}2                   &< p &\leq \sqrt{n}            &&\Rightarrow {l}_{p}(n\wr)&&<\log_2(n)\\
&(d)\hspace{20pt}{} p                &= 2 &                         &&\Rightarrow {l}_{p}(n\wr)&&={\sigma}_{2}(\lfloor{n/2}\rfloor)
\end{alignat*}

\end{document}


Result: