1

I wrote the following macro, that prints C_0^*. But I wanted to push the position of * little high, hence used strut. I also wanted optional argument i.e. C^* and C_0^* can be handled by same macro. So, I defined the following:

\documentclass{article}
\newcommand{\objstylesf}[1]{\ensuremath{\mathsf{#1}}}
\newcommand{\chcpcti}[1][]{
    \ifx&#1&
        \objstylesf{C}\strut^{\hspace{-.8pt}*}
    \else
        \objstylesf{C}_{#1}\strut^{\hspace{-5pt}*}
    \fi
}
\begin{document}
$\chcpcti$
$\chcpcti[0]$
$\chcpcti[1]$
$\chcpcti[\ell+1]$
\end{document}

For first three, it is working fine. However, for the last one, the * is shifted quite a lot. Anything hardcoded (such as -17pt) hampers the others.

Precisely, I need an input length sensitive optional argument macro definition. Can anyone please help me? I would like to keep the strut there. Or some other way of handling the superscript position might also be fine. But I don't like the default superscript position in this case.

1 Answer 1

2

You want rather to raise the asterisk

\documentclass{article}

\newcommand{\objstylesf}[1]{\ensuremath{\mathsf{#1}}}

\newcommand{\raisedasterisk}{\mathpalette\raiseexponent{*}}
\newcommand{\raiseexponent}[2]{\raisebox{.6\height}{$#1#2$}}

\newcommand{\chcpcti}[1][]{%
  \objstylesf{C}_{#1}^{\raisedasterisk}
}

\begin{document}
$\chcpcti$
$\chcpcti[0]$
$\chcpcti[1]$
$\chcpcti[\ell+1]$
\qquad
$\mathsf{C}^{*}$
$\mathsf{C}^{*}_{0}$
$\mathsf{C}^{*}_{1}$
$\mathsf{C}^{*}_{\ell+1}$
\end{document}

enter image description here

You must log in to answer this question.

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