4

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?

2 Answers2

3

enter image description here

\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}
Tarass
  • 16,912
  • 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
  • 1
    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
  • @Tarass and J Marcos With so much sincerity I use very little scarerel package and I'm not an expert like many users here. The Tarass's answer is impeccably. I upvote now you. – Sebastiano Mar 30 '18 at 20:34
3

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}

enter image description here

  • Hi, also for you +1. But the bounty when it will gives :-)? – Sebastiano Apr 02 '18 at 19:52
  • @Sebastiano If only I understood tikz, I could make the double bars farther apart... – Steven B. Segletes Apr 02 '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 02 '18 at 21:07
  • @JMarcos Yes, I don't know tikz and so I (so far) have not figured out how to make the double arrows more separated in their lines. – Steven B. Segletes Apr 02 '18 at 23:30
  • @StevenB.Segletes I think that you can do by writing something like double distance=1.4pt, together with baseline and line width. But I still have the trouble of smoothly scaling the symbols! – J Marcos Apr 02 '18 at 23:38
  • 1
    @JMarcos Thanks. I stumbled through it, and it seems to be improved. – Steven B. Segletes Apr 03 '18 at 00:01
  • @StevenB.Segletes Thanks! Your package scalerel is wonderfully useful. I wish I could see this code compile so as to at least look similar to your pic. Do you think there is any explanation for the fact that eight out of twelve symbols are actually getting larger under scriptstyle, when I compile in any of my computers, than under normalsize? – J Marcos Apr 03 '18 at 01:06
  • @JMarcos It would appear that I tailored the result to \LARGE, which you were in. That comes from specifying things in pt rather than em and ex. I will see if I can revise. – Steven B. Segletes Apr 03 '18 at 01:29
  • @JMarcos Please try again. Also, make sure you are using scalerel 2016/12/29 v1.8 – Steven B. Segletes Apr 03 '18 at 01:39
  • 1
    @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 06 '18 at 18:16