How to make \cdot operator same width as / (division slash) operator and vice versa

This is the code I use:

\begin{aligned}
&a\cdot{}a\\
&a/a
\end{aligned}


this is the output I get (red line is to emphasize unequal alignment):

How can I make cdot's and slash's widths match?

You can use a \makebox to create a box as wide as the slash:

Code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{calc}

\newcommand*{\mycdot}{\makebox[\widthof{/}]{$\cdot$}}
\newcommand*{\myslash}{\makebox[\widthof{${}\cdot{}$}]{{}/{}}}

\begin{document}\noindent
\verb|\cdot| same width as slash:
\begin{align*}
x &= a \mycdot a \\
x &= a / a
\end{align*}
Slash same width as \verb|\cdot|:
\begin{align*}
x &= a \cdot a \\
x &= a \myslash a
\end{align*}
\end{document}

• You can get it to work across all math styles with \usepackage{scalerel} \newcommand*{\mycdot}{\ThisStyle{\makebox[\widthof{$\SavedStyle/$}]{$\SavedStyle\cdot$}}} – Steven B. Segletes Aug 22 '17 at 1:43
• @bp2017: Please correct the title of the question. Both options are now provided. – Peter Grill Aug 22 '17 at 4:31

This scales in subscripts and superscripts and allows for different widths based on other operators.

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand\wslash[1][\cdot]{\mathbin{\mathpalette\w@slash{#1}}}
\newcommand\w@slash[2]{%
\settowidth\dimen@{$\m@th#1#2$}%
\makebox[\dimen@]{$\m@th#1/$}%
}
\makeatother

\begin{document}

\begin{align}
&a\cdot a\\
&a\wslash a \\
&a+a\\
&a\wslash[+]a\\
&x_{a\cdot a}\\
&x_{a\wslash a}
\end{align}

\end{document}


• @bp2017 I'm not sure what you're referring to. – egreg Oct 25 '17 at 6:17