4

Often in math textbooks when they define an absolute value (or a norm in general) they use the symbol with a dot (even nothing) with some space inside. It looks like this:

norm

Whatever method I use to define the absolute value symbol, normally I would only get a narrow spacing unless I define a new command for this special case. How do you do that?

Andrew
  • 175
  • 1
    In the middle of page 27 of https://ftp.acc.umu.se/mirror/CTAN/macros/latex/contrib/mathtools/mathtools.pdf you will find one way. – mickep Feb 06 '22 at 15:08

2 Answers2

7

Irrespective of how you generate the absolute-value and norm "fences" -- be it with | and \|, named macros such as \lvert/\rvert and \lVert/\rVert, or by defining bespoke macros called, say, \abs and \norm -- the adjustment that's required is always the same: surround \cdot with {}, aka "empty math atoms", i.e., write {}\cdot{}.

For the sake of ensuring notational consistency across the document -- a point made by @egreg in a comment -- it's a good idea not to write {}\cdot{} directly. Instead, define a macro called, say, \blank, in the preamble and then write \abs{\blank} and \norm{\blank} in the body of the document.

enter image description here

\documentclass{article}

\usepackage{mathtools} % for "[lr][vV]ert" and '\DeclarePairedDelimiter' macros \DeclarePairedDelimiter{\abs}{\lvert}{\rvert} \DeclarePairedDelimiter{\norm}{\lVert}{\rVert} \newcommand{\blank}{{}\cdot{}}

\begin{document} $| \blank | \quad | \blank |$

$\lvert \blank \rvert \quad \lVert \blank \rVert$

$\abs{\blank} \quad \norm{\blank}$ \end{document}

Mico
  • 506,678
  • 2
    I beg do disagree. Not about {}\cdot{} per se, however. You should recommend first of all to define a special command for this signpost. Then one's free to modify the definition (for example, a coauthor might say that a dash is preferable…) – egreg Feb 07 '22 at 09:36
  • Any reason to not do as Vicent and make \widecdot (I normally call it \mtarg) the default if the arg is empty? (I normally just use \ifblank{#1}{\mtarg}{#1} (etoolbox) – daleif Feb 07 '22 at 10:17
  • 1
    +1, but I'd much prefer an “abstract” name; personally I use \blank or variations thereon. Not “snazzier”, but carrying semantics. – egreg Feb 07 '22 at 11:18
4

You can do something like this.

\documentclass{article}
\usepackage{mathtools}
\newcommand*{\argordot}[1]{%
    \def\arg{#1}%
    \ifx\arg\empty
        \,\cdot\,%
    \else
        #1%
    \fi%
}
\DeclarePairedDelimiterX{\norm}[1]{\lVert}{\rVert}{\argordot{#1}}
\begin{document}
\(\norm{f}\) \(\norm{}\)
\end{document}

Vincent
  • 20,157
  • I think {}\cdot{} may be preferable to \,\cdot\,, as \cdot is generally defined as a binary operator, which should be surrounded by \medspace, not \thinspace (aka \,). Using {} is elegant because it hands the decision of how much whitespace to use back to TeX. – Mico Feb 06 '22 at 16:37
  • 1
    @Mico I just thought it looked better this way, with a little less spacing. Indeed if you use {} around \cdot you will get the same spacing as if the dot was used as a binary operator, but here we use the dot as the symbol, not as the operator, so I don't see a reason why choosing the precise binary operator spacing would be better. – Vincent Feb 06 '22 at 17:02