2

I'm trying to define a custom command which is to be an arrow with a tilde (\sim) on top of it.

So far I have

\newcommand{\tosim}{\mathrel{%
  \tikz[baseline,label/.style={%
      postaction={%
        decorate,transform shape,
        decoration={markings,mark=at position .5 with \node {$\sim$};}
      }
  }]
    \draw[-stealth,label={[above]}] (0ex,0.56ex) -- (3ex,.56ex);}}

With this the node sits right on top of the middle of the arrow. I would like it to be above by a certain amount. I've tried above=2ex and yshift=2x in various places, but either the file doesn't compile, or there's no scalable shift. Where should I use above= and where yshift= (and which is better for this situation)?

3

Use raise=<amount> for decorations:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\newcommand{\tosim}{\mathrel{%
  \tikz[baseline,label/.style={%
      postaction={%
        decorate,transform shape,
        decoration={markings,raise=.2cm,mark=at position .5 with \node {$\sim$};}
      }
  }]
    \draw[-stealth,label={[above]}] (0ex,0.56ex) -- (3ex,.56ex);}}

\begin{document}
$\tosim$
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.