Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd need a special symbol used in statistics.

What I need is a tilde with something written upon it.

I can get the tilde by using \sim, but I need to add a superscript over it (H_0). If I use \sim^{H_0}, I get a tilde with H_0 over it and on the right, not simply upon it.

share|improve this question
1  
You might be interested in this question. –  Thorsten Donig Feb 3 '12 at 22:07

1 Answer 1

up vote 9 down vote accepted

The following minimal example provides two possibilities: \distas{<stuff>} and \distras{<stuff>}. The former uses amsmath's \overset{<top>}{<bottom>} which sets <top> over top of <bottom>. The latter uses a resized version of <bottom> in case <top> is wider than <bottom>. In fact, it stretches <bottom> to 6pt wider than <top> (3pt on either side). In both instances, <bottom> is fixed to \sim and the symbol is spaced as a binary operator via \mathbin.

enter image description here

\documentclass{article}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\makeatletter
\newcommand{\distas}[1]{\mathbin{\overset{#1}{\kern\z@\sim}}}%
\newsavebox{\mybox}\newsavebox{\mysim}
\newcommand{\distras}[1]{%
  \savebox{\mybox}{\hbox{\kern3pt$\scriptstyle#1$\kern3pt}}%
  \savebox{\mysim}{\hbox{$\sim$}}%
  \mathbin{\overset{#1}{\kern\z@\resizebox{\wd\mybox}{\ht\mysim}{$\sim$}}}%
}
\makeatother
\begin{document}

$X\distas{H_0}Y \quad X\distras{H_0}Y$
\end{document}
share|improve this answer
2  
Thank you both Werner and Thorsten Donig! Your answers were very useful. I've solved by using: \overset{H_0}{\sim} –  Luigi Feb 3 '12 at 22:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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