Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
1  
\norm{{}\mathrel{\cdot}{}} does the trick quite nicely. –  cslstr May 25 at 17:56
    
You can insert a thin space with \, or a thick space with \;. –  Henri Menke May 25 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 May 25 at 17:57

2 Answers 2

up vote 5 down vote accepted

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.

share|improve this answer

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}
share|improve this answer
    
That's odd I event even thought there was a placement different between the two. Seems I got lucky ;-) –  daleif May 25 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 May 25 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 May 25 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 May 25 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. –  jfbu May 26 at 6:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.