10

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?

11

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

enter image description here

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}
| improve this answer | |
  • 1
    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
  • 1
    @bp2017: Please correct the title of the question. Both options are now provided. – Peter Grill Aug 22 '17 at 4:31
7

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}

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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