I want to type \text{coker} in normal font but not italic font in thm enviroment like \ker [duplicate]

I have a question about \text{}.

For convenience, I define many new commands, for example \def\im{\text{Im}}, \def\coker{\text{coker}}, etc.. I expect my new commands work like \ker, and really work that way in usual situation. But, in italic font enviroments(thm, prop, etc..), \im and \coker typed in italic font. I want they type in normal font like \ker.

Is there any way to solve this problem.

marked as duplicate by Loop Space, egreg fonts StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Sep 5 '16 at 9:44

• Since ker is an operator, \coker should be defined using \DeclareMathOperator{\coker}{coker}, in my point of view. This will use upright letters – user31729 Sep 5 '16 at 9:24
• Never ever use \text for this, try using it in an italic context, and you'll see why it is so wrong. Use the solutions either linked to or provided by others. – daleif Sep 5 '16 at 10:01

Use this in your preamble (I suppose you already load amsmath or mathtools):

     \DeclareMathOperator\coker{coker}


or

     \DeclareMathOperator\coker{Coker}


if you write in French (and possibly some other languages).

You should consider using amsmath's

\DeclareMathOperator{\coker}{coker}


in the first place, which handles this for you.