How to put a bar on a longer \mid

This superimposes \top to \mid; the former is a raised and the latter lowered.

It changes size in subscripts/superscripts.

UPDATE The negated relation has been added

\documentclass{article}
\usepackage{amsmath,amssymb}

\makeatletter
\newcommand{\topmid}{\mathrel{\mathpalette\topmid@\relax}}
\newcommand{\ntopmid}{\mathrel{\mathpalette\topmid@\nmid}}
\newcommand{\topmid@}[2]{%
  \begingroup
  \sbox\z@{$\m@th#1\mspace{1.5mu}\nonscript\mspace{1.5mu}$}%
  \ooalign{%
    \hfil\raisebox{\wd\z@}{$\m@th#1\top$}\hfil\cr
    \ifx#2\relax\else\hfil$\m@th#1#2$\hfil\cr\fi
    \hfil\raisebox{-0.3\wd\z@}{$\m@th#1|$}\hfil\cr
  }%
  \endgroup
}
\makeatother

\begin{document}

$p^{n_i}\topmid |\mathfrak{G}_{i+1}/\mathfrak{G}_{i}|$

$\scriptstyle a\topmid b\mid c$

$p^{n_i}\ntopmid |\mathfrak{G}_{i+1}/\mathfrak{G}_{i}|$

$\scriptstyle a\ntopmid b\mid c$

\end{document}

enter image description here


A similar idea as egreg's but implemented differently. The parameters can be chosen at will. (The vertical lines seem a bit broken but that's only a bad rendering of my viewer.)

\documentclass{article}

\usepackage{amsmath,amssymb}

\makeatletter

% returns ex in current math style
\newcommand*{\math@ex}[1]{%
    \fontdimen5
    \ifx#1\displaystyle\textfont\else
    \ifx#1\textstyle\textfont\else
    \ifx#1\scriptstyle\scriptfont\else
    \scriptscriptfont\fi\fi\fi 2\relax
}

\newcommand*{\divides}{\mathrel{\mathpalette\@divides\mid}}
\newcommand*{\ndivides}{\mathrel{\mathpalette\@divides\nmid}}

\newcommand*{\@divides}[2]{%
   \vcenter{%
      \m@th
      \offinterlineskip
      \ialign{%
         \hfil$##$\hfil\cr
         #1\top\cr
         \noalign{\kern-\math@ex{#1}}% or choose a different value
         #1#2\cr
      }%
   }%
}

\makeatother

\begin{document}

$a \divides b$
$\scriptstyle a \divides b$
$\scriptscriptstyle a \divides b$

\smallskip
$a \ndivides b$
$\scriptstyle a \ndivides b$
$\scriptscriptstyle a \ndivides b$

\end{document}

enter image description here

Tags:

Symbols