55

I'm trying to replicate the dot that my professor uses in his notes for the dot product between vectors but I am having a hard time doing so. This is what it looks like:

enter image description here

I have tried a couple of things. \cdot is too thin

 asdf

and \bullet is too thick

enter image description here

and using \Large with \cdot gives an error. Moreover, after digging through the list of symbols I cannot find a nice medium between \cdot and \bullet.

How can I get a dot closest to the first picture?

  • I use \bullet for dot products. – k-l Mar 22 '17 at 0:13
46

May be you find a better name like \dotp or something like that.

\documentclass{scrartcl}
\usepackage{graphicx}

\makeatletter
\newcommand*\bigcdot{\mathpalette\bigcdot@{.5}}
\newcommand*\bigcdot@[2]{\mathbin{\vcenter{\hbox{\scalebox{#2}{$\m@th#1\bullet$}}}}}
\makeatother

\begin{document}
$a \bigcdot b$
\end{document}

enter image description here

| improve this answer | |
  • 2
    @Manuel (or anyone who understands this), could you clarify a couple of points about your macros? 1. What are the two parameters to \mathpalette? (I only "see" one, unless "bigcdot@" and ".5" are separate in which case I don't understand why \mathpalette is called. 2. What ends up being the first parameter (#1) to bigcdot@, used right before \bullet? – dedded Feb 3 '16 at 13:22
  • 1
    That's how \mathpalette works, the #1 that is passed to \bigcdot@ is the current math style (\displaystyle, \textstyle, \scriptstyle, or \scriptscriptstyle depending on the case).Basically what mathpalette does is taking two arguments, and passing the currentstyle in first place and the second argument after it, so \mathpalete\foo{whatever} ends up being for instance \foo\displaystyle{whatever}, so you have to define \foo accordingly. – Manuel Feb 3 '16 at 14:06
  • @sardoj See The mysteries of \mathpalette – egreg Nov 28 '16 at 21:11
30

Here is a simple trick which needs the amsmath package.

\[
a  \boldsymbol{\cdot} b  =  0
\]

and the result is

enter image description here

| improve this answer | |
  • 1
    Interesting solution; but \bf has been deprecated for 20+ years. Besides, align* serves no purpose here, where equation* would be the correct environment. – egreg Nov 28 '16 at 21:09
  • @egreg: Yeah! I am new to LaTex! Sorry for those! :) I changed the answer a little bit. Let me know if it is OK. :) – Hosein Rahnama Nov 28 '16 at 21:11
  • This answer has a downside that the other one has not: if used within the scope of a \mathversion{bold} (or \boldmath, if you prefer) declaration, the dot cannot become any bolder. I agree, nonetheless, that it is an interesting solution. – GuM Nov 28 '16 at 21:58
11

The following example extends Manuel's answer in two ways:

  • The vertical position is fixed to center the symbol vertically around the math axis as \cdot and \bullet do.
  • The width of the symbol is not the scaled down width of the \bullet (with scaled down side bearings), but a little larger width of \cdot.

The scale and width factor can be configured by macros \bigcdot@scalefactor and \bigcdot@widthfactor.

\documentclass{scrartcl}
\usepackage{color}
\usepackage{graphicx}

\makeatletter
\newcommand*{\bigcdot}{}% Check if undefined
\DeclareRobustCommand*{\bigcdot}{%
  \mathbin{\mathpalette\bigcdot@{}}%
}
\newcommand*{\bigcdot@scalefactor}{.5}
\newcommand*{\bigcdot@widthfactor}{1.15}
\newcommand*{\bigcdot@}[2]{%
  % #1: math style
  % #2: unused
  \sbox0{$#1\vcenter{}$}% math axis
  \sbox2{$#1\cdot\m@th$}%
  \hbox to \bigcdot@widthfactor\wd2{%
    \hfil
    \raise\ht0\hbox{%
      \scalebox{\bigcdot@scalefactor}{%
        \lower\ht0\hbox{$#1\bullet\m@th$}%
      }%
    }%
    \hfil
  }%
}
\makeatother

\begin{document}
\[ a \bigcdot b \]
%
% Comparison with \cdot and \bullet
\[ a \cdot b \bigcdot c \bullet d \]
%
% Different math styles
\[ a \bigcdot b \quad
   \scriptstyle a \bigcdot b \quad
   \scriptscriptstyle a \bigcdot b
\]
%
% Visualization of the math axis
\[
  \sbox0{${-}{\cdot}{\bigcdot}{\bullet}{-}$}
  \rlap{\copy0}%
  \vcenter{%
    \hbox{%
      \textcolor{red}{%
        \vrule width\wd0 height .05pt depth .05pt\relax
      }%
    }%
  }
\]
\end{document}

Result

| improve this answer | |
  • I love it! And some more words to exceed the character limit. – Simon Nov 13 '18 at 19:10
1

I provide not an answer, I demonstrate a caveat of the accepted solution, in hope for a more robust solution.

I used Heiko Oberdiek's solution, which is based on Manuel's solution. It has always worked well with the pdflatex compiler, thanks for that. But a while back I had to use the regular latex compiler, and the dot product then appears as a usual \bullet in the dvi file:

enter image description here

2020-06-08 update. For those interested, several solutions that work with dvi:

\documentclass{article}

\usepackage{lmodern}
\usepackage[T1]{fontenc}

\usepackage{scalefnt}
\usepackage{relsize}

\usepackage{mathtools}

\newcommand{\dotp}{
    \mathop{
        \mathchoice{\vcenter{\hbox{\LARGE$\cdot$}}}
                   {\vcenter{\hbox{\LARGE$\cdot$}}}
                   {\vcenter{\hbox{\normalsize$\cdot$}}}
                   {\vcenter{\hbox{\small$\cdot$}}}
    }
}

\begin{document}
\noindent
d\raisebox{-0.5ex}{\LARGE $\cdot$}b ~  d\parbox[c][0pt][c]{0.5em}{\LARGE$\cdot$}b ~ d$\vcenter{\hbox{\LARGE$\cdot$}}$b ~ d$\vcenter{\hbox{\scalefont{1.75}$\cdot$}}$b ~ d$\vcenter{\hbox{\relsize{+2.5}$\cdot$}}$b ~ d$\vcenter{\hbox{$\mathlarger{\mathlarger{\mathlarger{\mathlarger{\cdot}}}}$}}$b
\begin{align*}
    d\raisebox{-0.5ex}{\LARGE $\cdot$}b\\
    d\parbox[c][0pt][c]{0.5em}{\LARGE$\cdot$}b\\
    d\vcenter{\hbox{\LARGE$\cdot$}}b\\
    d\vcenter{\hbox{\scalefont{1.75}$\cdot$}}b\\
    d\vcenter{\hbox{\relsize{+2.5}$\cdot$}}b\\
    d\vcenter{\hbox{$\mathlarger{\mathlarger{\mathlarger{\mathlarger{\cdot}}}}$}}b
\end{align*}
d $\dotp$ b
\begin{align*}
    d \dotp b\\
    a_{d \dotp b}
\end{align*}
\end{document}

enter image description here

Only the \dotp solution is robust. The others require manual intervention for super- and subscripts for example. You probably do want to insert some negative kerning left and right of the \dotp.

For the record, Hosein's answer to use \boldsymbol{\cdot} is also what the physics package uses. It also works in dvi. Still, I find that dot too small.

| improve this answer | |
  • DVI viewers may not obey PostScript specials, so what you see is not necessarily a faithful representation of the output you'll get after translation into PostScript or PDF. Have you ever tried to look at a TikZ picture in a DVI viewer? – egreg May 21 at 7:59
  • The screenshot was taken from Evince 3.34.1 (a.k.a. Document Viewer). If I convert the dvi to pdf with dvipdfm, then the dot product is displayed correctly in the new pdf file. So, should I assume this is an issue of Evince not obeying to the Postscript specials? – Bart May 21 at 8:13
  • Yes, that's it: Evince just uses xdvi internally when asked to preview a DVI file. – egreg May 21 at 8:38
  • My question then is: can I use Heiko's solution safely when submitting a tex article to a scientific journal? Knowing the journal eventually outputs a pdf (at least for the online version). – Bart May 21 at 9:22
  • Would you submit the DVI file? – egreg May 21 at 9:25

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