Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

redeclare math operator

767 views
Skip to first unread message

Guenter Milde

unread,
Nov 12, 2008, 9:11:56 AM11/12/08
to
If I want to define a new math operator, I can use e.g.

\DeclareMathOperator{\sgn}{sgn}

however, if I want to re-define an existing math operator (e.g. the real
part of a complex number with Re in roman face according to ISO 31), I
have to realise that the command

\reDeclareMathOperator{\Re}{Re}

does not exist.

What is the recommended method in this case?

Günter

Werner Grundlingh

unread,
Nov 12, 2008, 10:30:40 AM11/12/08
to

Here's an attempt at getting around your 'problem':

\documentclass{article}

\usepackage{amsmath}

\DeclareMathOperator{\newRe}{Re}

\begin{document}

$\Re \ell$

\let\Re=\newRe

$\Re \ell$

\end{document}

Werner

Mariano Suárez-Alvarez

unread,
Nov 12, 2008, 10:51:25 AM11/12/08
to

I do not know if this is recommended, but one way
to do this is to `undefine' \Re:

\documentclass{article}
\usepackage{amsmath}
\let\Re\undefined
\DeclareMathOperator{\Re}{Re}
\begin{document}
$\Re z$
\end{document}

-- m

Lars Madsen

unread,
Nov 12, 2008, 1:50:00 PM11/12/08
to

\renewcommand\Re{\opratorname{Re}}

hmm, might be an idea to a a \reDeclareMathOperator to mathtools

--

/daleif (remove RTFSIGNATURE from email address)

LaTeX FAQ: http://www.tex.ac.uk/faq
LaTeX book: http://www.imf.au.dk/system/latex/bog/ (in Danish)
Remember to post minimal examples, see URL below
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=minxampl
http://www.minimalbeispiel.de/mini-en.html

Dan Luecking

unread,
Nov 12, 2008, 2:58:59 PM11/12/08
to
On 12 Nov 2008 14:11:56 GMT, Guenter Milde <mi...@users.berlios.de>
wrote:

>If I want to define a new math operator, I can use e.g.
>
> \DeclareMathOperator{\sgn}{sgn}
>
>however, if I want to re-define an existing math operator (e.g. the real
>part of a complex number with Re in roman face according to ISO 31), I
>have to realise that the command
>
> \reDeclareMathOperator{\Re}{Re}
>
>does not exist.

\renewcommand{\Re}{\operatorname{Re}}

The difference between defining a command to be
\operatorname{something} and defining it by
\DeclareMathOperator, is one level of macro
expansion. With the above definitions,
\Re --> operatorname{Re}
--> [internal code for \operatorname{Re}]
\sgn --> [internal code for \operatorname{sgn}]

This is documented (amsldoc.pdf section 5, page 14).

Dan
To reply by email, change LookInSig to luecking

Guenter Milde

unread,
Nov 13, 2008, 7:04:19 AM11/13/08
to
Lars Madsen <dal...@RTFSIGNATUREimf.au.dk> schrieb:

> Guenter Milde wrote:
>> If I want to define a new math operator, I can use e.g.

>> \DeclareMathOperator{\sgn}{sgn}

>> however, if I want to re-define an existing math operator

...


>> \reDeclareMathOperator{\Re}{Re}
>> does not exist.

> \renewcommand\Re{\operatorname{Re}}

> hmm, might be an idea to add a \reDeclareMathOperator to mathtools

After looking at clsguide.pdf, I'd recommend \ReDeclareMathOperator as name.

Looking at the other replies, I would suggest something like

\newcommand{\ReDeclareMathOperator}[1]{
\let \csname #1\endcsname \undefined
\DeclareMathOperator{\csname #1\endcsname}{#1}
}


Thanks to all posters,

Günter

Robin Fairbairns

unread,
Nov 13, 2008, 7:42:35 AM11/13/08
to
Guenter Milde <mi...@users.berlios.de> writes:
>Looking at the other replies, I would suggest something like
>
>\newcommand{\ReDeclareMathOperator}[1]{
> \let \csname #1\endcsname \undefined
> \DeclareMathOperator{\csname #1\endcsname}{#1}
>}

\newcommand{\ReDeclareMathOperator}[1]{%
\expandafter\let \csname #1\endcsname \undefined
\DeclareMathOperator{\csname #1\endcsname}%
}

would be a better bet. (note the comment marks. probably not really
necessary since the command is generally used in the preamble, but
good practice nevertheless.)
--
Robin Fairbairns, Cambridge

Donald Arseneau

unread,
Nov 13, 2008, 7:07:22 PM11/13/08
to
On Nov 12, 6:11 am, Guenter Milde <mi...@users.berlios.de> wrote:

> however, if I want to re-define an existing math operator [but]


>
> \reDeclareMathOperator{\Re}{Re}
>
> does not exist.

Hold on. The command is "DeclareMathOperator", not
"NewMathOperator". It should not require a previously-undefined
command name, but should work like \DeclareRobustCommand.
File a bug report. (Fat chance it will change though.)

Donald Arseneau as...@triumf.ca

Dan Luecking

unread,
Nov 14, 2008, 3:47:07 PM11/14/08
to

amsopn.sty actually *uses* \DeclareRobustCommand, but
explicitly checks with \@ifdefinable before doing so.
One need only remove that (from the definition of
\@declmathop).

Alternatively, mathtools (or some package that implements
this) should use the new/renew naming system.

Personally, I always use \re and \im instead of \Re
and \Im. Easier to type, doesn't invoke this error,
and leaves the originals available. I'm a comlex
analyst and have to type them a *lot*.

Lars Madsen

unread,
Nov 14, 2008, 5:53:49 PM11/14/08
to

I'll keep following this thread to see what you guys end up
recommending, then I'll add that to mathtolls.


/daleif

0 new messages