In my country, the base of logarithm is written in superscript before the log sign, i.e. $^a\log b$ means log base a of b. This doesn't look nice on LaTeX, because there is a gap between ^a and \log. How to remove this gap?

  • 2
    I've never seen that notation and I find it a source for ambiguities, even if there's a thin space before the superscript: $2\mylog{2}x$ (with David's definition) will leave the reader with the doubt whether it's "four times the logarithm of x" or "2 times the base 2 logarithm of x". – egreg Jul 16 '12 at 17:37
  • Indeed it is. Unfortunately I have no choice but to follow the consensus. For such case of ambiguity, I'd put a dot to indicate multiplication. – steve Jul 16 '12 at 19:41
  • Can you reveal where this notation is used? It's certainly uncommon. – egreg Jul 16 '12 at 19:42
  • I'm from Indonesia – steve Jul 16 '12 at 19:43
  • 2
    This is not an uncommon notation at all. Here in the Netherlands it is also widely used. It is taught like this at the middle school. – Chiel ten Brinke Apr 25 '13 at 12:38

You can use a negative space \! to remove (or reduce) this to your liking. It would be best to define a command for this, for the sake of consistency:

enter image description here

\usepackage{xparse}% http://ctan.org/pkg/xparse
  {}^a\log xyz\ \mbox{or}\ \Log[a]xyz\ \mbox{or}\ \Log xyz\ \mbox{or}\ \log_a xyz

Of course, more specific kerning is also possible using \kern.

The above MWE defined \Log[<base>] that takes an optional argument <base>. Without <base> it defaults to \log.


enter image description here

The space comes because \log is a \mathop command. Here you don't want any space between the superscript and the log but you do want the entire construct to be a \mathop so:




$ x+x\mylog2 x$
  • The downside to this method seems to be that te base is not typset in mathfont. For instance, the "g" in \mylog{g} will look different from $g$. – gebruiker May 12 '20 at 12:28
  • I found a quick solve by using {}\textsuperscript{$#1$} – gebruiker May 12 '20 at 12:45
  • @gebruiker never use \textsuperscript in math: if you want the superscript in the same font as log then simply specify it in the same way, change #1 to \mathrm{#1} Oh no you say you want the base to be in a math font. That is what my original definition does. – David Carlisle May 12 '20 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.