13

I'm writing my first "real" paper in Latex, and one of my major pieces of notation involves item-wise multiplying the Nx1 vector \widehat{w} to the Nx1 vector \widehat{S}, and I've been using cdot to denote the non-matrix multiplication, so basically I am writing

(\widehat{w}\cdot\widehat{S})^{\intercal}\widetilde{H}(\widehat{w}\cdot\widehat{S})

a million times in my paper.

I am using cdot to avoid a lot of confusion that would result from just using \widehat{S}_w, or \widehat{w}\widehat{S} due to similar notation already in use in the paper. Basically I am complaining that the cdot adds a ton of space between the w and the S whereas really they are a single unit--a weighted S.

QUESTION: Is there any trick to shrink cdot or is there another bivariate function I could use to get the w and S to stick closer together? Can you help me make my paper prettier?

Thanks for any help.

Code:

\documentclass{article}
\usepackage{amssymb}
\begin{document}
\[(\widehat{w}\cdot\widehat{S})^{\intercal}\widetilde{H}(\widehat{w}\cdot\widehat{S})\]
\end{document}
Rebecca
  • 133

2 Answers2

13

Three suggestions:

  1. See Why is \[ … \] preferable to $$?

  2. Define a macro/command if you're using something multiple times. It promotes consistency and would make your life much easier if you decide to change things later on, even just a little bit. For example, \itemmul{<mat1>}{<mat2>}. As reference, see Consistent typography.

  3. You can modify the spacing around a relation/operator to your liking by changing it into an ordinal symbol first, and then specifying the kerning using \mkern. Ordinals are obtained by wrapping the relation/operator in braces, like {\cdot} or using \mathord{\cdot}. Math kerning is specified in mus (or math units).

Using the above suggestions, here's a take on your spacing:

enter image description here

\documentclass{article}
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\newcommand{\itemmul}[2]{% \itemmul{<mat1>}{<mat2>}
  \widehat{#1}\mkern1mu{\cdot}\mkern1mu\widehat{#2}% itemwise-multiplication
}
\begin{document}
\[
  (\itemmul{w}{S})^{\intercal}\widetilde{H}(\itemmul{w}{S})
\]
\end{document}
Werner
  • 603,163
  • I'm not sure...But in college I was told that (1) align is better than eqnarray and (2) [ ] is better than $$ $$. – Rebecca May 20 '12 at 01:12
  • @Rebecca: Yes, align (requires amsmath) is much better than eqnarray and \[...]is preferred over$$...$$` in LaTeX. I suggested the latter (which you haven't followed, by the way), while the former is also just a good observation in general. – Werner May 20 '12 at 01:16
  • I'm still getting the hang of this site (for example, I just wrote a comment but it disappeared...) – Rebecca May 20 '12 at 01:20
  • I am avoiding using \renewcommand, etc. in my paper draft because it is not clear yet which journal it is going to. The 2-3 options have different rules, and I am trying to avoid trouble down the road. Honestly I think it made me better at typing in Tex, although yes it has been painful at times.

  • Thanks for this explanation. It is much clearer than what I found when trying to answer my question with Google.

  • – Rebecca May 20 '12 at 01:23
  • 2
    @Rebecca: If you're using \newcommand to create a new command that you're using "a million times", I'm sure any journal will accept it. If you don't use a new command, then you run a greater risk of not being consistent, which may be worse when writing a paper. – Werner May 20 '12 at 01:29
  • I've had some bad experiences in the past but it was with journals in a non-mathematical field. I'll consider a different approach for papers 2-1000. Thanks for the advice. – Rebecca May 20 '12 at 01:31
  • 1
    I just checked the author information sections, and of the rather few rules they had, each of the major journals in my field included something along the lines of "Restrict the use of user-defined definitions and newcommands to the minimum." I was under the impression that this was a normal request. Is it not? – Rebecca May 20 '12 at 05:00
  • 1
    @Rebecca: Restricting it to a minimum doesn't mean you can't have any. Moreover, if the use of commands promotes consistency, I would imagine the journal would be for it, not against. Is this request normal? Sure, since they (the journal editors) eventually have to take the author document and make it conform to the regular standards, meaning they have to work with the raw code. And, if things are too cluttered with macros and personalized styles, it'll be more difficult to make it conform. – Werner May 20 '12 at 05:13
  • 2
    @Rebecca: The "restrict to the minimum request" is addressed at authors who start each of their papers with the same preamble containing 3000 \newcommands, of which only 50 are relevant to the present paper. – Hendrik Vogt Jun 04 '12 at 11:33
  • @Rebecca: Also try to make your macros unique. Thus, use long names and upper case letters to avoid name clashes (with any custom macros that the publisher or other authors! might be using). Therefore, I'd recommend, \MatrixMultiply or something similar. Most editors will complete a macro for you, so it does not require any more typing. – Aditya Jun 04 '12 at 16:42