2

I need to use several math operations between the same kind of objects and would like them to be of matching sizes. E.g. I have two different operations: $\otimes$ and $\ast$. But the asterisk is much smaller than the otimes symbol and so equations using it take up less space. I would like them both to have the same width. Is there a clean way to achieve this?

I would also like to have operator (\mathop) versions of the same operations, and I have the same question in that case.

Here is a MWE:

\documentclass[12pt,a4paper]{amsart}
\newcommand{\pp}{\mathbin{\ast}}
\newcommand{\qq}{\mathbin{\otimes}}

\begin{document}
inline:

$A \pp B$

$A \qq B$

display:
\[A \pp B\]
\[A \qq B\]

\end{document}

which produces:

enter image description here

Rui
  • 115

1 Answers1

4

Measure \otimes and set * in a box of that width. Using \mathpalette allows the symbol to change size in subscripts, as shown.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\qq}{\otimes} % just an alias, this is a binary operation
\makeatletter
\newcommand{\pp}{% equalize the width of * to \otimes
  \mathbin{\mathpalette\eq@to@otimes{*}}%
}
\newcommand{\eq@to@otimes}[2]{%
  \begingroup
  \settowidth\dimen@{$\m@th#1\otimes$}% measure \otimes in the current style
  \makebox[\dimen@]{$\m@th#1#2$}%
  \endgroup
}
\makeatother

\begin{document}

inline:

$A \pp B_{x\pp y}$

$A \qq B_{x\qq y}$

display:
\[A \pp B\]
\[A \qq B\]

\end{document}

enter image description here

If you instead want to make * bigger, then

\documentclass{article}
\usepackage{amsmath,graphicx}

\newcommand{\qq}{\otimes} % just an alias, this is a binary operation
\makeatletter
\newcommand{\pp}{% equalize the size of * to \otimes
  \mathbin{\mathpalette\eq@to@otimes{*}}%
}
\newcommand{\eq@to@otimes}[2]{%
  \begingroup
  \settowidth\dimen@{$\m@th#1\otimes$}% measure \otimes in the current style
  \vcenter{\hbox{\resizebox{\dimen@}{!}{$\m@th#1#2$}}}%
  \endgroup
}
\makeatother

\begin{document}

inline:

$A \pp B_{x\pp y}$

$A \qq B_{x\qq y}$

display:
\[A \pp B\]
\[A \qq B\]

\end{document}

enter image description here

I offer also a generic version of the resizing approach.

\documentclass{article}
\usepackage{amsmath,graphicx}

\newcommand{\qq}{\otimes} % just an alias, this is a binary operation

\makeatletter
% a generic command to do the equalization; \equalizeto takes three arguments:
% #1: the symbol to equalize
% #2: the base symbol that gives the width
% #3: the type of the constructed symbol
\newcommand{\equalizeto}[3]{%
  #3{\mathpalette\equalize@to{{#1}{#2}}}%
}
\newcommand{\equalize@to}[2]{\equalize@@to#1#2}
\newcommand{\equalize@@to}[3]{%
  \begingroup
  \settowidth\dimen@{$\m@th#1#3$}% measure #3 in the current style
  \vcenter{\hbox{\resizebox{\dimen@}{!}{$\m@th#1#2$}}}%
  \endgroup
}
\makeatother

\newcommand{\pp}{% equalize the size of * to \otimes
  \equalizeto{*}{\otimes}{\mathbin}%
}

\begin{document}

inline:

$A \pp B_{x\pp y}$

$A \qq B_{x\qq y}$

display:
\[A \pp B\]
\[A \qq B\]

\end{document}

For a big operator, see How to create my own math operator with limits?

egreg
  • 1,121,712