8

I have the following equation: $\|\text{DFT}\left( f_t (n) \right)\|^2 $ (rendered)

This equation is rendered with a space before the second $\|$. Why is this and how can I fix it?

diabonas
  • 25,784
Peter Smit
  • 14,035
  • It seems latex processing isn't working. Did I do something wrong? – Peter Smit Aug 27 '10 at 06:27
  • Could you try \providecommand\norm[1]{\lVert#1\rVert}? – Leo Liu Aug 27 '10 at 06:53
  • @Leo I like to try things, but only if I understand what it does. Where should I put that, and what should it solve? – Peter Smit Aug 27 '10 at 07:03
  • @Peter Smit: What do you mean in your comment about "latex processing"? What did you expect to happen that didn't? – Andrew Stacey Aug 27 '10 at 08:19
  • @Andrew Like on the Math and Stats site that things in between dollar signs are automatically latex-parsed – Peter Smit Aug 27 '10 at 09:30
  • @Peter Smit: We discussed that a bit on the meta site and the current consensus is that it would be a Bad Idea. If you want to join in the discussion, the relevant posts are http://meta.tex.stackexchange.com/questions/7/we-need-tex-markup and http://meta.tex.stackexchange.com/questions/181/can-we-turn-off-math-tex-please – Andrew Stacey Aug 27 '10 at 10:01
  • 2
    @Peter Smith: What Leo is suggesting is basically what I answered below. \lVert and \rVert are basically the same as \left| and \right|. You put his code into the preamble and use $\norm{\text{DFT}\left( f_t (n) \right)}^2$. "\providecommand" is like "\newcommand", so his code defines a new command named "\norm". It will save you typing if you need to use the same norm several times. It will also make your life much easier if you ever decide to use |...| or say ||...||_p for norm instead. You will only need to change one place. – Jan Hlavacek Aug 27 '10 at 11:40
  • 1
    I would also suggest that you place \DeclareMathOperator\DFT{DFT} in your preamble, and use \DFT\left(f_t(n)\right) instead of \text{DFT}\left(... (I am assuming that you use the amsmath package, since you use \text.) – Jan Hlavacek Aug 27 '10 at 11:49

2 Answers2

13

Use $\left\|\text{DFT}\left( f_t (n) \right)\right\|^2$. Otherwise LaTeX does not know that the first \| is supposed to be a left delimiter and the second \| a right one.

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
Jan Hlavacek
  • 19,242
2

This is due to some weird design choices by Knuth. Notice that there's also an extra space after \text{DFT}. They are produced because \left and \right follow different spacing rules.

To obtain the expected spacing, use

$\|\text{DFT}\mathopen{}\left( f_t (n) \right)\mathclose{}\|^2$

For a more complete discussion, see this answer.