2

I want to use TikZ to create new versions of the standard LaTeX math symbol \to and macro \mapsto to use for math mapping notation and, in the case of \to, to use for math convergence notation.

And I want the arrow tip style and shaft thickness to harmonize with arrows used in tikzcd diagrams.

For the Lucida Bright math font I'm using, I find the arrow tips too small on both — because the arrow tip on \rightarrow is so small — and the bar on \mapsto is also too small.

Questions:

  1. How do I make the terminal Stealth arrow tip larger for \newmapsto, so that it is the same size as the terminal Stealth arrow tip for \newto?
  2. Does the result of the code shown below create a pleasing and harmonious design of these symbols? Any suggestions for improving either the result or the code?em

Caution: Although the code shows the lucidabr package, I'm actually instead using the proprietary lucimatx package, with its lucidasmallscale option that enables "nonlinear" scaling, with 10pt font sizes scaled by 90%, with < 10pt sizes scaled upwards (up to 0.95% at < 5pt) and with > 10pt sizes scaled downwards (down to 0.85 pt at >= 22.5pt). (This is to compensate for the relatively large x-height of the Lucida fonts.) The image from the pdf output that's shown below uses \lucimatx with that scaling.

\documentclass[10pt]{article}
\usepackage[left=2in,right=0.75in]{geometry}

%% FOLLOWING LINE USED TO PRODUCE IMAGE SHOWN FOR THE OUTPUT
%\usepackage[lucidasmallscale=true]{lucimatx}
\usepackage{lucidabr}
\linespread{1.04}

\usepackage{amsmath}
\newcommand{\N}{\mathbb{N}}
\newcommand{\from}{\protect\colon}

\let\oldto\to
\let\oldmapsto\mapsto
\newcommand*{\oldtendsto}{\mathrel{\rightarrow}}

\usepackage{scalerel}
\usepackage{tikz-cd}
\usetikzlibrary{arrows.meta}

\tikzcdset{every arrow/.append style = -{Stealth[scale=1]}}
\tikzcdset{arrows={line width=0.4pt}}

\let\oldrightarrow\rightarrow
\newcommand{\newrightarrow}{\mathrel{\tikz[baseline]\draw[arrows=-{Stealth[scale=1]},yshift=0.75ex] (0,0) -- (1.4em,0);}}
\newcommand{\newto}{\mathrel{\scalerel*{\newrightarrow}{\oldrightarrow}}}
\newcommand{\newbarredrightarrow}{\mathrel{\tikz[baseline]\draw[arrows={Bar[line width=1.125pt,scale=1.667]}-{Stealth[scale=1.44]},yshift=0.75ex] (0,0) -- (1.95em,0);}}
\newcommand{\newmapsto}{\mathrel{\scalerel*{\newbarredrightarrow}{\oldrightarrow}}}

% command \test based upon the one used by Ruixi Zhang in answer at
% https://tex.stackexchange.com/questions/443614/what-length-arrow-for-converges-to/443623#443623
\newcommand*{\test}[3]{% params; tendsto, to, mapsto
  \makebox[7em][r]{\texttt{\textbackslash#1}, \texttt{\textbackslash#2} and \texttt{\textbackslash#3}}:\\[6pt]
  Let $(x_n)_{n \in \N} \csname#1\endcsname x$ in~$X$ where $f \from X \csname#2\endcsname Y$ and $x \csname#3\endcsname y$;
  that is, \[\lim_{n \csname#1\endcsname \infty} x_n = x \quad \text{where $\quad f \from X \csname#2\endcsname Y$ and $x \csname#3\endcsname y$}.\]}

\begin{document}

\noindent%
\test{oldtendsto}{oldto}{oldmapsto}% original
\test{newto}{newto}{newmapsto}
\[
\begin{tikzcd}
 & Y \arrow{dr}{g} & \\
X \arrow{ur}{f} \arrow{rr}{h} && Z
\end{tikzcd}
\]
\[
\begin{tikzcd}
X \arrow{r}{f} \arrow[swap]{d}{h} & Y \arrow{d}{k}
\\
Z \arrow{r}{g} & W
\end{tikzcd}
\]
\end{document}

new \to, \mapsto

The original query

I had been looking for the actual definition of the tikz-cd the \mapsto arrow command (so that I can modify the height and thickness of the bar on its left end).

Thanks to comments from @Phelype Oleinik and @marmot, I did find the definition in texmf-dist/tex/generic/tikz-cd/tikzlibrarycd.code.tex. Unfortunately, with my limited knowledge of TikZ I don't find it informative (yet).

  • 3
    The code for tikz-cd is located at texmf-dist/tex/generic/tikz-cd/tikzlibrarycd.code.tex – Phelype Oleinik Jul 30 '18 at 21:50
  • Alas, there's no \Mapsto defined in that file. – murray Jul 30 '18 at 22:18
  • 2
    It is, the definition is Mapsto/.code={\tikzcdset{double line}\pgfsetarrows{tikzcd implies bar-tikzcd implies}},. The perhaps simplest way to go is to define a new style like \tikzset{MyMapsto/.style={{Tee Barb[0pt]}-{Stealth[]}}}. – user121799 Jul 30 '18 at 22:19
  • Yes, I did find Mapsto there; I was mistakenly searching for \Mapsto in that file. But the code is not very informative to me, at least not yet. – murray Jul 30 '18 at 22:24
  • Thanks for the update! Now I am confused what the role of tikz-cd is in this question (apart from loading tikz). According to how I read your question, you are not too happy with how Mapsto looks in this library, and you know how to patch arrows with the arrows.meta library anyway. So where does tikz-cd come in? – user121799 Jul 30 '18 at 22:47
3

For the length of the arrows you can use the parameters row sep and column sep which define the distance between two nodes/cells in your diagram. After here http://mirrors.ctan.org/graphics/pgf/contrib/tikz-cd/tikz-cd-doc.pdf you can see at paragraph 1.3 Changing arrow tips, where there is a list that it shows all available arrow types.

At the page 8 you can modify the thickness of the barb:

% in preamble
\tikzcdset{
  arrow style=tikz,
  diagrams={>={Straight Barb[scale=0.8]}}
}

% in document body
\begin{tikzcd}
  A \arrow[r, tail] \arrow[rd] & B \arrow[d, two heads] \\
  & D
\end{tikzcd}
  • My error in problem statement (corrected now). I'm actually looking to modify the code for \Mapsto so that I can modify it for use in place of the standard LaTeX math symbol \mapsto. So I want an arrow with a zero width Tee Barb on its left end and an arrow head (as it happens, a Stealth type tip) on its right end. – murray Jul 30 '18 at 22:14
  • Can you add an image thus I undestand your request? – Sebastiano Jul 30 '18 at 22:17
  • 1
    What is the reason for the 4th downvote in this day? – Sebastiano Jul 30 '18 at 22:31
  • 1
    Just upvoted to compensate the downvote, also have no idea why someone would downvote your answer. – user121799 Jul 30 '18 at 22:37
3

Just spelling out the comment and correcting a mistake: the argument of Tee Barb needs to be corrected. I actually do not know the reason why the tikz-cd library works with .code instead of .style, so I hope I am not doing something terribly stupid here.

\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{arrows.meta}
\tikzset{MyMapsto/.style={{Tee Barb[width=0pt]}-{Stealth[]}}}
\begin{document}
\[
\begin{tikzcd}[column sep=huge]
X   \arrow[r,MyMapsto]& Y\\
\end{tikzcd}
\]
\end{document}

enter image description here

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.