1

I am trying to use the symbol \faPlus from the latex package fontawesome and I have some troubles with the spacing.

I declare my symbol with \DeclareMathOperator\plus{\text{\rm\scriptsize\faPlus}} The \text is there because it is not a math command. The \rm is there because there is no "italics" version, and so to avoid problems, the size is just a choice otherwise it is too big.

My problem is that the spacing looks not well. For example, if I put $\star\plus\star$ I get this:

enter image description here

But if I write $(\star)\plus(\star)$ or \langle\star\rangle\plus\langle\star\rangle I get this:

enter image description here

where the symbol is clearly not centered.

Here is the full example:

\documentclass{article}

\usepackage{amsmath}     % for \DeclareMathOperator macro
\usepackage{fontawesome} % for the \faPlus symbol

\DeclareMathOperator{\plus}{\textrm{\rm\scriptsize\faPlus}}

\begin{document}
\[
  \star\plus\star
\]
\[
  (\star)\plus(\star)
\]
\[
  \langle\star\rangle\plus\langle\star\rangle
\]
\end{document}

1 Answer 1

3

You want to use \mathbin, not the \mathop that's used by \DeclareMathOperator, which is for operators such as “sin” or “log”, not for binary operation symbols.

\documentclass{article}

\usepackage{amsmath}     % for math
\usepackage{fontawesome} % for the \faPlus symbol

\newcommand{\plus}{\mathbin{\textnormal{\scriptsize\faPlus}}}

\begin{document}
\[
  \star\plus\star
\]
\[
  (\star)\plus(\star)
\]
\[
  \langle\star\rangle\plus\langle\star\rangle
\]
\end{document}

enter image description here

Please, note that \rm has been deprecated for 30 years.

I'd probably use \scalebox, though, so the symbol also properly scales in subscripts, and add a small space on either side, because the symbol \faPlus has a very tight bounding box.

\documentclass{article}

\usepackage{amsmath}     % for \DeclareMathOperator macro
\usepackage{fontawesome} % for the \faPlus symbol
\usepackage{graphicx}    % for \scalebox

\newcommand{\plus}{\mathbin{\mspace{1mu}\text{\scalebox{0.7}{\faPlus}}\mspace{1mu}}}

\begin{document}

\[
  \star\plus\star_{a\plus b}
\]
\[
  (\star)\plus(\star)
\]
\[
  \langle\star\rangle\plus\langle\star\rangle
\]
\end{document}

enter image description here

3
  • Excellent! Thanks. I noticed that the problem had nothing to do with the symbol, and I edited the question to make it more general. Your answer is perfect. Thanks. Commented Dec 15, 2021 at 22:38
  • @AlejandroDC Please, roll back, possibly also adding the more general question. There are specific parts for the usage of fontawesome in this context, which are addressed to in the answer.
    – egreg
    Commented Dec 15, 2021 at 22:45
  • Rolled back. Thanks. Commented Dec 15, 2021 at 23:24

You must log in to answer this question.

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