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.

I want to define \ext to behave exactly like \lim.

I tried \newcommand{\ext}{{\mathrm{ext}}\,} but that doesn't behave exactly like \lim.

share|improve this question
    
possible duplicate of Command for argmin or argmax? –  Caramdir Mar 15 '11 at 19:41
add comment

4 Answers 4

up vote 5 down vote accepted

If you use amsmath, which is recommendable for math texts in any way, a similar definition to \lim is

\def\ext{\qopname\relax m{ext}}

since amsmath, specifically amsopn.sty, defines:

\def\lim{\qopname\relax m{lim}}
share|improve this answer
1  
Why not use \operatorname? I think it is a robust command. –  Rushavski Mar 16 '11 at 0:26
    
@Rushavski: I posted this solution because \ext shall behave exactly like \lim, not a bit different or even better. So I suggested the original definition of \lim in amsmath. –  Stefan Kottwitz Mar 16 '11 at 6:39
    
Curious: In what way would it behave different if I would use \operatorname? –  Albert Mar 16 '11 at 9:45
2  
Then you should have suggested \DeclareMathOperator*\ext{ext} which will behave exactly like \lim and has the advantage of not using internal amsmath macros. (The one difference is that there will be some local assignments that are totally irrelevant inside the \mathop for this particular example. Cf. \DeclareMathOperator*\good{foo-bar} \def\bad{\qopname\relax m{foo-bar}}.) –  TH. Mar 16 '11 at 19:22
    
@TH: Maybe, I just focused on exactly like. So I showed how to do it in exactly the same way and where it can be found, straightforward. Hope that adds something (general practice in copying macro behavior), otherwise the link to the "duplicate" would have been sufficient. Give me downvotes for it. :-) I upvoted Gonzalos solution because it is good. –  Stefan Kottwitz Mar 16 '11 at 20:55
add comment

As an alternative to \DeclareMathOperator, there is also \mathop to be used with \newcommand. For example:

\newcommand{\ext}{\mathop{\mathrm{ext}}
share|improve this answer
    
\mathop is a tex primitive, so this definition is a hybrid, non-latexy. if you look into the documentatin for amsopn.sty (texdoc mathopn) you will see that \mathop is used there for the "internal" definitions, but command naming quickly shifts into the latex realm. you will also see that the choice of commands is stated to be governed by the amount of memory they use. remember, amsmath and its kin were written when memory use still mattered. –  barbara beeton Mar 16 '11 at 13:25
add comment

Use \DeclareMathOperator or its starred form (if the operator should take limits):

\usepackage{amsmath}

% \DeclareMathOperator{<command>}{<text>}
% if the operator shouldn't take limits
\DeclareMathOperator\ext{ext}
% if the operator should take limits
% \DeclareMathOperator*\ext{ext}
share|improve this answer
    
The stared version produces something that behaves exactly like \lim. –  TH. Mar 16 '11 at 19:23
add comment

try

\makeatletter
\def\ext{\mathop{\operator@font ext}}
\makeatother
share|improve this answer
    
Does that do limits correctly? –  Caramdir Mar 15 '11 at 19:44
    
sure, why should it not? –  Herbert Mar 15 '11 at 20:12
    
Sorry, the command name sort of implies that it only sets the font. It seems to work as intended though. –  Caramdir Mar 16 '11 at 3:59
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.