3

I've invented a custom symbol I wish to use in my LaTeX writings. It is a one, 1, overlapped with a tilde. This image shows what I want:

a digit '1' with overlapping wiggle

The actual symbol for the tilde is \sim. I have seen \rlap used to make characters overlap, as in

$\rlap{X}O$

which creates Capital O and capital X overlapping; ugly vector space product

but when I try

$\rlap{\sim}{1}$

I get an error complaining about a missing $. Duh. What is a valid way to get this one+tilde symbol?

I prefer to avoid any uncommon packages or anything quirky, so that the proper LaTeX way of doing this can be used for online markup, such as blogs, wikis, and Q&A forums, which may be using any version of LaTeX and may or may not have any particular desired package.

  • Note: the tag "overlays" is incorrect. I wanted to put "overlap" but don't have the right to do so yet. I don't know of any other relevant tags. – DarenW Oct 22 '16 at 23:18
  • 1
    Welcome to the site :) I've suggested a couple of tags that should work. Please be aware that our limited tag set is really by design, I think some kind of overlap tag would probably be much too narrow in my opinion. Others may disagree, but personally I think it's best to keep tags as broad indexes and I can't think of many questions that warrant an overlap tag (perhaps why we don't have one :P) – Au101 Oct 22 '16 at 23:27
  • 'kerning' perhaps? – DarenW Oct 22 '16 at 23:36
  • I don't know that it's 'kerning' as such, you could maybe tag it with positioning, but honestly, I wouldn't worry about over-tagging – Au101 Oct 22 '16 at 23:41
  • 1
    'wild and crazy kerning' then? Yeah, I'll leave the tagging to others... – DarenW Oct 23 '16 at 0:40
3

The following example overlays the two symbols:

  • The current math style is respected by implementing it via \mathpalette.

  • The 1 is horizontally centered.

  • The tilde is vertically centered.

  • The implementation does not need any additional packages.

Example file:

\documentclass{article}

\makeatletter
\newcommand*{\tildeone}{%
  \mathord{% or whatever
    \mathpalette\@tildeone{}%
  }%
}
\newcommand*{\@tildeone}[2]{%
  % #1: math style
  % #2: unused
  \sbox0{$#1\sim\m@th$}% tilde
  \sbox2{$#11$}% for height of "1"
  \sbox4{$#1\vcenter{}$}% math axis, presumably the middle of "\sim"
  \rlap{% place "1"
    \hbox to\wd0{\hfil$#11\m@th$\hfil}%
  }%
  % place the tilde raised to the correct height
  \raise\dimexpr.5\ht2 - \ht4\relax\copy0 %
}
\makeatother

\begin{document}
\[ 1 + {\sim} = \tildeone \]
\end{document}

Result

2

Here are three solutions, based on \mathclap from \mathtools and \stackinset from stackengine:

\documentclass[12pt]{article}
\usepackage{mathtools}
\usepackage{stackengine}

 \begin{document}

 \[ \mathclap {1}\mathclap{\sim}\qquad \mathclap {1}\mathclap{\raisebox{0.1ex}{$ \sim $}}\qquad \stackinset{c}{0pt}{c}{-0.2ex}{$ \sim $}{$ 1 $} \]%

\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.