There are already several questions about absolute signs, like this one. My question is different in that I'm not satisfied with the typesetting of the absolute sign offered by any of the options I know about. Consider the following MWE, which illustrates the problem for the letter "G":
\documentclass[crop,varwidth]{standalone}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{tikz}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\newcommand\myslash{\char`\\}
\begin{document}
\texttt{|G|}: $|G|$
\texttt{\myslash left G\myslash right}: $\left|G\right|$
\texttt{\myslash lvert G\myslash rvert}: $\lvert G\rvert$
\texttt{\myslash abs\{G\}}: $\abs{G}$
\end{document}
All four options produce absolute signs that go too far below the baseline (for my taste):
With a new command:
\documentclass[crop,varwidth]{standalone}
\usepackage{tikz}
\newlength{\myht}
\newlength{\mydp}
\newcommand{\myabs}[1]{%
\settoheight{\myht}{#1}%
\settodepth{\mydp}{#1}%
\tikz[anchor=base, baseline=0pt] \draw[line cap=round] (0pt,-\mydp-0.2pt) -- (0pt,\myht+0.3pt);%
$\mkern0.6mu #1\mkern1.0mu$%
\tikz[anchor=base, baseline=0pt] \draw[line cap=round] (0pt,-\mydp-0.2pt) -- (0pt,\myht+0.3pt);%
}
\begin{document}
\myabs{G} = 2
\myabs{g} = 3
\end{document}
I get what I think are better-looking absolute signs:
Of course, one can quibble about some of the spacing between the absolute signs and the letters as well as the distances above and below the letters; I did not try to tune these yet.
However, this is clearly not good enough because when you typeset a scalar product, we have two absolute values side-by-side.
The only solution I can see (other than using symbols in the dot product that have similar height and depths) is to allow a user to influence the typesetting of the absolute signs, for example like this:
\documentclass[crop,varwidth]{standalone}
\usepackage{tikz}
\usepackage{xifthen}
\newlength{\myht}
\newlength{\mydp}
\newcommand{\myabs}[3]{%
\settoheight{\myht}{#2}%
\settodepth{\mydp}{#3}%
\tikz[anchor=base, baseline=0pt] \draw[line cap=round] (0pt,-\mydp-0.2pt) -- (0pt,\myht+0.3pt);%
\ensuremath{\mkern0.6mu {#1}\mkern1.0mu}%
\tikz[anchor=base, baseline=0pt] \draw[line cap=round] (0pt,-\mydp-0.2pt) -- (0pt,\myht+0.3pt);%
\ensuremath{\mkern2.0mu}%final space
}
\begin{document}
\myabs{G}{G}{g}\myabs{g}{G}{g}
\end{document}
I'm interested in getting feedback on the new command, both from a typesetting point of view as well as from an implementation point of view.


