# Negative logarithm: spacing

The equation $\max - \log x$ renders in a weird way:

The minus is a unary operator (i.e. it means "negative logarithm", and not "the difference between max and log"). So I would expect that it would be closer to "log". That happens for $-b$ as opposed to $a-b$:

Is there a better way than $-\log x$ to write the negative logarithm?

• I'd use \max(-\log x) Jun 3, 2018 at 19:50
• What if I don't want to write the parentheses? I'm concerned about the spacing in $\max -\log x$ as opposed to $\max -b$.
– root
Jun 3, 2018 at 19:54
• I consider very ambiguous even \max\log x, because there's no binding of the variable. I can suggest \max-{\log x}, Jun 3, 2018 at 19:59
• It's actually \max\{\log x:x>0\} (or whatever interval you compute the maximum over. Jun 3, 2018 at 20:02
• What about \max{}-\log x? I dislike, but... Jun 3, 2018 at 20:04

As @egreg pointed out in the comments, to avoid ambiguity a pair of parentheses is recommended. Or maybe you could try $\max_{x\ge2} -{\log x}$ instead of the full expression $\max\{ \, -{\log x} : x\ge2 \, \}$.

You mentioned you wanted a unary negation, so you have to use $-{\log x}$, and even $-\log x$ is incorrect.

In the $-\log x$ example, \log is of class \mathop, and the minus sign (which is not a binary operation here) will be rendered as an ordinary object (class \mathord - see this answer to learn about math classes). And so a thin space \, is added between them (because a thin space is always inserted between \mathord and \mathop - see this answer - think $\sin x\cos x$ for example).

Therefore, to truly get unary negation, you must make sure whatever you are negating is itself an ordinary object. This can be done by simply enclosing \log x within a pair of {}. Same idea applies to $-{\sin x}$, $\tan x = {\sin x}/{\cos x}$, etc.

• Thanks! What's ambiguous about $\max\log x$ without parentheses, what else can it mean apart from $\max(\log x)$? Why does $-\log$ create an "impossible" combination, where is it explained that $- cannot be followed by a \mathop? – root Jun 3, 2018 at 22:55 • @root A - in math mode is classified as \mathbin by default. “Impossible” means “it is impossible to start math mode with a \mathbin”, hence the \mathord adjustment. A \mathop can follow a \mathord—see my mentioned example. You can check this answer to learn about math classes, and this answer for the spacing rules. Jun 3, 2018 at 23:38 • @root done! :) Aug 5, 2019 at 17:04 • Thanks :) In the $-\log x$ example and the $\max-\log x$ example – root Aug 5, 2019 at 21:22 • @root not quite. In $\max-\log x\$, the minus sign is a perfectly normal binary, the atoms in this math list are mathop mathbin mathop mathord. Aug 6, 2019 at 23:50

A double pair of braces will do the trick. However, I also prefer to add a pair of parentheses:

\documentclas{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathtools}

\begin{document}

\begin{align*}
& \smashoperator{\max_{1 < x < \mathrm e}}{-}{\log x}\\
& \smashoperator{\max_{1 < x < \mathrm e}} ({-}{\log x})
\end{align*}%

\end{document}