# How to center set of equations?

I have four math function definitions, and I want to center them, such that function names start from the same point, and after the colon there is some blank space before the domain and range is defined. Currently, I have this code segment:

\documentclass{paper}
\begin{document}

\begin{center}
$\mathsf{Gen}: \mathbb{N} \rightarrow \mathcal{K}_p \times \mathcal{K}_s \times \mathcal{K}_e$

$\mathsf{Enc}: \mathcal{K}_p \times \mathcal{P} \rightarrow \mathcal{X}$

$\mathsf{Dec}: \mathcal{K}_s \times \mathcal{Z} \rightarrow \mathcal{P}$

$\mathsf{Eval}: \mathcal{K}_e \times \mathcal{C} \times \mathcal{Z^*} \rightarrow \mathcal{Y}$
\end{center}

\end{document}


But this results in a kind of distorted output. I want the output to look like this:

Any ideas how to achieve it? Please note that the whole group of equations should also be centered in the page.

• ! Undefined control sequence. l.5 \mathsf{Gen}: \mathbb Dec 29 '16 at 21:29 ## 3 Answers perhaps with align \documentclass{paper} \usepackage{amsmath,amsfonts} \begin{document} \begin{align*} \mathsf{Gen}:&& \mathbb{N} &\rightarrow \mathcal{K}_p \times \mathcal{K}_s \times \mathcal{K}_e\\ \mathsf{Enc}:&& \mathcal{K}_p \times \mathcal{P} &\rightarrow \mathcal{X}\\ \mathsf{Dec}:&& \mathcal{K}_s \times \mathcal{Z} &\rightarrow \mathcal{P}\\ \mathsf{Eval}:&& \mathcal{K}_e \times \mathcal{C} \times \mathcal{Z^*} &\rightarrow \mathcal{Y} \end{align*} \end{document}  A variant with align, and another with alignat: \documentclass{paper} \usepackage{amsmath,amsfonts} \begin{document} \begin{align*} & \mathsf{Gen}: & \mathbb{N} & → \mathcal{K}_p × \mathcal{K}_s × \mathcal{K}_e & & \\ & \mathsf{Enc}:& \mathcal{K}_p × \mathcal{P} & → \mathcal{X}\\ & \mathsf{Dec}:& \mathcal{K}_s × \mathcal{Z} & → \mathcal{P}\\ & \mathsf{Eval}:& \mathcal{K}_e × \mathcal{C} × \mathcal{Z^*} & → \mathcal{Y} \end{align*} \begin{alignat*}{2} & \mathsf{Gen}: & \hspace{5em} & \mathbb{N} → \mathcal{K}_p × \mathcal{K}_s × \mathcal{K}_e \\ & \mathsf{Enc}: & & \mathcal{K}_p × \mathcal{P} → \mathcal{X} \\ & \mathsf{Dec}: & & \mathcal{K}_s × \mathcal{Z} → \mathcal{P} \\ & \mathsf{Eval}: & & \mathcal{K}_e × \mathcal{C} × \mathcal{Z^*} → \mathcal{Y} \end{alignat*} \end{document}  • Why have three & in each line in the first block of equations while using align*? Jan 2 '17 at 15:07 • Because there are two alignment points. n alignment points require 2n – 1 ampersands. Jan 2 '17 at 15:14 • If there are two alignment points, shouldn't you only use {alignat*}{2} then, as in the latter construction? (David has done the same as you, but I don't understand why.) Jan 2 '17 at 15:33 • alignat (which I use in the second code) adds the possibility to control the spacing between the alignment groups. That is the reason for \hspace{5em}. Jan 2 '17 at 15:42 • @soodehMehboodi: Why not simply2\mathbb{Z}^{+}$(or$2\mathbf{Z}^{+}$)? Jan 9 '20 at 19:20 Here is how I would do it: \documentclass{paper} \usepackage{amsmath} \usepackage{amsfonts} \newcommand*\name[1]{\text{$\mathsf{#1}\$:}}
\newcommand*\letter[1]{\mathcal{#1}}

\begin{document}

\begin{alignat*}{2}
&\name{Gen}  &       \mathbb{N}     \times \letter{A}                          &\to \letter{K}_{p} \times \letter{K}_{s} \times \letter{K}_{e},\\
&\name{Enc}  &       \letter{K}_{p} \times \letter{P}                          &\to \letter{X},\\
&\name{Dec}  &       \letter{K}_{s} \times \letter{Z}                          &\to \letter{P},\\
&\name{Eval} &\qquad \letter{K}_{e} \times \letter{C} \times \letter{Z}^{\ast} &\to \letter{Y}.
\end{alignat*}

\end{document}


Notice the removal of space between the words/abbreviations and the colons.