4

I would like to use black and white triangle arrows with text above like these:

arrows

I guess that I have to combine \longrightarrow \xrightarrow{W} and \rightarrowtriangle but I don't know how to do that.

1

3 Answers 3

7

Messing around with the code found in mathtools, which defines several types of extensible arrows on, I got the following:

\documentclass{article}
\usepackage{mathtools}
\usepackage{stmaryrd}

\makeatletter
\providecommand*\xrightarrowtriangle[2][]{%
  \ext@arrow 0055{\arrowfill@\relbar\relbar\rightarrowtriangle}{#1}{#2}}
\makeatother

\begin{document}
    \[
        x \rightarrowtriangle y, \qquad x \xrightarrowtriangle{i} y
    \]

    Some unknown text les transitions synchrones par xyzqwert

    \[
        x \rightarrow y, \qquad x \xrightarrow{W} y
    \]
\end{document}

output

EDIT: To get filled arrows with the same shape as the empty ones, I used the \rhd (▷) and \RHD (▶) commands from wasysym:

\documentclass{article}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{booktabs}

\providecommand\rightarrowRHD{\relbar\joinrel\mathrel\RHD}
\providecommand\rightarrowrhd{\relbar\joinrel\mathrel\rhd}
\providecommand\longrightarrowRHD{\relbar\joinrel\relbar\joinrel\mathrel\RHD}
\providecommand\longrightarrowrhd{\relbar\joinrel\relbar\joinrel\mathrel\rhd}

\makeatletter
\providecommand*\xrightarrowRHD[2][]{\ext@arrow 0055{\arrowfill@\relbar\relbar\longrightarrowRHD}{#1}{#2}}
\providecommand*\xrightarrowrhd[2][]{\ext@arrow 0055{\arrowfill@\relbar\relbar\longrightarrowrhd}{#1}{#2}}
\makeatother

\begin{document}
    \begin{tabular}{lcccc}
        \toprule
        type               &   displaystyle                            &   textstyle                            &   scriptstyle                            \\
        \midrule
        filled short       & $\displaystyle a \rightarrowRHD        b$ & $\textstyle a \rightarrowRHD        b$ & $\scriptstyle a \rightarrowRHD        b$ \\
        empty  short       & $\displaystyle a \rightarrowrhd        b$ & $\textstyle a \rightarrowrhd        b$ & $\scriptstyle a \rightarrowrhd        b$ \\
        filled long        & $\displaystyle a \longrightarrowRHD    b$ & $\textstyle a \longrightarrowRHD    b$ & $\scriptstyle a \longrightarrowRHD    b$ \\
        empty  long        & $\displaystyle a \longrightarrowrhd    b$ & $\textstyle a \longrightarrowrhd    b$ & $\scriptstyle a \longrightarrowrhd    b$ \\
        filled superscript & $\displaystyle a \xrightarrowRHD{c}    b$ & $\textstyle a \xrightarrowRHD{c}    b$ & $\scriptstyle a \xrightarrowRHD{c}    b$ \\
        empty  superscript & $\displaystyle a \xrightarrowrhd{c}    b$ & $\textstyle a \xrightarrowrhd{c}    b$ & $\scriptstyle a \xrightarrowrhd{c}    b$ \\
        filled sup+super   & $\displaystyle a \xrightarrowRHD[d]{c} b$ & $\textstyle a \xrightarrowRHD[d]{c} b$ & $\scriptstyle a \xrightarrowRHD[d]{c} b$ \\
        empty  sub+super   & $\displaystyle a \xrightarrowrhd[d]{c} b$ & $\textstyle a \xrightarrowrhd[d]{c} b$ & $\scriptstyle a \xrightarrowrhd[d]{c} b$ \\
        \bottomrule
    \end{tabular}
\end{document}

new output

They have the same behavior as \longrightarrow and friends in that they don't scale as much (at all?) as the regular arrows.

2
  • 1
    I like the fact that you do not use TikZ here.
    – Karlo
    Mar 29, 2016 at 11:38
  • I find it necessary to re-scale it: \providecommand\Heytingarrow{\relbar\joinrel\mathrel{\vcenter{\hbox{\scalebox{0.75}{$\rhd$}}}}} Dec 25, 2020 at 12:47
3

Maybe this is an overkill solution with TikZ but it is handy to use.

The code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usepackage{xparse}
\usepackage{xspace}

\makeatletter
\NewDocumentCommand{\myarrow}{%
s
O{}
m
m
O{1cm}
}{%
\begin{tikzpicture}[baseline=-0.5ex] {
\node[inner sep=0](@1) at (0,0) {#3};
\node[inner sep=0](@2) at (#5,0) {#4};
\IfBooleanTF #1 {
\draw [arrows={-Triangle[open]},shorten >= 2pt,shorten <= 2pt](@1)--(@2) node[pos=.5,above,inner sep=1pt] {#2};}
{\draw [arrows={-Triangle},shorten >= 2pt,shorten <= 2pt](@1)--(@2) node[pos=.5,above,inner sep=1pt] {#2};}}
\end{tikzpicture}\xspace
}
\makeatother

\begin{document}
Some text \myarrow{$x$}{$y$}, and other text.

White triangle with the starred version: \myarrow*{$x$}{$y$} and other text.

Specify the superscript as optional argument \myarrow*[$i$]{$x$}{$y$}.

Finally you can also set the distance between the two nodes: \myarrow[$i$]{$x$}{$y$}[2cm]

It works also math mode: \[ \myarrow*[$i$]{$x$}{$y$}\]
\end{document}

TikZ draws the content, xparse serves to define the new command called \myarrow that takes two mandatory arguments (what's on the left and on the right of the arrow respectively). The first optional argument is to typeset something centered above the arrow, while the second optional argument (i.e. after the two set of curly braces) sets the length of the arrow. The starred version \myarrow*{}{} provides the white end arrow, which can be drawn invoking the arrows.meta library. Finally the package xspace is used to deal with the space after the command.

Output

1
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[frenchb]{babel}
\usepackage{mathabx}

\begin{document}
$x \raisebox{3pt}{\underrightarrow{\quad w \quad}} y$
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .