9

My aim is to construct a relational symbol which is graphically equivalent the standard infinity sign (coded by\infty) crossed exactly in the middle of it. Yet I am not able to overcome something. To be more precise:

sample sentence

I would like to have slash sign moved exactly to the middle position of the infinity sign. The above was defined in the following way:

\documentclass{standalone}
\begin{document}
\newlength{\length}
\settowidth{\length}{$\infty$}
\newcommand\ninfty{\mathrel{\infty\hspace{-0.5\length/}}} 

$\ninfty$ is not what I am aiming at.

\end{document}

So as you can see my idea was to define the length equal to the length of the infinity sign and then place slash sigh it halfway through it. As it can be seen above it was rather please quarter-way (backwards).

Could you please explain what I did wrong and how can I exactly determine the middle point (in terms of width) of a given mathematical glyph? Or a glyph in general?

  • 2
    actually you did locate the middle but then you aligned the left edge of / to the middle of \infty you just want to backspace by half the difference between the width of \infty and the witdh of / – David Carlisle Feb 1 '15 at 22:24
  • You mean by half the sum of the width of \infty and the width of /? – Mad Hatter Feb 1 '15 at 23:06
  • oh yes well I meant (but didn't write) padding has to be half the difference on each side, so back space has to be that plus the with of / which comes to what you say:-) – David Carlisle Feb 2 '15 at 9:18
  • :) Thanks for the hint. It was very helpful. – Mad Hatter Feb 2 '15 at 22:11
18

Don't reinvent the wheel. ;-)

\documentclass{article}
\usepackage{centernot}
\begin{document}

$\centernot{\infty}$

\end{document}

enter image description here

Some manual adjusting can help:

\documentclass{article}
\usepackage{centernot}
\begin{document}

$\centernot{\mkern-0.35mu\infty}\mkern-0.35mu$

\end{document}

enter image description here

Finding the exact geometric center is not really easy, because it depends on the side bearings of the symbol. Here's a picture showing them

enter image description here

Also the slash has side bearings, so it's a question of balancing them.

Of course, when you're satisfied with the positioning, you can define

\newcommand{\cinfty}{\mathrel{\centernot{\mkern-0.35mu\infty}\mkern-0.35mu}}

A different version that uses the slash rather than \not (and my favorite tool \ooalign).

\documentclass{article}

\makeatletter
\newcommand{\cinfty}{\mathrel{\mathpalette\do@cinfty\relax}}
\newcommand{\do@cinfty}[2]{%
  \vphantom{/}%
  \ooalign{\hidewidth$\m@th#1/$\hidewidth\cr$\m@th#1\infty$}%
}
\begin{document}

$A\cinfty B_{\cinfty}$

\end{document}

enter image description here

  • More than I would venture to expect :) Thanks a lot! – Mad Hatter Feb 1 '15 at 23:08
8
\documentclass{article}
\usepackage{stackengine}
\renewcommand\stacktype{L}
\stackMath
\begin{document}
$\stackon[0pt]{\infty}{/}$
\end{document}

enter image description here

If you want the version that is a \mathrel and scales with the math style,

\documentclass{article}
\usepackage{scalerel,stackengine}
\def\notinfty{%
  \renewcommand\stacktype{L}\mathrel{\ensurestackMath{%
  \ThisStyle{\stackon[0pt]{\SavedStyle\infty}{\SavedStyle/}}}}%
}
\begin{document}
$A \notinfty B ~\scriptstyle A\notinfty B ~\scriptscriptstyle A \notinfty B$
\end{document}

enter image description here

2

\not is usually optimized for the equals sign. Package centernot takes care of the horizontal centering. \infty is wider than the equals sign, see egreg's answer.

The equals sign is vertically centered around the math axis and \not usually follows this symmetry. The symbol \infty, however, just sits on the base line (Computer Modern fonts, cmsy10). Since it seems used with a different meaning as relational symbol, it might be allowed to vertically center it.

The following example centers \infty as \vinfty vertically around the math axis and uses package centernot for the horizontal centering.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[variablett]{lmodern}
\usepackage{amsmath}% for environment "gather*"

\usepackage{centernot}

\makeatletter
\newcommand*{\vinfty}{%
  \mathrel{%
    \mathpalette\@vinfty{}%
  }%
}
\newcommand*{\@vinfty}[2]{%
  % #1: math style
  % #2: unused
  \vcenter{%
    \hbox{$#1\infty\m@th$}%
  }%
}
\makeatother

\newcommand*{\notvinfty}{%
  \centernot\vinfty
}

\begin{document}
\centering

{\scriptsize Vertically centered (\texttt{\textbackslash vinfty})}
\begin{gather*}
  a \vinfty b \notvinfty c
\\
  \scriptstyle a \vinfty b \notvinfty c
\\
  \scriptscriptstyle a \vinfty b \notvinfty c
\end{gather*}
%
{\scriptsize Not vertically centered (\texttt{\textbackslash infty})}
\begin{gather*}
  a \mathrel{\infty} b \centernot\infty c
\\
  \scriptstyle a \mathrel{\infty} b \centernot\infty c
\\
  \scriptscriptstyle a \mathrel{\infty} b \centernot\infty c
\end{gather*}

\end{document}

Result

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.