# How to produce a scalable version of a new (arrow) symbol?

NEW VERSION of the question:

Let me try to be very precise about what I'm looking for, incorporating here what I have written at a comment to the earlier version of my question. As in the illustration to be found here, I want to produce a number of arrows

->, <-, <->, =>, <=, <=>

all looking exactly like, resp., LaTeX's \rightarrow, \leftarrow, \leftrightarrow, \Rightarrow, \Leftarrow, \Leftrightarrow, and also produce, in a standard way, the arrows

>-, -<, >-<, >=, =<, >=<

which are not native to LaTeX but should look like the arrows above, except that they invert the directions of the arrow heads.

It is extremely important that these new arrows should scale in a natural way, just like the native LaTeX arrows, when used in subscripts or superscripts.

(Notice that smooth scaling is fundamental, but only part of my problem.)

OLD VERSION of the question:

In the answer to this question I learned how to produce some new arrow symbols that I was in need of. I would now like to make these symbols scalable, so that they could be used in subscripts or superscripts without ad hoc adaptations. Can anyone help?

• You could use the scalerel package of Steven B. Segletes: ctan.mirror.garr.it/mirrors/CTAN/macros/latex/contrib/scalerel/… – Sebastiano Mar 29 '18 at 19:00
• I think this is a duplicate of this questoin. (Just replace the \includegraphics with your arrow.) – schtandard Mar 29 '18 at 22:21
• Possible duplicate of How to use a custom, scalable, symbol in LaTeX – schtandard Mar 29 '18 at 22:23
• @Sebastiano Many thanks. The examples I find in the documentation of the package and in the related question pointed out by the other users employ \def rather than \NewDocumentCommand. I know it should be "obvious" how to adapt them for the use of scalerel, but so far I have not managed to make it work for the command \imparrow, in my code... Could you be so kind as to give a hint? – J Marcos Mar 30 '18 at 1:50

Based on the accepted answer at the cited question...

Also using scalerel, but the result seems different than the other answer.

EDITED to express results in ex rather than pt, so that the answer was not specifically geared to the OP's specification of \LARGE.

EDITED to use \mathrel.

EDITED to make double arrows same width as single arrows.

\documentclass{article}

