3

I was interested in using a custom symbol. So, I played around with some numbers in a MWE (because it was much faster to compile) before trying it out in my original document. I wound up with the following. (The parameters were just found by experimentation.)

\documentclass{minimal}

\usepackage{graphicx}

\newcommand{\ineq}{\mathrel{\mkern -3mu \in \mkern -16mu \makebox[0.5em]{\raisebox{-.225em}{\scalebox{1.68}[1]{\_}}}}}

\begin{document}

$x\ineq y$

\end{document}

MWE

Then, I added this to the document I wanted to actually use it in, but it didn't quite look so nice. Below, I've included the same MWE as before, but now with most font-related commands that appear in the preamble of the document intended for final use. (These lines were inserted between \documentclass{minimal} and \usepackage{graphicx}.)

\documentclass{minimal}

\usepackage[utf8]{luainputenc}
\usepackage[T1]{fontenc}

\usepackage[english]{babel}

\usepackage[tracking=true]{microtype}

\usepackage{avant}

\usepackage{mathptmx}

\usepackage{graphicx}

\newcommand{\ineq}{\mathrel{\mkern -3mu \in \mkern -16mu \makebox[0.5em]{\raisebox{-.225em}{\scalebox{1.68}[1]{\_}}}}}

\begin{document}

$x\ineq y$

\end{document}

Final

Now, I could just redefine the symbol with parameters modified so that things look right with this new preamble, but this solution is less than ideal because, every time I want to reuse the symbol in a different setup, I will have to go back and play with the numbers again. It would be best if I could define a single command that was robust enough to display 'correctly' in almost any environment. Is it possible to do something like this?

  • Never use minimal to begin with. And mathptmx is not the best math font package: it's essentially a 20th century hack for getting an almost decent Times-like font with math support. – egreg Mar 30 '17 at 21:46
  • You could measure the width of the character. What does this have to do with mathptmx? Somewhat confused. But please provide complete code we can compile and do not use minimal. – cfr Mar 30 '17 at 21:51
  • What's actually wrong with minimal? I've been using this in most of my MWEs because my understanding was that it just simply loaded less LaTeX macros, which meant less overhead. – Jonathan Gleason Mar 30 '17 at 21:55
  • @cfr The complete code you can compile is obtained by taking the first complete MWE and inserting the second group of lines between the aforementioned two lines. I figured saying this would be better than just repeating code, but I will edit the question to just contain the complete code samples in both cases. – Jonathan Gleason Mar 30 '17 at 21:56
  • @cfr Try adding/deleting only that line. I found that the output changed. – Jonathan Gleason Mar 30 '17 at 22:03
  • 1
    There's a question explaining why not to use minimal. – cfr Mar 30 '17 at 22:20
  • 1
    http://tex.stackexchange.com/questions/42114/why-should-the-minimal-class-be-avoided – cfr Mar 30 '17 at 22:22

2 Answers2

2

Font independence is a dream, I'm afraid.

You can try underlining, but pretending the \in is slightly thinner than its bounding box. The amount of “thinning” depends on the font, but it's not difficult to adapt the macro to the current needs.

\documentclass{article}
\usepackage{amsmath}
\usepackage{newtxtext,newtxmath}

\newcommand{\ineq}{%
  \mathrel{%
    \mspace{1.2mu}%
    \underline{\mspace{-1.2mu}\in\mspace{-1.2mu}}%
    \mspace{1.2mu}%
  }%
}

\begin{document}

$x\ineq y$

\end{document}

Notes

  1. minimal should never be used
  2. mathptmx is a 20 year old hack for getting a math font that could almost decently accompany Times as text font
  3. Nowadays, NewTX does a much better job.

enter image description here

egreg
  • 1,121,712
1

Three versions shown below, by uncommenting the appropriate lines in the MWE. I relied on the fact that a minus sign should generally be a similar width to \in (actually I shrink the minus to 0.85 times its original width). I used stackengine for the sub-placement of the minus, and scalerel to make it work across math styles.

As egreg notes, it is hard to get a universal definition across fonts.

\documentclass{article}

\usepackage{graphicx,stackengine,scalerel}
%\usepackage{mathptmx}
%\usepackage{newtxmath}

\newcommand{\ineq}{\mathrel{\ThisStyle{\ensurestackMath{%
  \stackengine{-1.5\LMpt}{\SavedStyle\in}{%
    \SavedStyle\kern.5\LMpt\hstretch{.85}{-}}{U}{c}{F}{T}{S}}}}}

\begin{document}

$x\ineq y \quad\scriptstyle x\ineq y \quad\scriptscriptstyle x\ineq y$

\end{document}

Computer Modern:

enter image description here

mathptmx

enter image description here

newtxmath

enter image description here