4

I'd like to do something like this

enter image description here

What would be the code? does it use a package for doing the $$f\mapsto f\circ \pi$$ part?

2
  • Not at all. Math mode will do. Either between $ signs (as you already have it) or in display mode between \[ \] or \begin{equation} and \end{equation}. Or are you referring to the indentation?
    – Count Zero
    May 12 '13 at 19:19
  • 3
    I think you might be interested in Math Mode by Herbert Voß which provides much useful information
    – cgnieder
    May 12 '13 at 19:21
11

You can use the following.

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align*}
  \pi^{\ast} \colon C^{k}(P,N) &\to     C^{k}(M,N)  \\[-1ex]
  f                            &\mapsto f \circ \pi
\end{align*}

\end{document}

output

Remember to use \colon for maps; with : you will get wrong spacing acound the colon.

6
  • »I don't think there is a package for this« - but you are loading amsmath ;)
    – cgnieder
    May 12 '13 at 19:23
  • @cgnieder Well, I meant a package for typing only this specifically in an easier way. :) May 12 '13 at 19:24
  • the problem with this approach is the spacing between the upper and the lower part I guess it's too big, is there a way to fix it?
    – Dion
    May 12 '13 at 19:25
  • @Dion See updated answer. May 12 '13 at 19:28
  • @Dion You can change -1ex to whatever length fits your needs. May 12 '13 at 19:31
5

You can use a self-defined command with a better syntax than using five arguments:

\documentclass{article}
\usepackage{xparse,array}

\NewDocumentCommand{\map}{s m >{\SplitArgument{1}{\to}}m >{\SplitArgument{1}{\mapsto}}m}
 {\IfBooleanTF{#1}{\onelinemap{#2}#3#4}{\twolinemap{#2}#3#4}}

\NewDocumentCommand{\onelinemap}{mmmmm}
 {#1\colon #2\to#3,\quad #4\mapsto #5}

\NewDocumentCommand{\twolinemap}{mmmmm}
 {\begin{array}{@{}r@{}>{{}}l@{}}
  #1\colon #2 & \to #3\\
  #4 & \mapsto #5
  \end{array}}

\begin{document}
\[
\map*{\pi}{C^k(P,N) \to C^k(M,N)}{f \mapsto \pi\circ f}
\]
\[
\map{\pi}{C^k(P,N) \to C^k(M,N)}{f \mapsto \pi\circ f}
\]
\end{document}

The *-variant prints a one line version.

enter image description here

1
  • you could also define this way: \newcommand{\map}[5]{\displaystyle #1:#2&\longrightarrow #3\[-2ex]#4&\longmapsto #5} The command would be: \begin{align*} \map{\pi}{C^k(P, N)}{C^k(M, N)}{f}{\pi\circ f} \end{align*} \end{document} The way I defined it makes it works only inside the align environment... I guess you save some charachters when typing..
    – Dion
    May 13 '13 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.