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.

Let's say I want to write N^{eT}, but have N^e as a predefined command \Ne. Thus, I want to append the character T to the superscript of \Ne. Is this possible?

(Note that I don't want to write {\Ne}^T, since that will result in the T being one level above the e. This was adressed in Trick LaTeX into doing double superscripts by the way)

share|improve this question
1  
It may help to explain how you intend to use the macro. Something along the lines of \def\Ne#1{$N^{e#1}$} is acceptable in your case? (usage: \Ne T) –  guillem Apr 19 '12 at 14:46
1  
What about using $\Ne{}^T$ (maybe putting it into a box to prevent a break between e and T)? –  Stephen Apr 19 '12 at 18:08
    
Haha, I actually didn't know that was possible, Stephen. Thanks! –  andreasdr Apr 19 '12 at 19:54
    
Similar question has been answered some time ago: tex.stackexchange.com/questions/33261/… –  amorua Apr 19 '12 at 20:45

3 Answers 3

up vote 14 down vote accepted

Or what about an empty optional argument?

\newcommand*\Ne[1][]{N^{e#1}}

Which you can use

$\Ne$ or $\Ne[T]$
share|improve this answer
    
Accepted for conciseness. Thanks to all responders! –  andreasdr Apr 19 '12 at 15:18
    
By the way, what does the asterisk after "\newcommand" do? –  andreasdr Apr 19 '12 at 15:45
2  
@andreasdr: The starred variant of \newcommand removes the capability to include lengthy arguments (like paragraphs). Surely, since your superscripts will only contain characters (not paragraphs), using \newcommand* is appropriate. –  Werner Apr 19 '12 at 16:12
    
@andreasdr: A more detailed explanation of \newcommand* can be found at tex.stackexchange.com/questions/1050/… –  Jake Apr 24 '12 at 10:40

I would define \Ne in the following way:

\newcommand{\Ne}{\ensuremath{N^e\vphantom{N}}}

This ensures that any following superscripts start at the same height as regular superscripts to N, but also trick TeX in thinking that it's not doubling a superscript:

enter image description here

\documentclass{article}
\newcommand{\Ne}{\ensuremath{N^e\vphantom{N}}}
\begin{document}
\Ne\ $\Ne^T$\ $N^{eT}$
\end{document}

Note that this will not work properly for subscripts, since the placement will be off. It would require more effort to make that work.

share|improve this answer

Here is a "clever hack" inspired by (read: shamelessly copied from) the definition of math prime:

\documentclass{article}

\makeatletter
\def\Ne{N^\bgroup\e@s}
\def\e@s{%
  e\futurelet\@let@token\e@@s}
\def\e@@s{%
  \ifx^\@let@token
     \expandafter\expandafter\expandafter\e@@@s
  \else
     \egroup
  \fi}
\def\e@@@s#1#2{#2\egroup}
\makeatother

\begin{document}
\[
\Ne^T \Ne^T_5
\]
\end{document}

You can do \Ne^{}_{} but not \Ne_{}^{}, otherwise the positioning is exactly as N^{}_{}

share|improve this answer

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.