Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can I write the following code more concisely, without an ifcase statement? Please assume the command will only be called with integer arguments between 1 and 8, inclusive. Sorry for asking such a basic question---I'm new to macros.

\renewcommand{\@fnsymbol}[1]{\ifcase#1\or ^0 \or ^1\or ^2\or
                 ^3\or ^4\or ^5\or ^6\or ^7 \or ^8 \fi\relax}
share|improve this question
    
Do you mean something like \newcommand{\mysuperscript}[1]{$^{#1}$}? Do you plan on using this in text mode or in math mode? –  Neo Jan 23 '13 at 3:38
2  
LaTeX provides \textsuperscript{<stuff>} which "returns its argument as a superscript." –  Werner Jan 23 '13 at 4:00
    
Welcome to TeX.SE. It might be helpful if you included some details as to exactly what you are trying to accomplish as there might be an easier way to do what you want. Also, for the way you have specd it, what do you want to happen if the parameter is not a single digit? –  Peter Grill Jan 23 '13 at 4:15
    
Thanks, here's some context: I'm using a .cls file that defines a custom footer symbol. I don't like those footer symbols though, so I'm redefining the command (@fnsymbol) that generates the footer symbols. My command appears above, in the question. It works, but seems ridiculous to use "ifcase", just to write a command that returns its argument as a superscript. So I'm looking for a better way to duplicate the functionality of the above command. –  Jeff Jan 23 '13 at 4:20
1  
How about including a minimal working example (MWE) which would provide even more context to your current discussion? –  Werner Jan 23 '13 at 4:43
show 3 more comments

1 Answer

up vote 2 down vote accepted
\let\@fnsymbol^

Is probably as concise as you could get as an answer to the question, although given the command name you used, you need a bit more as it needs to work with count registers not just literal digits \@fnsymbol{33} would work but not \@fnsymbol\c@footnote and it needs to work out of math mode so you need

\def\@fnsymbol#1{\ensuremath{^{\number#1}}}

But \textsuperscript is a better option as it uses the text fonts not the math ones.

share|improve this answer
    
Awesome! Thanks. –  Jeff Jan 25 '13 at 0:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.