\usepackage{amsmath}
\usepackage{tikz,xparse,xstring}
\usetikzlibrary{calc}
\usepackage{scalerel}
\newcommand\scaled[1]{\scaleto{#1}{\dimexpr1.8\LMex+0.43ex}}

\newcommand{\MyArc}[1][1]{%
\begin{scope}[#1]
\fill[white]
(0,0) arc (270:180:3.5*\ArW) -- (0,3.5*\ArW) -- cycle ;
\draw   (0,0) arc (270:180:3.5*\ArW) ;
\fill[white]
(0,0) arc (90:180:3.5*\ArW) -- (0,-3.5*\ArW) -- cycle ;
\draw (0,0) arc (90:180:3.5*\ArW) ;
\end{scope}
}

\newcommand{\MyArcRv}[1][1]{%
\begin{scope}[#1]
\fill[white] (0,3.5*\ArW) arc (0:-90:3.5*\ArW)
arc (90:0:3.5*\ArW) -- cycle ;
\draw (0,3.5*\ArW) arc (0:-90:3.5*\ArW)
arc (90:0:3.5*\ArW) ;
\end{scope}
}

\tikzset{%
Arrow width/.store in=\ArW,
Arrow width=.18ex,
pics/.cd,
arc east/.style={code = {\MyArc[xshift=.5*\pgflinewidth]}},
arc west/.style={code = {\MyArc[rotate=180,xshift=.5*\pgflinewidth]}},
arc rv east/.style={code = {\MyArcRv[xshift=.5*\pgflinewidth]}},
arc rv west/.style={code = {\MyArcRv[rotate=180,xshift=.5*\pgflinewidth]}}
}

\NewDocumentCommand{\imparrow}{
D<>{} % above
O{1em} %length
m % pattern
D<>{} % below
}{\mathrel{\scaled{%
\def\Law{}
\def\Raw{}
\def\Style{}
\def\Dlen{#2}
\IfBeginWith{#3}{<}{\def\Law{pic{arc west}}}{}
\IfBeginWith{#3}{>}{\def\Law{pic{arc rv west}}}{}
\IfEndWith{#3}{>}{\def\Raw{pic{arc east}}}{}
\IfEndWith{#3}{<}{\def\Raw{pic{arc rv east}}}{}
\IfSubStr[1]{#3}{=}{\def\Style{double}\def\Dlen{.85em}}{}
\tikz [baseline=-.5ex,line width=.11ex, double distance=.33ex]
\draw[\Style] (0,0) \Law
-- node[below=-2pt] {#1} node[above=-2pt] {#4}
(\Dlen,0) \Raw;}}}
\begin{document}
%\LARGE
\newcommand\stencil[1]{%
$\alpha #1 \beta / \scriptstyle \alpha #1 \beta / \scriptscriptstyle \alpha #1 \beta$\par
}
\stencil{\to}
\stencil{\Leftrightarrow}
\smallskip
versus
\smallskip

\renewcommand\stencil[1]{%
$\alpha \imparrow{#1} \beta / \scriptstyle \alpha \imparrow{#1} \beta / \scriptscriptstyle \alpha \imparrow{#1} \beta$\par
}
\stencil{->}
\stencil{<->}
\stencil{<-}
\stencil{>-}
\stencil{-<}
\stencil{>-<}
\stencil{=>}
\stencil{<=>}
\stencil{<=}
\stencil{>=}
\stencil{=<}
\stencil{>=<}
\end{document}


• Hi, also for you +1. But the bounty when it will gives :-)? – Sebastiano Apr 2 '18 at 19:52
• @Sebastiano If only I understood tikz, I could make the double bars farther apart... – Steven B. Segletes Apr 2 '18 at 19:54
• This looks pretty good, thanks! I have not confirmed the bounty, however, for the code does not precisely fulfill the specification... – J Marcos Apr 2 '18 at 21:07
• @JMarcos Thanks. I stumbled through it, and it seems to be improved. – Steven B. Segletes Apr 3 '18 at 0:01
• @StevenB.Segletes Thanks again. It was indeed essential to update the 2015 version of scalerel that I had installed in my machine. – J Marcos Apr 6 '18 at 18:16

\documentclass{article}

\usepackage{amsmath}
\usepackage{tikz,xparse,xstring,scalerel}
\usetikzlibrary{calc}

\newcommand{\MyArc}[1][1]{%
\begin{scope}[#1]
\fill[white]
(0,0) arc (270:180:4*\ArW) -- (0,4*\ArW) -- cycle ;
\draw   (0,0) arc (270:180:4*\ArW) ;
\fill[white]
(0,0) arc (90:180:4*\ArW) -- (0,-4*\ArW) -- cycle ;
\draw (0,0) arc (90:180:4*\ArW) ;
\end{scope}
}

\newcommand{\MyArcRv}[1][1]{%
\begin{scope}[#1]
\fill[white] (0,4*\ArW) arc (0:-90:4*\ArW)
arc (90:0:4*\ArW) -- cycle ;
\draw (0,4*\ArW) arc (0:-90:4*\ArW)
arc (90:0:4*\ArW) ;
\end{scope}
}

\tikzset{%
Arrow width/.store in=\ArW,
Arrow width=.7pt,
pics/.cd,
arc east/.style={code = {\MyArc[xshift=.5*\pgflinewidth]}},
arc west/.style={code = {\MyArc[rotate=180,xshift=.5*\pgflinewidth]}},
arc rv east/.style={code = {\MyArcRv[xshift=.5*\pgflinewidth]}},
arc rv west/.style={code = {\MyArcRv[rotate=180,xshift=.5*\pgflinewidth]}}
}

\NewDocumentCommand{\imparrow}{
D<>{} % above
O{1.4em} %length
m % pattern
D<>{} % below
}{%
\def\Law{}
\def\Raw{}
\def\Style{}
\IfBeginWith{#3}{<}{\def\Law{pic{arc west}}}{}
\IfBeginWith{#3}{>}{\def\Law{pic{arc rv west}}}{}
\IfEndWith{#3}{>}{\def\Raw{pic{arc east}}}{}
\IfEndWith{#3}{<}{\def\Raw{pic{arc rv east}}}{}
\IfSubStr[1]{#3}{=}{\def\Style{double}}{}
\scalerel*{
\tikz [baseline=-.5ex,line width=.4pt]
\draw[\Style] (-3pt,0) (0,0) \Law
-- node[below=-2pt] {#1} node[above=-2pt] {#4}
(#2,0) \Raw
++(3pt,0);}{$\beta$}
}
\begin{document}

$\alpha\to\beta$ / $\alpha\Leftrightarrow\beta$\bigskip

$\alpha \imparrow{->} \beta$

$\alpha \imparrow{<->} \beta$

$\alpha \imparrow{<-} \beta$

\Large

$\alpha \imparrow{>-} \beta$

$\alpha \imparrow{-<} \beta$

$\alpha \imparrow{>-<} \beta$

$\alpha \imparrow{=>} \beta$

\footnotesize

$\alpha \imparrow{<=>} \beta$

$\alpha \imparrow{<=} \beta$

$\alpha \imparrow{>=} \beta$

$\alpha \imparrow{=<} \beta$

$\alpha \imparrow{>=<} \beta$

\end{document}

• Thanks for showing me where to put the \scalerel in the code you sent me earlier! By the way, it seems you should have used {\beta} rather than {$\beta$} as the second argument of \scalerel? – J Marcos Mar 30 '18 at 15:45
• Both works, but if are sure to use it always in math mode, you can use \beta, if not you also can use \ensuremath as third way. – Tarass Mar 30 '18 at 16:05
• By the way, are these symbols supposed to fully scale automatically when used in a subscript or superscript? The one thing that I find a bit undesirable about the new symbols, which are otherwise great, is that the arcs of the arrows seem to become disproportional to the whole thing when the arrow is scaled... That is a different behavior from the one I observe in \to when used in a subscript. – J Marcos Mar 30 '18 at 17:07
• Please mix both methods (your and mine) upon your taste. I can't figure what proportions are suitable for you. – Tarass Mar 30 '18 at 17:10
• Thanks, I am trying... My initial idea was that (your) \imparrow{->} should like exactly like LaTeX's standard \to, that \imparrow{=>} should like exactly like LaTeX's \Rightarrow, and similarly for \imparrow{<->} versus \leftrightarrow, and for \imparrow{<=>} versus \Leftrightarrow. The other symbols would all be produced then by simply moving the arcs to the right positions. Surely I would be happy if the new symbols would scale smoothly in an analogous way to their LaTeX standard counterparts. – J Marcos Mar 30 '18 at 17:12