3

I'm having the following code:

\documentclass[11pt]{article}
\usepackage{amssymb,amsthm,amsmath}
\newcommand{\norm}[1]{\lVert #1 \rVert_2}

\begin{document}
\begin{displaymath}
\norm{\cdot}=...
\end{displaymath}
\end{document}

I'd like to add a little space before and after the dot in the norm, because it's a bit crushed between the vertical lines now. Is there a command with the same output as \cdot that does this automatically or should I insert the spacing manually (with ~ for example) each time?

3
  • 1
    \norm{{}\mathrel{\cdot}{}} does the trick quite nicely.
    – cslstr
    Commented May 25, 2014 at 17:56
  • You can insert a thin space with \, or a thick space with \;. Commented May 25, 2014 at 17:56
  • You won't find a command that has the space built-in, I don't believe. Manual space or relational spacing should be fine.
    – cslstr
    Commented May 25, 2014 at 17:57

2 Answers 2

7

I would go even further than Mico, why not embed the empty arg marker into the macro it self.

\documentclass[a4paper]{memoir}
\usepackage{mathtools,etoolbox,amssymb}
\newcommand\emptyarg{{}\cdot{}}
\DeclarePairedDelimiterX\norm[1]\lVert\rVert{
  \ifblank{#1}{\emptyarg}{#1}
}
\begin{document}
\[
\norm{}: A \to B \qquad \norm{X}
\]
\end{document}

BTW: on CTAN the latest mathtools version now contain a tool to build the L^2 norm, such that one does not have to add the _2 manually all the time.

6

You could define a new macro named, say, "\widecdot", that surrounds \cdot with thinspace (\,) on either side. Note: I wouldn't redefine \cdot directly, as this macro tends to be used internally by other macros as well.

Incidentally, your definition of \norm is a bit suboptimal since subscripts -- such as the 2 in your example -- aren't set quite low enough. It may be preferable to use the macro \DeclarePairedDelimiter of the mathtools package; compare the output of the \norm and \Norm macros in the second equation below.

enter image description here

\documentclass[11pt]{article}
\usepackage{amssymb,mathtools}
\newcommand{\norm}[1]{\lVert #1 \rVert_2}
\DeclarePairedDelimiter{\Norm}{\lVert}{\rVert}
\newcommand\widecdot{\,\cdot\,}
\begin{document}
\[ \norm{\cdot} \text{ vs.\ } \norm{\widecdot}\]

\[ \norm{\widecdot}\text{ vs.\ } \Norm{\widecdot}_2 \]
\end{document}
8
  • That's odd I event even thought there was a placement different between the two. Seems I got lucky ;-)
    – daleif
    Commented May 25, 2014 at 21:08
  • @daleif - I think the OP's definition of \norm generates the insufficiently-low subscript issue because it doesn't use \left and \right (or equivalent). Hence TeX doesn't "know" that the 2 subscript should be typeset a bit lower than usual as it follows a glyph (\Vert) that has a descender component.
    – Mico
    Commented May 25, 2014 at 21:34
  • But should it know from the fact what we are using \rVert that ought to to mark it as a closing fence. The only thing extra that mathtools do is to wrap it explicitly in a \mathclose.
    – daleif
    Commented May 25, 2014 at 22:15
  • @daleif - I think the use of the explicit \mathclose directive is the key. Compare the looks of \lVert a\rVert_2 and \mathopen{\lVert} a\mathclose{\rVert}_2, in either inline or display-style math mode: Without the explicit \mathclose directive, the subscript is positioned without regard to the size of the preceding symbol. This holds for other fence symbols too, such as ), ], and \}...
    – Mico
    Commented May 25, 2014 at 23:01
  • @daleif it is not the \mathclose as you can test with \mathopen\lVert a\mathclose\rVert_2 but the braces (which create a sub-formula) as you can test with {\lVert} a{\rVert}_2. Try also {\lVert a\rVert}_2.
    – user4686
    Commented May 26, 2014 at 6:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .