82

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?

sardoj
  • 923

4 Answers4

61

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

Manuel
  • 27,118
  • 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 03 '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 03 '16 at 14:06
60

Here is a simple trick which needs the amsmath package.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation} a \boldsymbol{\cdot} b = 0 \end{equation}

\end{document}

and the result is

enter image description here

  • 3
    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
14

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

Heiko Oberdiek
  • 271,626
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.

Bart
  • 397
  • 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 '20 at 07: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 '20 at 08:13
  • Yes, that's it: Evince just uses xdvi internally when asked to preview a DVI file. – egreg May 21 '20 at 08: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 '20 at 09:22
  • Would you submit the DVI file? – egreg May 21 '20 at 09:25
  • No, I have to submit the built files (tex and images). They post a pdf online, so that should go fine then, and the online version is most important. I guess my question is: does it make sense to use a dvi for printing? If not, the printed version should also go fine. – Bart May 21 '20 at 09:57
  • This question comes down to "Is \scalebox reliable?" It is an idiosyncratic add-on. However, \scalebox isn't needed! It is possible to specify the font size scaled (and there are probably several questions/answers on that topic already). – Donald Arseneau May 21 '20 at 11:16
  • I tried several solutions with the packages relsize and scalefnt. The difficulty is to get the \bullet vertically centered and to scale a math font properly. Anyway, a hint to a few commands or packages would be useful. – Bart May 21 '20 at 13:11