# Spacing in fractions

I have a fraction whose denominator is a fraction again. I want to write the denominator in parantheses, but I have the feeling that the space is not really nice.

The lower term is nice from the spacing, but parantheses destroy it. I would love to see the whole fraction in the denominator a bit up. Is that possible? Here is my code:

\documentclass{article}
\usepackage[german, linesnumbered, boxruled]{algorithm2e}
\usepackage{algorithmic}

\begin{document}
$\lim\limits_{x\to\infty} \frac{\pi(x)}{\left(\frac{x}{\log(x)}\right)} = 1.$

$\lim\limits_{x\to\infty} \frac{\pi(x)}{\frac{x}{\log(x)}} = 1.$
\end{document}

• Why do you use \limits into $...$: is unnecessary? Use the package amsmath and \dfrac in \left(\frac{x}{\log(x)}\right). Commented Mar 11 at 21:01

Don't use \left and \right to size the parentheses in the denominator term; use \bigl and \bigr instead. For that matter, does the denominator term really need parentheses? And do you need the parentheses in \log(x)?

Do also give some thought to replacing the \frac-format denominator term with an inline-fraction expression. That way, the terms in the numerator and denominator will all be rendered in \textstyle math mode.

Finally, there's no need for the \limits qualifiers.

\documentclass{article}
\begin{document}
$\lim_{x\to\infty} \frac{\pi(x)}{\bigl(\frac{x}{\log(x)}\bigr)} = \lim_{x\to\infty} \frac{\pi(x)}{\frac{x}{\log x}} = \lim_{x\to\infty} \frac{\pi(x)}{x/\log x} = 1.$
\end{document}

• Why the downvote? Please enlighten me.
– Mico
Commented Mar 13 at 16:06

Three answers appeared in the time it took me to write this up but I'm posting it anyway. You can use the mathtools package and its \DeclarePairedDelimiter command to create paired delimiters that size correctly, using optional manual \big, \Big, etc.

% !TEX program = lualatexmk
% !TEX encoding = UTF-8 Unicode

\documentclass{article}
\usepackage[german, linesnumbered, boxruled]{algorithm2e}
\usepackage{algorithmic}
\usepackage{mathtools}

\DeclarePairedDelimiter{\ps}{(}{)}

\begin{document}
$\lim_{x\to\infty} \frac{\pi(x)}{\left(\frac{x}{\log x}\right)} = 1.$

$\lim_{x\to\infty} \frac{\pi(x)}{\frac{x}{\log x}} = 1.$

$\lim_{x\to\infty} \frac{\pi(x)}{ \ps{\frac{x}{\log x}} } = 1.$

$\lim_{x\to\infty} \frac{\pi(x)}{ \ps[\big]{\frac{x}{\log x}} } = 1.$

$\lim_{x\to\infty} \frac{\pi(x)}{ \ps[\Big]{\frac{x}{\log x}} } = 1.$
\end{document}


Instead of \left and \right, which set automatically the delimiters sizes, you can choose it manually with (from smaller to bigger) :

\bigl ... \bigr
\Bigl ... \bigr
\biggl ... \biggr
\Biggl ... \Biggr


For example, with \bigl and \bigr :

\documentclass{article}
\usepackage[german, linesnumbered, boxruled]{algorithm2e}
\usepackage{algorithmic}

\begin{document}
$\lim_{x\to\infty} \frac{\pi(x)}{\bigl(\frac{x}{\log(x)}\bigr)} = 1.$

$\lim\_{x\to\infty} \frac{\pi(x)}{\frac{x}{\log(x)}} = 1.$
\end{document}


• +1. Into $...$ \limits has not effect. Commented Mar 11 at 21:10
• @Sebastiano OK, I edited the answer to remove it. Thanks.
– jlab
Commented Mar 11 at 21:13