tikz-cd 中的 \leftmapsto

tikz-cd 中的 \leftmapsto

考虑以下代码:

\documentclass{article}
\usepackage{MnSymbol}
\usepackage{tikz-cd}


\begin{document}

$$\begin{tikzcd}
     S^2 - S \arrow[r, "f_+"] & \mathbb R^2 \\
     (x,y,z) \arrow[r, mapsto] & \left( \frac{x}{1+z}, \frac{y}{1+z} \right) \\
     \left( \frac{2u}{1+u^2+v^2}, \frac{2v}{1+u^2+v^2}, \frac{1-u^2-v^2}{1+u^2+v^2}\right) \arrow[r, leftmapsto] & (u,v)
\end{tikzcd}$$
and
$$\begin{tikzcd}
    S^2 - N \arrow[r, "f_-"] & \mathbb R^2 \\
    (x,y,z) \arrow[r, mapsto] & \left( \frac{x}{1-z}, \frac{y}{1-z} \right) \\
    \left( \frac{2u}{1+u^2+v^2}, \frac{2v}{1+u^2+v^2}, \frac{-1+u^2+v^2}{1+u^2+v^2}\right) \arrow[r, leftmapsto] & (u,v)
\end{tikzcd}$$

\end{document}

结果如下图所示,但我想改变箭头的方向,如红色标记。此外,上述代码会引发一些错误。问题是什么?如何修复?

在此处输入图片描述

答案1

让我将我的评论转换为答案。箭头类型在第 3-4 页的文档中列出。tikz-cd没有leftmapsto,但定义如下mapsfrom

\documentclass{article}
\usepackage{amsmath, amssymb}
%\usepackage{MnSymbol}
\usepackage{tikz-cd}


\begin{document}
\[
    \begin{tikzcd}[sep=tiny]
S^2 - S \ar[r, "f_+"]   & \mathbb{R}^2 \\
(x,y,z) \ar[r, mapsto]  & \left(\frac{x}{1+z}, \frac{y}{1+z}\right) \\
\left(\frac{2u}{1+u^2+v^2}, 
      \frac{2v}{1+u^2+v^2}, 
      \frac{1-u^2-v^2}{1+u^2+v^2}\right) \ar[r, mapsfrom] & (u,v)
\end{tikzcd}
\]
and
\[
\begin{tikzcd}[row sep=1ex]
    S^2 - N \arrow[r, "f_-"] & \mathbb{R}^2 \\
    (x,y,z) \arrow[r, mapsto] & \left( \frac{x}{1-z}, \frac{y}{1-z} \right) \\
    \left( \frac{2u}{1+u^2+v^2}, \frac{2v}{1+u^2+v^2}, \frac{-1+u^2+v^2}{1+u^2+v^2}\right) \arrow[r, mapsfrom] & (u,v)
    \end{tikzcd}
\]
\end{document}

笔记:在 LaTeX 中使用 $$ for markingdisplaymath deprecated. For it is defined[ and]`。

在此处输入图片描述

答案2

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{tikz-cd}


\begin{document}

\begin{tikzcd}
     S^{2} - S \arrow[r, "f_+"] & \mathbb{R}^{2} \\
     (x,y,z) \arrow[r, mapsto] & \left(\frac{x}{1+z},\frac{y}{1+z}\right) \\
     \left( \frac{2u}{1+u^2+v^2}, \frac{2v}{1+u^2+v^2}, \frac{1-u^2-v^2}{1+u^2+v^2}\right) \arrow[r, leftarrow] & (u,v)
\end{tikzcd}

and\par

\begin{tikzcd}
    S^2 - N \arrow[r, "f_-"] & \mathbb R^2 \\
    (x,y,z) \arrow[r, mapsto] & \left( \frac{x}{1-z}, \frac{y}{1-z} \right) \\
    \left( \frac{2u}{1+u^2+v^2}, \frac{2v}{1+u^2+v^2}, \frac{-1+u^2+v^2}{1+u^2+v^2}\right) \arrow[r, leftarrow] & (u,v)
\end{tikzcd}

\end{document}

答案3

您可以在没有 的情况下获得图表tikz-cd:ansalign*环境即可,并stmaryrd 能够定义\xmapsfrom箭头。注意,我用 中的中等大小分数替换了 displaystyle 分数nccmath,因此我认为图表看起来更好:

\documentclass{article}
\usepackage{amssymb, stmaryrd}
\usepackage{nccmath}
\usepackage{mathtools}

\makeatletter
 \newcommand{\xmapsfrom}[2][]{%
 \ext@arrow3095\leftarrowfill@{#1}{#2}\mapsfromchar
}
\makeatother

\begin{document}

\begin{align*}
      S^2 - S & \xrightarrow[\hskip3em]{f_ + } \mathbb R^2 \\
 (x,y,z) & \xmapsto[\hskip3em]{}\Bigl( \mfrac{x}{1+z}, \mfrac{y}{1+z}\Bigr) \\
\Bigl ( \mfrac{2u}{1+u^2+v^2}, \mfrac{2v}{1+u^2+v^2}, \mfrac{1-u^2-v^2}{1+u^2+v^2}\Bigr) & \xmapsfrom[\hskip 3em]{}(u,v) \\
\shortintertext{and}
 S^2 - N & \xrightarrow[\hskip3em]{f_-} \mathbb R^2 \\
 (x,y,z) & \xmapsto[\hskip3em]{} \Bigl( \mfrac{x}{1-z}, \mfrac{y}{1-z} \Bigr) \\
 \Bigl( \mfrac{2u}{1+u^2+v^2}, \mfrac{2v}{1+u^2+v^2}, \mfrac{-1+u^2+v^2}{1+u^2+v^2}\Bigr) &\xmapsfrom[\hskip3em]{} (u,v)
\end{align*}

\end{document}

在此处输入图片描述

相关内容