# How can I renew the macro "\log" (from "log" to "\ell og")?

How can I renew the macro "\log" (from "log" to "\ell og")?

Default function \log in line 1

I use renewcommand for \log:

\renewcommand{\log}{\ell\text{og }}


That shows in line 2.

But I want to function \log in line 3:

    Default: \hspace{0.5 cm} $\log_M x^N = N \log_M x$ \\
\renewcommand{\log}{\ell\text{og }}
That show: $\log_M x^N = N \log_M x$ \\
\renewcommand{\log}{\ell\text{og}}
I want: \hspace{0.625 cm} $\log_M\hspace{2 pt}x^N = N \log_M\hspace{2 pt}x$ \\

• \mathop{\ell\mathrm{og}} but why would you do that?? May 17 at 15:09
• Without trying things, in \text{og } it looks like you are adding the space you want to remove(?). Also, see this old answer. May 17 at 15:09
• People want to typeset all sort of weird things. Generally speaking though, if you submit to journals etc. they would expect the "standard" (i.e. default) styles && the people making the default had researched lots about good typography. May 17 at 15:09
• Thank you every one :D May 17 at 15:16
• Never ever use \text for things like this. See what happens if you issue \itshape before That show... May 17 at 15:16

## 2 Answers

The standard macro \log is defined as a "math operator". You first need to undefine the existing macro and then recreate it via, e.g., a \DeclareMathOperator instruction.

\documentclass{article} % or some other suitable doc. class
\usepackage{amsmath} % for "\DeclareMathOperator" macro
\let\log\relax  % first, undefine the existing macro
\DeclareMathOperator{\log}{\ell og} % now, (re)define it

\begin{document}
$\log_M x^N = N \log_M x$
\end{document}

• Technically true undefine would be \let\log\undefined, but that way would be able to "trick" most programs (is it documented behavior?). May 17 at 15:51
• Oh! Thank You :D May 17 at 16:17
• @user202729 Yes, that's used also in other cases. Since \DeclareMathOperator relies on \@ifdefinable, if the control sequence being defined is either currently undefined or its meaning is \relax, then \@ifdefinable returns true. This internally uses \@ifundefined that's classically based on a \csname...\endcsname construction, which yields \relax when the control sequence is undefined. May 17 at 20:49

An alternative to undefining and redefining the command is to declare the log-like operator as a \mathop atom. You would also want to add \nolimits so superscripts and subscripts appear to the right, instead of above and below. This also works for operators that should not use the operator font.

\documentclass{article}
\usepackage{amsmath}

\newcommand\ellog{\mathop{\ell\mathrm{og}}\nolimits}

\pagestyle{empty}

\begin{document}
\begin{align*}
\log_M   x^N &= N \log_M   x \\
\ellog_M x^N &= N \ellog_M x
\end{align*}
\end{document}


In this case, I avoided redefining \log in order to show the old and new output above and below, but you can easily change \newcommand\ellog to something like \DeclareRobustCommand\log.

• +1. Is there an advantage to running \newcommand\ellog{\mathop{\ell\mathrm{og}}\nolimits} instead of \DeclareMathOperator{\ellog}{\ell og}?
– Mico
May 18 at 5:57
• @Mico I guess there are two minor ones: you don’t change to the operator font, if that’s undesired, and you don’t need to redefine the command to \relax first. May 18 at 5:59
• @Mico This wasn’t intended as criticism of your fine answer, though. Just a different method. May 18 at 6:01
• Thanks. I suppose the second advantage is doubtful since \ellog hasn't been defined so far. (If it has been defined, then \newcommand{\ellog}{...} fails too...)
– Mico
May 18 at 6:02