[Tex/LaTex] Closer slanted parallel symbol

math-modepdftexsymbols

Looking the @egreg's answer where I have deleted some parts of code

\documentclass[12pt]{article}
\newcommand{\parallelsum}{\mathbin{\!/\mkern-5mu/\!}}
\begin{document}
$AB \parallelsum CD$
\end{document}

I would to change the classical symbol of \parallel

enter image description here

to obtain another same symbol of parallel

enter image description here

where the slanted should not be above and below the two red lines, are closer to each other and are in line with the text, in mathematical mode in both subscript and overscript mode. If there's already a symbol like this I'm searching for even better for me.

Best Answer

Raise and scale.

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

\makeatletter
\newcommand{\newparallel}{\mathrel{\mathpalette\new@parallel\relax}}
\newcommand{\new@parallel}[2]{%
  \begingroup
  \sbox\z@{$#1T$}% get the height of an uppercase letter
  \resizebox{!}{\ht\z@}{\raisebox{\depth}{$\m@th#1/\mkern-5mu/$}}%
  \endgroup
}
\makeatother

\begin{document}

$AB\newparallel CD$

$\scriptstyle AB\newparallel CD$

\end{document}

enter image description here

A different implementation with picture mode. One can easily vary the slope by acting on the second argument to \mathpalette.

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

\makeatletter
\newcommand{\newparallel}{\mathrel{\mathpalette\new@parallel{0.3}}}
\newcommand{\new@parallel}[2]{%
  \begingroup
  \settoheight{\unitlength}{$#1T$}% get the height of an uppercase letter
  \sbox\z@{\new@parallel@slash{#1}{#2}}%
  \mkern0.5mu\copy\z@\mkern-0.5mu\copy\z@\mkern0.5mu
  \endgroup
}
\newcommand{\new@parallel@slash}[2]{%
  \begin{picture}(#2,1)
  \roundcap
  \new@parallel@linethickness{#1}
  \Line(0,0)(#2,1)
  \end{picture}%
}
\newcommand{\new@parallel@linethickness}[1]{%
  \linethickness{%
      \ifx#1\displaystyle \fontdimen8\textfont\else
      \ifx#1\textstyle \fontdimen8\textfont\else
      \ifx#1\scriptstyle \fontdimen8\scriptfont\else
      1.1\fontdimen8\scriptscriptfont\fi\fi\fi 3
  }%
}
\makeatother

\begin{document}

$AB\newparallel CD$ ${\newparallel}/$

$\scriptstyle AB\newparallel CD$ $\scriptstyle{\newparallel}/$

$\scriptscriptstyle AB\newparallel CD$ $\scriptscriptstyle{\newparallel}/$

{\Large$AB\newparallel CD$ ${\newparallel}/$}

\end{document}

This is for Computer Modern fonts; for different fonts, \roundcap might be omitted. In the example I show the standard slash to compare the line thickness.

enter image description here