2

I am convinced this is a duplicate as much as I used a search engine to unsuccessfully find one, but how can I control the line length of the \neq symbol please? I do not want to use tikz and I am sure there would be a way with kerning but I am not sure how to manipulate math symbols, should they be overlayed on top?

MWE

\documentclass{article}

\begin{document}
$P\neq x^2$
\end{document}

enter image description here

I do not like how far the diagonal strike through travels and would like a way to control it using the centre of the equal line as the origin if possible please so it is equal in length on both sides. How can this be achieved please? Would appreciate a duplicate if this is not original.

3 Answers 3

4

Do you mean something like this?

\documentclass{article}
\usepackage{stackengine,scalerel}
\newcommand\neqA{\mathrel{\ensurestackMath{%
  \stackinset{c}{}{c}{.7pt}{\vstretch{.5}{/}}{=}}}}
\begin{document}
$P\neq x^2$

$P\neqA x^2$
\end{document}

enter image description here

For a version that allows script math styles:

\documentclass{article}
\usepackage{stackengine,scalerel}
\newcommand\neqA{\mathrel{\ThisStyle{\ensurestackMath{%
  \stackinset{c}{}{c}{.8\LMpt-.1pt}{%
  \SavedStyle\vstretch{.5}{/}}{\SavedStyle=}}}}}
\begin{document}
$P\neq x^2$

$P\neqA x^2$

$\scriptstyle P\neqA x^2$

$\scriptscriptstyle P\neqA x^2$
\end{document}

enter image description here

3

You can use a slash in the relative script size.

\RequirePackage{fix-cm}
\documentclass{article}
\usepackage{amsmath}

\makeatletter
\NewDocumentCommand{\smallnot}{}{\mathrel{\text{\smallnot@}}}

\newcommand{\smallnot@}{%
  \settowidth\dimen@{$\m@th=$}%
  \makebox[0pt][l]{%
    \makebox[\dimen@]{%
      $\m@th\vcenter{\hbox{\fontsize{\sf@size}{0}\selectfont$/$}}$%
    }%
  }%
}
\makeatother
\AtBeginDocument{%
  \NewCommandCopy{\oldnot}{\not}% Just for comparison
  \RenewCommandCopy{\not}{\smallnot}%
}

\begin{document}

$\not= \neq \ne$\quad
$\scriptstyle\not= \neq \ne$\quad
$\scriptscriptstyle\not= \neq \ne$

$\oldnot=$

\end{document}

It doesn't work so well in scriptscript size, but I don't think it's a real problem.

enter image description here

3

In OpTeX, you can use \mathbox which keeps the actual textsize/scriptsize etc.

\fontfam[lm]

\def\neq{\mathrel{\mathbox{\setfontsize{mag.7}\rm\raise.2ex\rlap{\kern.25em/}}{=}}}

defined: $a \neq b_{\neq}$

original: $a \ne b_{\ne}$

\bye

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .