Skip to content
All LaTeX symbols

Logarithm (log, ln)

Operators

log

LaTeX command

\log

logarithm, printed upright

Use inside math mode: $\log$, works in base LaTeX, KaTeX and MathJax

\log and \ln are operator names, so LaTeX prints them upright and puts the right space before the argument. Typing plain log gives italic l, o, g, which reads as three variables multiplied together. Put the base in a subscript: \log_2 n.

All ways to write it

CommandUsePackageCopy
\loglogarithm, printed uprightnone
\lnnatural logarithmnone
\log_{b} xlogarithm to base bnone
\lgshort log, base 10 or 2 depending on the fieldnone
\expexponential function, the inverse of \lnnone
\operatorname{lb}any other operator name, e.g. binary logamsmath

Commands marked with a package need that \usepackage line in a LaTeX document.

Example

\log_b(xy) = \log_b x + \log_b y

The product rule for logarithms.

Questions

How do I write log base 2 in LaTeX?

\log_2 n. Use braces when the base has more than one character: \log_{10} x.

Why does my log look italic?

You typed log as letters. Use \log (or \ln) so it prints upright with operator spacing.

How do I make parentheses after \log scale?

Use \left( and \right): \log\left(\frac{a}{b}\right). Plain parentheses stay at normal height.

How do I add an operator that isn't built in?

\operatorname{lb} prints any name upright with operator spacing. It comes from amsmath and works in KaTeX, so it works in Confluence math macros.

Related symbols

Using logarithm in Confluence

Confluence Cloud has no built-in LaTeX. With LaTeX Math for Confluence you add a math macro to any page, type \log and it renders inline or as a block, with a live preview while you edit. Every command on this page renders there without extra packages.