\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
| Command | Use | Package | Copy |
|---|---|---|---|
\log | logarithm, printed upright | none | |
\ln | natural logarithm | none | |
\log_{b} x | logarithm to base b | none | |
\lg | short log, base 10 or 2 depending on the field | none | |
\exp | exponential function, the inverse of \ln | none | |
\operatorname{lb} | any other operator name, e.g. binary log | amsmath |
Commands marked with a package need that \usepackage line in a LaTeX document.
Example
\log_b(xy) = \log_b x + \log_b yThe 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
- Limit lim
\lim_{x \to a} f(x) - Summation ∑
\sum_{i=1}^{n} - Product ∏
\prod_{i=1}^{n}
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.