[Tex/LaTex] How to add a superscript in text mode

formattingtext manipulation

I'm writing about C* algebras and I'm trying to write *-strings efficiently. I managed to define C* like this:

\newcommand{\Cstar}{C\textsuperscript{*}}

While I have to invoke it as \Cstar{} to prevent it from sticking to the next word, I have had trouble writing a command to add * to any word (such as morphism or isometry). I tried doing this:

\newcommand{\star}[1]{#1\textsuperscript{*}}

without luck.
Is this possible, and should I be doing this with LaTex, or is it something I should be doing with my editor's macros?

Best Answer

In my opinion, the asterisk should be always in the upright font, independently of the context. Besides, \textsuperscript{*} would place the asterisk too high, see the last line in the image below.

Also C* should probably always appear upright, but you may decide otherwise.

Redefining \star could be safe in your context, but be aware that \star is the name of a symbol, namely ⋆, and you may want to save it under another name in case you decide to use it.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\Star}[1]{#1\ensuremath{^*}\kern-\scriptspace}
\newcommand{\CStar}{\Star{\ensuremath{\mathrm{C}}}}

\begin{document}

% the commands in upright text
We deal with \CStar-algebras, with \Star{morphisms}
and \Star{isometries}.

% the commands in italics context, such as theorems
\textit{We deal with \CStar-algebras, with \Star{morphisms}
and \Star{isometries}.}

% with \textsuperscript{*}
\textit{We deal with C\textsuperscript{*}-algebras, with morphisms\textsuperscript{*}
and isometries\textsuperscript{*}.}

\end{document}

enter image description here

Related Question