[Tex/LaTex] No natural log parentheses when typesetting

parenthesestypography

How can I insert parentheses around the content of the natural log? I want my document to show

ln(x+1)

but the code

\ln{x+1}

or

\ln(x+1)

or

\ln \left( x+1 \right)

will not produce this.

Edit:
I should have specified that this issue was occurring in an equation (math mode).

Earlier today I was having some issues compiling due to corrupt temporary files (log and aux files) but never restarted my tex environment. Upon rebooting this evening, my original document is placing parentheses as expected.

I am marking Christian's post as the solution due to his effort and his explanation really clears up what the command \ln actually is (a comand without an argument).

Thank you all for your quick responses.

Best Answer

There are some possibilities to achieve this, but all of them require entering into math mode, i.e. with $...$, \(...\), or \[...\] or one of the various math environments such as equation and align.

But \ln{x+1} is not producing a pair of parentheses. In fact, it's the same as \ln x+1. \ln is an command without arguments, so \ln stands alone actually and ignores the following {...}.

If the parentheses are required in many occasions, wrapper macros, say \lnn and \lnb are useful, which uses either \left(...\right) or the medium spaced version \mleft(...\mright), both of which has the advantage of growing parenthesis for fractions etc.

\documentclass{article}

\usepackage{amsmath}
\usepackage{mleftright}

\newcommand{\lnn}[1]{%
  \ln\left(#1\right)%
}

\newcommand{\lnb}[1]{%
  \ln\mleft(#1\mright)%
}

\begin{document}


\verb!$\ln x+1$ and $\ln{x+1}$ produce the same output!

\begin{center}
  \fboxsep=0pt
  \fbox{$\ln x+1$}

  \fbox{$\ln{x+1}$}
\end{center}

produce the same output

With parentheses:

$
\begin{array}{ccc}
  \verb!\ln(x+1)! & \verb!\ln \left(x+1\right)! & \verb!\ln \mleft(x+1\mright)! \\
  \\
  \ln (x+1) & \ln \left(x+1\right) & \ln \mleft(x+1\mright) \\
  \\
   \verb!\lnb{x+1}! & \verb!\lnb{\dfrac{x+1}{x-1}}! & \verb+\lnn{n!}+\\
   \\
  \lnb{x+1} & \lnb{\dfrac{x+1}{x-1}} & \lnn{n!} \\
\end{array}
$

\end{document}

enter image description here

Related Question