[Tex/LaTex] How to represent a mathematical function in LaTeX?

amsmathmath-mode

I want to write something like

F : X —-> Y

x |—> 2x

in LaTeX where the

x |—> 2x

appears directly below

F : X —-> Y

Any suggestions on how to do this?

Best Answer

This should be the right approach:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{align*}
F\colon & X \rightarrow Y \\
        & x \mapsto 2x
\end{align*}
\end{document} 

enter image description here

If you prefer a different alignment move the &:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{align*}
F\colon X & \rightarrow Y \\
        x & \mapsto 2x
\end{align*}
\end{document} 

enter image description here

If you also prefer longer arrows, use \longrightarrow and \longmapsto:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{align*}
F\colon X & \longrightarrow Y \\
        x & \longmapsto 2x
\end{align*}
\end{document}

enter image description here