# Maths, functions in latex, really basic

I am trying to code the following;

f:X->Y
x|->f(x)

where -> is \longrightarrow and |-> is \longmapsto. However, my problem is that I am unable to get the x directly underneath the X. I tried the following code:

\\* $f : X\longrightarrow Y$
\\* $\hphantom{<1>}$x\longmapsto f(x)\$\\


However this doesn't get it directly under the X as desired. Any help will be much appreciated.

-
Sorry it didn't appear properly in this post, I wanted the small x directly under the big X –  Eduardo Dec 13 '13 at 17:29
Use the align environment from amsmath package. –  Thruston Dec 13 '13 at 17:31
Is this expression supposed to occur in a two-line displaymath context with both lines set in the same font size, or is supposed to occur in inline math and with x\longmapsto f(x) fairly small and set below f:X\longrightarrow Y? Please advise. –  Mico Dec 13 '13 at 18:09

\begin{equation*}
\begin{split}
f: & X\rightarrow Y ,\\
& x\mapsto f(x).
\end{split}
\end{equation*}

-

I would personally prefer the alignment offered by a direct use of array:

\documentclass{article}

\usepackage{amsmath}

\begin{document}
$\begin{array}{@{}r@{\;}c@{\;}c@{\;}l@{}} f: & X & \rightarrow & Y, \\ & x & \mapsto & f(x). \end{array}$
\end{document}


The first argument of array (i.e. @{}r@{\;}c@{\;}c@{\;}l@{} in this case) is a specification for the alignment of the columns, as found in the tabular environment. The @{...} part specifies the space between the columns and I use it here (as suggested by @egreg in the comments) to make the spacing more uniform with the rest of the document.

-
IMO this gives too much space, and the X \to Y  part end up looking inconsistent with other X\to Y in the normal text –  daleif Dec 13 '13 at 18:05
\begin{array}{@{}r@{\;}c@{\;}c@{\;}c@{}} –  egreg Dec 13 '13 at 18:06
@egreg Thanks that's exactly what I was going to propose in a moment! Spot on as always =) –  Bordaigorl Dec 13 '13 at 18:08
Edited as suggested by @egreg –  Bordaigorl Dec 13 '13 at 18:12