[Tex/LaTex] Scale single symbol in math mode

fontsmath-modescalingsymbols

I am using the Baskervald font with KP fonts for the maths font. It is very nice, but it needs some manual fine-tuning.

For example, the \star command gives an (oversized) italic star, which should not happen. I figured I just redefine \star as

\renewcommand{\star}{\scalebox{.5}{\bigstar}}

but this doesn't seem to work (\star is used in display mode).

What is the correct command to resize a particular command in math mode?

Minimal example:

\documentclass{article}
\usepackage{amssymb,amsmath}
\usepackage{kpfonts,baskervald}

\begin{document}
\begin{align*}
  f\star g=fg+\hbar\{f,g\}\\
  f\bigstar g=fg+\hbar\{f,g\}
\end{align*}
\end{document}

\star is slanted, but \bigstar is not.

Best Answer

In this case, I use \scalerel to replace the definition of \star with a \bigstar that is scaled to the same vertical footprint as the italic \star. I tried putting a \mathrel around it, but the spacing to the f seemed odd, so I took it out.

The nice thing about this scalerel approach is that it will work in smaller math styles, as well, as shown below.

\documentclass{article}
\usepackage{amssymb,amsmath}
\usepackage{kpfonts,baskervald}
\usepackage{scalerel}
\let\savestar\star
\renewcommand\star{{\scalerel*{\bigstar}{\savestar}}}
\begin{document}
\begin{align*}
  f\star g=fg+\hbar\{f,g\}\\
 \scriptstyle f\star g=fg+\hbar\{f,g\}
\end{align*}
\end{document}

enter image description here

as I said in my initial comment, loading just baskervald does not give an italic star. Rather, the problem originates in the kpfonts package. I get the same erroneous behavior loading just the kpfonts package. Alternately, if I try to load baskervald first, I get an option clash, which I presume is kpfonts complaining that baskervald already took control of \star and it wants it too.