2

This is basically a follow-up on this question: How can I reduce the gap between left and right of \cdot with a macro?

The aim is to reduce spacing around \cdot. The accepted answer proposes to define a new cdot command as an ordinary math operator with: \DeclareMathSymbol{\mdot}{\mathord}{symbols}{"01} However, this does not work well with parentheses.

MWE:

\documentclass[a4paper]{article}
\DeclareMathSymbol{\mdot}{\mathord}{symbols}{"01} % shortens space

\begin{document}
    \noindent
    $a = b \cdot c$ This works well, but spacing is too big\\
    $a = b \cdot (c)$ Idem with simple parentheses ()\\ 
    $a = b \cdot \left(c\right)$ Idem using \texttt{\textbackslash{}left( \textbackslash{}right)}\\ 
    $a = b \mdot c$ This too, with compact spacing\\
    $a = b \mdot (c)$ This does not, with simple parentheses ()\\   
    $a = b \mdot \left(c\right)$ This does not, using \texttt{\textbackslash{}left( \textbackslash{}right)}\\   
    
\end{document}

Which gives:

enter image description here

As you can see the two lowest examples are not working properly, with an asymmetrical spacing between the different elements:

enter image description here

with a slightly larger space on the c-side for the upper example, and a largely wider space on the (c)-side for the lower example.


How to obtain appropriate spacing? I.e. same spacing between cdot and opening parenthesis as between b and cdot.

Also, if you could tell me why this happens, I am really curious.

1

1 Answer 1

1

You shouldn't define \mdot as an ordinary symbol.

If you plan to use it only as infix, you can remove the spacing inserted by default and add some to your choice.

\documentclass[a4paper]{article}

\newcommand{\reducemedmuskip}{%
  \nonscript\mskip -\medmuskip % remove the standard spacing
  \nonscript\mkern 0.5\medmuskip % add some (non flexible)
}

\newcommand{\mdot}{%
  \reducemedmuskip
  \cdot
  \reducemedmuskip
}

\begin{document}

$a = b \cdot c$ This works well, but spacing is too big

$a = b \cdot (c)$ Idem with simple parentheses ()

$a = b \cdot \left(c\right)$ Idem using \texttt{\string\left( \string\right)}

$a = b \mdot c$ This too, with compact spacing

$a = b \mdot (c)$ This too, with simple parentheses ()

$a = b \mdot \left(c\right)$ This too, using \texttt{\string\left( \string\right)}

\fboxsep=0pt \fboxrule=0.1pt
\fbox{$($}
    
\end{document}

I added a picture of the bounding box for the parenthesis to show it has some sidebearing on its right.

Note, however, that you shouldn't be using \left and \right in those cases.

enter image description here

2
  • "You shouldn't define \mdot as an ordinary symbol." Could you please elaborate why this is bad practice? Is it just your opinion or is it documented somewhere? (I do not intend to be sarcastic / aggressive, but I would appreciate some further justification / sourcing) Thank you for your answer, and yes, I realised about the parenthesis' bounding box later... :'(
    – mranvick
    Commented May 20 at 12:37
  • @mranvick If you define it as an ordinary symbol, TeX automatic insertion of spaces will fail, which is exactly the problem you're experiencing. In the linked thread, the problem was about a very specific situation, where defining the symbol as ordinary doesn't get in the way.
    – egreg
    Commented May 20 at 13:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .