5

I need a functional composition operator. I find \circ too big for it, so I've declared a math operator (within the amsart documentclass) as \scriptstyle\circ instead; the size is exactly what I would like to have but the placement seems wrong now, it is too low.

enter image description here

Does anybody know a simple way (without too many \raises and boxes) to place the symbol slightly higher?

9

Try with defining a new command \smallcirc

\newcommand{\smallcirc}{\mathbin{\text{\raisebox{0.2ex}{\scalebox{0.6}{$\circ$}}}}}

MWE:

\documentclass{amsart}
\usepackage{graphicx}
\newcommand{\smallcirc}{\mathbin{\text{\raisebox{0.2ex}{\scalebox{0.6}{$\circ$}}}}}

\begin{document}
\[
 f\circ\alpha \quad\text{vs}\quad f\smallcirc\alpha
\]

\[
 f \smallcirc \alpha_{f \smallcirc \alpha_{f \smallcirc \alpha}}
\]
\end{document}  

enter image description here

Note that, defining the command with a \scripstyle in it, it's not a good idea since if you have that symbol in a sub/superscript, its size will remain the same as the one in display style.

  • Thanks a lot! I preferred this one since it is more concise, more customizable, and works without graphicx too :D – მამუკა ჯიბლაძე Mar 19 '15 at 10:50
  • Oops maybe it still needs graphicx - I load tikz and that I think loads graphicx... Well anyway – მამუკა ჯიბლაძე Mar 19 '15 at 10:52
  • @მამუკაჯიბლაძე You're welcome. And, yes, tikz loads graphicx. – karlkoeller Mar 19 '15 at 10:54
4

Here's an answer that will work even in sub/superscript:

\documentclass{article}
\usepackage{amsmath}

\newcommand{\centeredcirc}[1]{\vcenter{\hbox{$#1\circ$}}}
\newcommand{\smallcirc}{\mathbin{\mathchoice{\centeredcirc\scriptstyle}{\centeredcirc\scriptstyle}{\centeredcirc\scriptscriptstyle}{\centeredcirc\scriptscriptstyle}}}

\begin{document}

    \[ f\circ\alpha \quad\text{vs}\quad f\smallcirc\alpha \]
    \[ g^{f\circ\alpha} \quad\text{vs}\quad g^{f\smallcirc\alpha} \]

\end{document}

enter image description here

1

The following example uses the scaling method of karlkoeller's answer and enhances it in several ways:

  • The new symbol is correctly vertically centered around the math axis.
  • The side bearings are restored (heuristic).
  • The scaling diminishes the line width. This is compensated by additionally stroking the symbol with an estimated line width to compensate the scaling.

Full example:

\documentclass{article}
\usepackage{amsmath}
\usepackage{color}
\usepackage{graphicx}
\usepackage{pdfrender}

\makeatletter
\newcommand*{\smallcirc}{%
  \mathbin{%
    \mathpalette\@smallcirc{}%
  }%
}
\newcommand*{\smallcircscale}{.6}
\newcommand*{\@smallcirc}[2]{%
  % #1: math style
  % #2: unused
  \sbox0{$#1\vcenter{}$}% \ht0: math axis
  \sbox2{$#1\circ\m@th$}%
  % Calculate symbol width with original side bearings
  % (in the hope, the symbol height is correct).
  % The radius is estimated as symbol height minus math axis
  % (\ht2 - \ht0).
  \dimen@=\dimexpr
    \smallcircscale\dimexpr2\ht2-2\ht0\relax
    + \wd2-2\ht2+2\ht0
  \relax
  % Estimated line thickness from symbol height
  \dimen2=.1\ht2
  % Calculate line width for rendering mode "Stroke".
  \dimen2=\dimexpr\dimen2 - \smallcircscale\dimen2\relax
  \raise\ht0\hbox to \dimen@{%
    \hfil
    \textpdfrender{
      TextRenderingMode=FillStroke,
      LineWidth=\dimen2,
    }{%
      \scalebox{\smallcircscale}{%
        \lower\ht0\hbox{%
          $#1\circ\m@th$%
        }%
      }%
    }%
    \hfil
  }%
}
\makeatother

\begin{document}
\begin{align*}
  \text{styles: }&
  f \smallcirc \alpha \quad
  \scriptstyle f \smallcirc \alpha \quad
  \scriptscriptstyle f \smallcirc \alpha
\\
  \text{{\fontfamily{lmvtt}\selectfont\textbackslash circ}: }&
  f \circ \alpha \quad
  \scriptstyle f \circ \alpha \quad
  \scriptscriptstyle f \circ \alpha
\\
  \text{axis: }&
  \sbox0{${-}{\smallcirc}{-}$}
  \rlap{\copy0}%
  \vcenter{%
    \hbox{%
      \textcolor{red}{%
        \vrule width\wd0 height .05pt depth .05pt\relax
      }%
    }%
  }
\end{align*}
\end{document}

Result

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.