How do I represent a mathematical function in LaTeX? [duplicate]

This question already has an answer here:

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?

marked as duplicate by egreg amsmath StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Jul 3 '16 at 18:18

• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – karlkoeller Jul 3 '16 at 17:49
• @SAM English is not my native language, hope now it's better. – karlkoeller Jul 3 '16 at 18:10

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} 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} 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} • You can also substitute \rightarrow with \to. – karlkoeller Jul 3 '16 at 18:03

I am not sure what you mean by |, but for aligning equations, the align-environment is often used. Here it will align at the arrow since I put & right in front of the \Rightarrow. This is explained further in the documentation.

Note that you can always locate the documentation using the command-line/terminal by writing texdoc amsmath, and that works for any package. The documentation is also available at http://ctan.org/pkg/amsmath

It might sound tedious to look up the documentation for various small problems/features, but the package documentations tend to be well-written and easy to browse. Also, it will at the same time help you to understand how LaTeX works.

Output Code

\documentclass[11pt]{article}
\usepackage{mathtools}
\begin{document}
\begin{align}
F: x &\Rightarrow Y\\
x &\Rightarrow 2x
\end{align}
\end{document}