3

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).

murray
  • 7,944
  • 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[]}}}. –  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? –  Jul 30 '18 at 22:47
  • The connectin with tikz-cd is simply that I thought by looking at the code there for mapsto (and Mapsto), it would help me see how to design the version of the\mapsto symbol. But it did not. – murray Jul 31 '18 at 00:25
  • OK, thanks for clarifying this. And, according to what I see, your code already accomplishes what you seemingly want. Apart from the fact that you may want to use \mathrel instead of \mathbin, as clarified in your follow-up (?) question, what is it that you want to achieve. Is it that \scalerel makes the line too thin? (Notice that TikZ understands width, i.e. you could simply make the arrow as long as the reference arrow without changing the line width.) –  Jul 31 '18 at 02:50
  • @marmot: Please explain how to use TikZ's width for the line. Or did you mean line width? – murray Jul 31 '18 at 19:52
  • @murray No, I mean width. Try e.g. \pgfmathsetmacro{\X}{width("ABC")} \typeout{\X} \pgfmathsetmacro{\X}{height("ABC")} \typeout{\X}. Of course the calc package (not the calc library) also offers \widthof and \heightof. –  Jul 31 '18 at 19:55
  • @marmot: I'm confused! Are you talking about the overall width (i.e., thickness) of the lines (i.e., strokes) used to make the shaft of the arrow and the bar and the bar (if any)? I just do not understand how width is to be used where with the \tikz[baseline]\draw[arrows... command. – murray Jul 31 '18 at 20:21
  • Most likely it is irrelevant but I simply do not understand the question. So I was guessing that you may not like the width of the line of the arrow, and was wondering if you might want to use a different means to rescale your arrow. –  Jul 31 '18 at 20:24
  • @marmot: I'm trying to change everything about these arrows: increase their overall lengths a bit; increase the thickness of their shafts; make more prominent right-end arrow tips; and for \mapsto, a slightly longer and ever-so-thicker bar on the left end. The overall rescaling I'm attempting with \scalerel* is to properly scale when the arrows are used in \scriptstyle. – murray Jul 31 '18 at 20:46
  • Yes, that's the part I understand. But you are doing that already, don't you? So what are the issues an answer should address? –  Jul 31 '18 at 20:49

2 Answers2

4

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}
Werner
  • 603,163
Sebastiano
  • 54,118
  • 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
  • 2
    Just upvoted to compensate the downvote, also have no idea why someone would downvote your answer. –  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