12

I want to write something like this: enter image description here

But doing \leftarrow{\$} does not produce the desired result. Any ideas?

4
  • 1
    $ \leftarrow\$ $ ? Commented Mar 6, 2018 at 13:36
  • 1
    Just out of idle curiosity: What might this symbol mean? Is it a relational operator of some kind?
    – Mico
    Commented Mar 6, 2018 at 15:56
  • 1
    @Mico It's mainly used in cryptography, it means that the elements are sampled uniformly from a set. For example $ x ~{\leftarrow}\vcenter{\hbox{\tiny\$}}~ \mathbb{Z}/n\mathbb{Z}$, means that $x$ is a random element sampled from $\mathbb{Z}/n\mathbb{Z}$.
    – pixel
    Commented Mar 6, 2018 at 16:00
  • 1
    @pixel - In that case, it's probably a good idea to give this symbol mathrel status. I'll post an addendum to my answer.
    – Mico
    Commented Mar 6, 2018 at 16:30

4 Answers 4

14

Something like this?

enter image description here

\documentclass{article}
\begin{document}
$ {\leftarrow}\vcenter{\hbox{\scriptsize\rmfamily\upshape\$}} $ or 
$ {\leftarrow}\vcenter{\hbox{\tiny\rmfamily\upshape\$}} $ 
\end{document} 

Addendum, to incorporate some additional information provided by the OP in comment. It looks like this symbol should be assigned the type "mathrel" ("relational operator"). E.g., one could define a macro called (say) \getsdollar as follows:

\newcommand\getsdollar{\mathrel{{\leftarrow}\vcenter{\hbox{\tiny\rmfamily\upshape\$}}}}

and then write x\getsdollar \mathbb{Z}/n\mathbb{Z} in the body of the document (in math mode, of course).

2
  • @egreg No, I just needed it to use inside a table.
    – pixel
    Commented Mar 6, 2018 at 18:26
  • @egreg - Thanks for pointing out this issue. I've added \rmfamily\upshape directives to address it. :-)
    – Mico
    Commented Mar 6, 2018 at 18:27
14

A version that scales in subscripts and superscripts. Use a different factor than 0.7 if you want a smaller dollar sign.

\RequirePackage{fix-cm}% arbitrary scaling
\documentclass{article}
\usepackage{amsmath}

\newcommand\leftarrowS{\leftarrow\joinrel\smalldollar}
\newcommand\rightarrowS{\smalldollar\joinrel\rightarrow}

\makeatletter
\newcommand{\smalldollar}{\mathrel{\mathpalette\small@dollar\relax}}
\newcommand{\small@dollar}[2]{%
  \vcenter{\hbox{%
    $#1\textnormal{\fontsize{0.7\dimexpr\f@size pt}{0}\selectfont\$}$%
  }}%
}
\makeatother

\begin{document}

$A\leftarrowS B\rightarrowS C$

$\scriptstyle\leftarrowS$

\end{document}

enter image description here

5

enter image description here

\documentclass[10pt,a4paper]{article}
\usepackage{tikz}

\newcommand{\ArrowS}[1][1]{%
    \tikz[baseline=(a.base)]
        \draw[stealth-,shorten >=4pt] (0,0)--(#1,0)
            node (a) {\$} ;
}

\begin{document}
Foo \ArrowS Foooooo \ArrowS[3]
\end{document}
1

The easiest way would be with the cryptocode package.

To get the sampling operator you'll need to load it with the "operators" option.

\documentclass{standalone}

\usepackage[operators,sets]{cryptocode}

\begin{document}
$r \sample \ZZ_p^+$
\end{document}

output

0

You must log in to answer this question.

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