[Tex/LaTex] How to typeset this correspondence in LaTeX

arrowsmath-modetables

I am looking to create a "table" or something similar in LaTeX where I show correspondence/mapping between a natural number and some other natural number, as indicated in the picture below (please excuse the badly drawn Paint example):

enter image description here

In other words "one maps onto zero, two maps onto one…" etc. I am, however, not sure how to do so in LaTeX.

Can anyone please provide me with some help as to how I can go about typesetting something similar to this in a LaTeX environment?

Best Answer

One option using a matrix; an array could also be used, but with matrix you don't have to specify the number and format of columns:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
\begin{matrix}
0 & 1 & 2 \\
\updownarrow & \updownarrow & \updownarrow  \\
2 & 3 & 1 
\end{matrix}
\]

\end{document}

enter image description here

As has been noted, the vertical space around the arrows seems a little uneven: there's more space above the arrows than below them, so one can easily fix it:

\documentclass{article}
\usepackage{amsmath}

\newcommand\UpDownarrow[1][0.2ex]{
  \raisebox{#1}[0pt][0pt]{$\updownarrow$}
}

\begin{document}
\[
\begin{matrix}
0 & 1 & 2 \\
\UpDownarrow & \UpDownarrow & \UpDownarrow \\
2 & 3 & 1 
\end{matrix}
\]

\end{document}

enter image description here

Just for the record, the array version:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
\begin{array}{ccc}
0 & 1 & 2 \\
\updownarrow & \updownarrow & \updownarrow  \\
2 & 3 & 1 
\end{array}
\]

\end{document}