![TikZ 中常用的箭头](https://linux22.com/image/257385/TikZ%20%E4%B8%AD%E5%B8%B8%E7%94%A8%E7%9A%84%E7%AE%AD%E5%A4%B4.png)
在一个上一个问题Gonzalo Medina 和 Peter Grill 提出了一种解决方案,\to
用 生成的箭头代替 箭头TikZ
。
对于一些在交换图中使用 TikZ的人来说,也许希望统一一些常见箭头的尖端(,,,,\to
等等)。\leftarrow
\mapsto
\rightsquigarrow
可以扩展 Peter Grill 在上述问题中的解决方案(Gonzalo Medina 的解决方案提供了一个可调整大小的箭头,但由于除 之外的箭头\to
在超级或子索引中不太常用,因此这里使用最简单的解决方案)以获得\leftarrow
如下代码所示。问题出在箭头上\mapsto
,因为我无法生成它:它的垂直部分太大,如下图所示。
\documentclass{article}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
% Tikz part
%********************************************************************
\usepackage{tikz}
\usetikzlibrary{mindmap,trees}
\usetikzlibrary{arrows,chains,matrix,positioning,scopes}
\makeatletter
\tikzset{join/.code=\tikzset{after node path={%
\ifx\tikzchainprevious\pgfutil@empty\else(\tikzchainprevious)%
edge[every join]#1(\tikzchaincurrent)\fi}}}
\makeatother
%
\tikzset{>=stealth',every on chain/.append style={join},
every join/.style={->}}
\tikzstyle{labeled}=[execute at begin node=$\scriptstyle,
execute at end node=$]
\usepackage{tikz-cd}
\usetikzlibrary{arrows}
\tikzset{
commutative diagrams/.cd,
arrow style=math font,
diagrams={>=stealth}}
%*******************************************************
%redefining the arrows
%*******************************************************
\newcommand{\MyOt}[1][]{\mathbin{\tikz \draw [#1, stealth-] (0,0) (0,0.5ex) -- (1.0em,0.5ex);}}
\newcommand{\MyTo}[1][]{\mathbin{\tikz \draw [-stealth, #1] (0,0) (0,0.5ex) -- (1.0em,0.5ex);}}
\newcommand{\MyMapsto}[1][]{\mathbin{\tikz \draw [|-stealth, #1] (0,0) (0,0.5ex) -- (1.0em,0.5ex);}}
\let\OldTo\to
\let\OldOt\leftarrow
\let\OldMapsto\mapsto
\renewcommand{\to}{\MyTo}%
\renewcommand{\leftarrow}{\MyOt}
\renewcommand{\mapsto}{\MyMapsto}
\newcommand{\where}{\quad\mbox{where}\quad}
%**************************************************
\begin{document}
\begin{align*}
f: A\to B & \quad \rightsquigarrow \quad f^*:A^*\leftarrow B^*\where f^*:\phi \mapsto \phi\circ f\qquad&\mbox{(with TikZ)} \\
f: A\OldTo B &\quad \rightsquigarrow \quad f^*:A^*\OldOt B^* \!\!\where f^*:\phi \OldMapsto \phi\circ f\qquad &\mbox{(ordinary)}\\
\end{align*}
\end{document}
结果是:
答案1
\mapsto
这有帮助吗?我通过将垂直线添加到隐形箭头(tikz 之外)来组合一个复合材料。编辑:现在它可以在\scriptstyle
\documentclass{article}
% See http://tex.stackexchange.com/questions/14386/importing-a-
% single-symbol-from-a-different-font
% Setup the matha font (from mathabx.sty)
\DeclareFontFamily{U}{matha}{\hyphenchar\font45}
\DeclareFontShape{U}{matha}{m}{n}{
<5> <6> <7> <8> <9> <10> gen * matha
<10.95> matha10 <12> <14.4> <17.28> <20.74> <24.88> matha12
}{}
\DeclareSymbolFont{matha}{U}{matha}{m}{n}
% Define a subset character from that font (from mathabx.dcl)
% to completely replace the \subset character, you can replace
% \varsubset with \subset
\DeclareMathSymbol{\varleftarrow}{3}{matha}{"D0}
\DeclareMathSymbol{\varrightarrow}{3}{matha}{"D1}
\usepackage{scalerel}
\def\Newmapsto{%
\mbox{$\displaystyle\rule{.3ex}{0ex}\rule[.2ex]{.075ex}{.8ex}\rule{-.8ex}{0ex}%
\varrightarrow$}}%
\def\newmapsto{%
\scalerel*{\Newmapsto}{\scaleobj{1.2}{\mapsto}}%
}
\begin{document}
\[
A \mapsto B \qquad A \newmapsto B \scriptstyle \qquad
A \mapsto B \qquad A \newmapsto B
\]
\end{document}
感谢 varsop 提供的非常有效且简单的替代方法\joinrel
:
\documentclass{article}
% See http://tex.stackexchange.com/questions/14386/importing-a-
% single-symbol-from-a-different-font
% Setup the matha font (from mathabx.sty)
\DeclareFontFamily{U}{matha}{\hyphenchar\font45}
\DeclareFontShape{U}{matha}{m}{n}{
<5> <6> <7> <8> <9> <10> gen * matha
<10.95> matha10 <12> <14.4> <17.28> <20.74> <24.88> matha12
}{}
\DeclareSymbolFont{matha}{U}{matha}{m}{n}
\DeclareMathSymbol{\varleftarrow}{3}{matha}{"D0}
\DeclareMathSymbol{\varrightarrow}{3}{matha}{"D1}
\DeclareMathSymbol{\mapstochar} {3}{matha}{"DE}
\def\newmapsto{\mapstochar\joinrel\kern1.7pt\varrightarrow}
\begin{document}
\[
A \mapsto B \qquad A \newmapsto B \scriptstyle \qquad
A \mapsto B \qquad A \newmapsto B
\]
\[
\scriptscriptstyle A \mapsto B \qquad A \newmapsto B
\]
\end{document}