Construct a dotted-tilde relation in TeXJanuary 14, 2009 9:12 AM   Subscribe

TeXperts: how can I construct a \Dotsim relation that will look like a \sim with dots above and below it (the same way that \Doteq gives an equals sign with dots above and below)?
posted by Wolfdog to Computers & Internet (15 answers total)

I'm no expert, but I think \dot{\sim} will do that.
posted by Salvor Hardin at 9:27 AM on January 14, 2009

Google gave me this: \def\dotsim{{\buildrel .\over \sim}}
posted by teabag at 9:28 AM on January 14, 2009

(you can easily add a \under to the \buildrel I posted for the additional dot, I think)
posted by teabag at 9:29 AM on January 14, 2009

ooh sorry, just noticed you wanted dots above and below. Lemme think about that.
posted by Salvor Hardin at 9:31 AM on January 14, 2009

If you're using AMS-Latex, you can also sure the \overset and \underset commands. The syntax is \overset{top symbol}{main symbol}, and similarly for \underset. This keeps the baseline constant, but puts the over-set and under-set symbols in the size appropriate for superscripts and subscripts.
posted by Johnny Assay at 10:43 AM on January 14, 2009

Try this:

\newcommand{\dotsim}\ensuremath{{\hspace{.5em} \vbox{\baselineskip=2pt \lineskiplimit=0pt \kern0pt \hbox{.}\hbox{\kern-.25em \vspace{-.1em}$\sim$}\hbox{.}}\hspace{.4em} }}
posted by leahwrenn at 11:13 AM on January 14, 2009

and then call it as x \dotsim y or $x \dotsim y$
posted by leahwrenn at 11:13 AM on January 14, 2009

Oops. Take out the \ensuremath{ } above. Also, the spacing is hosed if you try to use this in non-mathmode text (i.e., x \dotsim y looks like crap, $x \dotsim y$ is mostly ok.) There's still something a little strange about the spacing after the symbol which I don't understand.

The problem I was encountering with \overset \underset or \stackrel is that I don't see how to deal with the nesting: to get two dots, it seems like you would have to do something like
\overset{.}{\overset{\sim}{\dot}}, but then the top dot is smaller than the bottom dot.

If someone can show me a better way of doing things than the bastardized TeX hacking I gave above, I'd be real interested.

posted by leahwrenn at 11:31 AM on January 14, 2009

or ask the good folks on typesetterforum.com typesetterforum.com
posted by lapsang at 11:39 AM on January 14, 2009

heavens to betsy, 1 preview wasn't enough for me.
posted by lapsang at 11:40 AM on January 14, 2009

Leanwrenn, this is what I had in mind:

\overset{\cdot}{\underset{\cdot}{<}}
posted by Johnny Assay at 11:50 AM on January 14, 2009

(which, I should add, works just fine for me — though I had to use cdots instead of periods to get the vertical spacing right.)
posted by Johnny Assay at 11:55 AM on January 14, 2009

The problem I was encountering with \overset \underset or \stackrel is that I don't see how to deal with the nesting: to get two dots, it seems like you would have to do something like
\overset{.}{\overset{\sim}{\dot}}, but then the top dot is smaller than the bottom dot.

One solution is the \textstyle command, which forces the use of an ordinary-text-sized font.

I'd also put a \mathrel{} around the whole thing — that causes TeX to treat it as a relation. That means it'll automatically get the right amount of space around it — no need to add \hspace manually — and it'll behave right around line breaks and such. So
   \mathrel{\overset{\textstyle .}{\overset{\sim}{.}}}
gives you a \sim with two normal-sized dots and correct spacing.
posted by nebulawindphone at 12:13 PM on January 14, 2009

On non-preview, I'd say Johnny Assay's approach, with \underset and \cdot, is even better — it gets the vertical positioning of the \sim right, which mine doesn't.
posted by nebulawindphone at 12:16 PM on January 14, 2009

I'd also put a \mathrel{} around the whole thing

I knew there was a command that did that, but darned if I could find it earlier.

posted by leahwrenn at 5:11 PM on January 14, 2009

« Older Why is the Mexican Nesquik cheaper?   |   Where have my rectangles gone? Newer »