How to make a composition of functions prettier?

A solution based on alignat* and \xmapsto. Requires mathtools and eqparbox:

\documentclass[11pt]{article}
\usepackage{mathtools}
\DeclareMathOperator{\id}{id}
\usepackage{eqparbox}
\newcommand{\eqmathbox}[2][M]{\eqmakebox[#1]{$\displaystyle#2$}}

\begin{document}

    \begin{alignat*}{2}
            G\times U & \xrightarrow{\id\times \sigma} \eqmathbox{G\times \pi^{-1}(U)} & & \xrightarrow[\phantom{\id\times \sigma}]{\theta} \pi^{-1}(U) \\[-1.5ex]
            (g, [x]) & \xmapsto{\phantom{\id\times \sigma}} \eqmathbox{(g,\sigma[x])} & & \xmapsto[\phantom{\id\times \sigma}]{} g\cdot \sigma[x]
    \end{alignat*}

\end{document} 

enter image description here


One way to align (actually, center) everything is to use some package for commutative diagrams, for example tikz-cd:

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\begin{document}
\[
\begin{tikzcd}[row sep=0pt]
  G\times U \arrow[r,"\mathrm{id}\times \sigma"] & G\times \pi^{-1}(U)
  \arrow[r,"\theta"] &\pi^{-1}(U) \\
  (g, [x])  \arrow[r,mapsto] &(g,\sigma[x])  \arrow[r,mapsto] & g\cdot \sigma[x]
\end{tikzcd}
\]
\end{document}

(Changes after the comments: \textrm{} is replaced by \mathrm{} as per egreg's suggestion, the diagram is places inside display math.)

The result is:

enter image description here


I suppose that this will do what you want:

\documentclass[11pt]{article}
\usepackage{amsmath}
\begin{document}
  \[\begin{array}{ccccc}
        G\times U & \xrightarrow{\textrm{id}\times \sigma}& G\times \pi^{-1}(U) &\xrightarrow{\theta}&\pi^{-1}(U) \\
        (g, [x]) &\longmapsto &(g,\sigma[x]) &\longmapsto&g\cdot \sigma[x]
\end{array}\]
\end{document}

Here is how it looks:

screenshot

Tags:

Align

Amsmath