In my document, I'm often setting upper case words and abbreviations in small caps because it avoids breaking the flow (which upper case words does). Also, many words (like CUDA, for instance) are also entered as commands instead of directly as text.
Up to this point I have manually set these words in small caps where appropriate (like \textsc{\cuda}), but this becomes unnecessarily repetitive. What I would like to be able to do is to define a command like \cuda which prints CUDA in small caps where the text "mode" is normal roman, and sets CUDA in upper cases if the text mode is italics. The reason for doing this is the font I'm using doesn't support small caps in italics.
Hence I would like to be able to detect which text "mode" is currently in use, and act accordingly.
I've included a minimal example below to illustrate my point:
\documentclass{article}
\usepackage{textcase}
\newcommand{\cudaString}{CUDA}
\newcommand{\cuda}{\textsc{\MakeTextLowercase{\cudaString}}}
\begin{document}
Set \cuda in small caps here,
\itshape but do not set \cuda in small caps here.
\end{document}

\newcommand{\cuda}{\textsc{CUDA}}, as it will appear in all caps anyway; it's probably\textsc{cuda}, isn't it? – egreg Oct 15 '11 at 19:25\MakeTextLowercaseand I wrote the example code just from memory. – gablin Oct 17 '11 at 08:51\MakeUppercasemight have problems. – egreg Oct 17 '11 at 08:57