有豎線的不等號 (≠)

有豎線的不等號 (≠)

是否可以\neq使用垂直條而不是傾斜條來得到“但是”?像 AMS 這樣的不等式運算子\gvertneqq具有這種「不等於」的特徵,但並非沒有將其與其他符號混合在一起。

\documentclass[a5paper]{article}
\usepackage{amssymb}
\usepackage{amsmath}
\begin{document}
\begin{align*}
a&\gvertneqq b\\
C&\neq \varnothing
\end{align*}
\end{document}

上述程式碼的結果

所以我基本上想要的是上面 > 下的孤立符號\gvertneqq。特別是因為我不喜歡第二行中斜線的不同斜率,而「≠∅」是相當常見的組合。

答案1

有垂直線的等號

垂直線|對我來說有點高。以下定義\vneq降低了垂直線的總高度以符合 的總高度\neq。調整垂直高度不會改變水平方向的線條粗細。

  • \vneqxscale最終垂直線的寬度和高度可以透過重新定義巨集和進行微調\vneqyscale。預設為1.
  • \mathpalette允許符號自動調整大小。

範例檔:

\documentclass{article}

\usepackage{amssymb}% \varnothing

\usepackage{graphicx}% \resizebox
\makeatletter
\newcommand*{\vneq}{%
  \mathrel{%
    \mathpalette\@vneq{=}%
  }%
}
\newcommand*{\@vneq}[2]{%
  % #1: math style (\displaystyle, \textstyle, ...)
  % #2: symbol (=, ...)
  \sbox0{\raisebox{\depth}{$#1\neq$}}%
  \sbox2{\raisebox{\depth}{$#1|\m@th$}}%
  \ifdim\ht2>\ht0 %
    \sbox2{\resizebox{\vneqxscale\width}{\vneqyscale\ht0}{\unhbox2}}%
  \fi
  \sbox2{$\m@th#1\vcenter{\copy2}$}%
  \ooalign{%
    \hfil\phantom{\copy2}\hfil\cr
    \hfil$#1#2\m@th$\hfil\cr
    \hfil\copy2\hfil\cr
  }%
}
\newcommand*{\vneqxscale}{1}
\newcommand*{\vneqyscale}{1}
\makeatother

\begin{document}
\[
  % Comparison \neq vs. vneq
  \varnothing \neq \emptyset \vneq \varnothing \\
\] 
\[ 
  % Check sizes:
  \vneq^{\vneq^{\vneq}} \\
\] 
\[ 
  % Bounding box checks:
  \setlength{\fboxsep}{0pt}
  \setlength{\fboxrule}{.1pt}
  \fbox{$\neq$}\,\fbox{$\vneq$}\,\fbox{$|$}
\]
\end{document}

結果

高度還可以進一步降低,例如

\renewcommand*{\vneqyscale}{.8}

結果/.8

結果mathabx

數學

結果txfonts

tx字體

結果MnSymbol

錳符號

這裡垂直線太粗,水平調整大小要縮小:

\renewcommand*{\vneqxscale}{.67}

MnSymbol\vneqxscale= 的結果.67

Mn符號/.67

替代varnothing

可以使用匹配傾斜垂直線的斜率來構造\neq空集符號,而不是更改。然而,太小又太大。因此,該方法顯示為提供和。\varnothing\not\circ\bigcirctxfonts\medcircMnSymbol\medcircle

\documentclass{article}

%\usepackage{txfonts}
%\newcommand*{\varemptysetcircle}{\medcirc}

\usepackage{MnSymbol}
\newcommand*{\varemptysetcircle}{\medcircle}

\makeatletter
\newcommand*{\varemptyset}{%
  {% mathord
    \vphantom{\not=}% correct height and depth of the final symbol
    \mathpalette\@varemptyset\varemptysetcircle
  }%
}
\newcommand*{\@varemptyset}[2]{%
  % #1: math style (\displaystyle, \textstyle, ...)
  % #2: circle
  \ooalign{%
    \hfil$\m@th#1\not\hphantomeq$\hfil\cr
    \hfil$\m@th#1#2$\hfil\cr
  }%
}
% \not can be redefined to take an argument
\newcommand*{\hphantomeq}{%
  \mathrel{\hphantom{=}}%
}
\makeatother

\usepackage{color}

\begin{document}
\[
  \not=\; \color{blue}\neq \varemptyset\; \color{black}\varnothing
\]
\end{document}

結果txfonts

tx字體

結果MnSymbol

錳符號

答案2

是的:

下面的程式碼的螢幕截圖

\documentclass[a5paper]{article}
\usepackage{amssymb}
\usepackage{amsmath}
\newcommand\vneq{\mathrel{\ooalign{$=$\cr\hidewidth$|$\hidewidth\cr}}}
\begin{document}
\begin{align*}
a&\gvertneqq b\\
C&\neq \varnothing \\
d&\vneq f
\end{align*}
\end{document}

要了解 中命令背後的動機,請閱讀egreg中\vneq關於 的優秀教程\ooalign\subseteq+\circ作為單一符號(「開放子集」)

答案3

一個簡單的解決方案是

\usepackage{mathabx}
\changenotsign

但這意味著改變很大一部分數學符號,這是不可取的,因為在我看來,提供的一些符號mathabx設計得很糟糕。

使用標準工具的解決方案是

\documentclass{article}

\renewcommand\neq{\mathrel{\vphantom{|}\mathpalette\xsneq\relax}}
\newcommand\xsneq[2]{%
  \ooalign{\hidewidth$#1|$\hidewidth\cr$#1=$\cr}%
}

\begin{document}
$a\neq b$
\end{document}

我使用它\renewcommand是因為只需刪除該程式碼即可恢復\neq到其通常的形狀。

透過使用\mathpalette,創建的符號的下標或上標將變小。

在此輸入影像描述

相關內容