I want a length macro, named \mymathspace, which is changeable in inline math (including \text command) and display math. For example,
Text mode $inline\ math\vert\mymathspace\vert{}inline\ math$
get a space 6mu between the \verts; and
\[display\ math\vert\mymathspace\vert{}display\ math\]
get a space 18mu between the \verts; while
\[display\ math\text{Text mode $math\ in\ text\ command
\vert\mymathspace\vert$}display\ math\]
get a space 6mu between the \verts. But I can't obtain this by \if@display and \ifmmode.