2

I've a simple formula:

\documentclass[]{article}

\usepackage{mathtools}

\newcommand\norm[1]{\left\lVert#1\right\rVert}

\begin{document}
    \begin{equation*}
        \displaystyle\sum\limits_{\mathclap{j \in \{1,2\}}}~\frac{q^{0} - q^{j}}{{(\norm{q^{0} - q^{j}}^{2} - d^{2}})^{2}}
    \end{equation*} 
\end{document}

After adding \left and \right commands to make the parenthesis of the denominator bigger, LaTeX generates the output as follows:

\documentclass[]{article}

\usepackage{mathtools}

\newcommand\norm[1]{\left\lVert#1\right\rVert}

\begin{document}
    \begin{equation*}
        \displaystyle\sum\limits_{\mathclap{j \in \{1,2\}}}~\frac{q^{0} - q^{j}}{{\left(\norm{q^{0} - q^{j}}^{2} - d^{2}}\right)^{2}}
    \end{equation*} 
\end{document}

enter image description here

but there is an error like Extra }, or forgotten \right. ...orm{q^{0} - q^{j}}^{2} - d^{2}}\right)^{2}}. The code is seamlessly compiled without those \left and \right commands.

  • 2
    Replace it with: \displaystyle\sum\limits_{\mathclap{j \in \{1,2\}}}~\frac{q^{0} - q^{j}}{{\left(\norm{q^{0} - q^{j}}^{2} - d^{2}\right)^{2}}}. Simple rule: Respec the brackets ;) – Raaja_is_at_topanswers.xyz Nov 28 '18 at 09:39
  • 3
    You are enclosing \left in a group leaving out \right: {\left( ... } \right). – campa Nov 28 '18 at 09:41

2 Answers2

4

Grouping error in your code, below is the updated code:

\begin{equation*}
    \displaystyle\sum\limits_{\mathclap{j \in
    \{1,2\}}}~\frac{q^{0} - q^{j}}{{\left(\norm{q^{0} - q^{j}}^{2} - d^{2}\right)}^{2}}
\end{equation*} 
MadyYuvi
  • 13,693
3

You have too many useless bits in your code

  • inside equation, \displaystyle and \limits are already in force
  • additional braces in the denominator can be disruptive of spacing
  • \mathclap is not needed (and is wrong, as the need for ~ shows)

Here are my proposals (I'd go with the first one). Note that with my definition of \norm, \norm* is essentially the same as yours.

\documentclass{article}

\usepackage{mathtools}

%\newcommand\norm[1]{\left\lVert#1\right\rVert}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}

\begin{document}

\subsection*{Good}

\begin{equation*}
\sum_{j \in \{1,2\}} \frac{q^{0} - q^{j}}{(\norm{q^{0} - q^{j}}^{2} - d^{2})^{2}}
\end{equation*}

\subsection*{Possibly preferable}

\begin{equation*}
\sum_{j \in \{1,2\}} \frac{q^{0} - q^{j}}{\bigl(\norm{q^{0} - q^{j}}^{2} - d^{2}\bigr)^{2}}
\end{equation*}

\subsection*{Possibly preferable again}

\begin{equation*}
\sum_{j \in \{1,2\}} \frac{q^{0} - q^{j}}{\bigl(\norm{q^{0} - q^{j}}^{2} - d^{2}\bigr)^{\!2}}
\end{equation*}

\subsection*{Disputable}

\begin{equation*}
\sum_{j \in \{1,2\}} \frac{q^{0} - q^{j}}{\left(\norm*{q^{0} - q^{j}}^{2} - d^{2}\right)^{2}}
\end{equation*}

\end{document}

enter image description here

egreg
  • 1,121,712