Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In a previous question Gonzalo Medina and Peter Grill gave a solution to replace the \to arrow by an arrow generated by TikZ.

For some people using TikZ in commutative diagrams, it would be perhaps desirable to uniformize the tips of some common arrows (\to, \leftarrow, \mapsto,\rightsquigarrow,etc.)

One can extend Peter Grill's solution in the question above (Gonzalo Medina's solution provides an arrow that resizes, but since arrows other than \to are less commonly used in super- or subindices, here the simplest solution is used) to obtain a\leftarrow as in the code show bellow. The problem is with the \mapsto arrow, for I cannot produce it: its vertical part is too large, as shown in the picture bellow.

\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}

The result is: enter image description here

share|improve this question
    
The arrows should be declared by \mathrel, not \mathbin –  egreg Oct 22 '12 at 21:16
    
I just substituted \mathbin by \mathrel: same result. –  c.p. Oct 22 '12 at 21:23
3  
Well, \mathrel or \mathbin influence the spacing around the arrows, not the arrows themselves. By the way, if I had to express a preference, I'd point to the second row. –  egreg Oct 22 '12 at 21:24
1  
Though, I'm a loyal TikZ foot soldier, I think such a replacement is only justified if the arrows are unquestionably prettier than the usual ones since it will bring a large overhead (unless you protocol or use the basic layer drawing commands etc.) –  percusse Oct 22 '12 at 23:08
1  
To fix the height of the mapsto, you could draw the vertical line yourself: \newcommand{\MyMapsto}[1][]{\mathbin{\tikz \draw [-stealth, cap=round, #1] (0,0) (0,0.97ex) -- (0,0.035ex) (0,0.50ex) -- (1.0em,0.50ex);}}. Might still need some more tweaking of the vertical line though. I am not sure what you want to change regarding the \rightsquigarrow. –  Peter Grill Oct 23 '12 at 1:03
show 2 more comments

1 Answer

up vote 1 down vote accepted

Does this help? I put together a composite \mapsto, by adding a vertical rule to a stealth arrow (outside of tikz) EDIT: Now it works in \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}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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