4

I have the following equation which I have split in two lines, why do I get the ( after = to be smaller that the closing )?

\begin{equation}\label{testequation}
\begin{split}
d_{m}^{\sim \phi}\left(A,f\right) = \left( \mid1-Y(R)\mid^{5} -|-f(M)|^{9} +\\  \sum_{i=1;i\neq p_{i}}^{length\left(H}\right)}  \mid I\left(i\right)\right.  \left. \vphantom{\sum_{i=1;i\neq pi}^{length\left(R\right)}} -f\left(i\right)\mid^{m}\right)^{1/m}
\end{split}
\end{equation}

Thanks.

karlkoeller
  • 124,410
Simplicity
  • 1,305

2 Answers2

9

You should not be using \left...\right construct for things spanning over one line but fixed sized delimiters as \Biggl...\Biggr.

I've also corrected some errors and removed some more unneeded \left...\right.

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{equation}\label{testequation}
\begin{split}
d_{m}^{\sim \phi}\left(A,f\right) = \Biggl( \mid 1-Y(R)\mid^{5} -\mid -f(M)\mid^{9} \\
+\sum_{i=1;i\neq p_{i}}^{\text{length}(H)} \mid I(i)-f(i)\mid^{m}\Biggr)^{1/m}
\end{split}
\end{equation}

\end{document}  

enter image description here

Further improvements can be made. BTW: probably the equation fits in one line, why using split?


EDIT

An improved version that fits in one line and uses \mathclap (mathtools package) to reduce the spacing around \sum

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{equation}\label{testequation}
d_{m}^{\sim \phi}\left(A,f\right) = \Biggl(\lvert 1-Y(R)\rvert^{5} -\lvert -f(M)\rvert^{9}
+\;\;\sum_{\mathclap{i=1;i\neq p_{i}}}^{\mathclap{\text{length}(H)}}\;\; \lvert I(i)-f(i)\rvert^{m}\Biggr)^{1/m}
\end{equation}

\end{document}  

enter image description here

karlkoeller
  • 124,410
5

There are several issues with your code:

  • The construct \vphantom{\sum_{i=1;i\neq pi}^{length\left(R\right)}} needs to be in the first line, not the second line, in order to assure equal heights of the enclosing parentheses. However, in the present case, the use of (properly delimited/terminated \left and \right will result in parentheses that are by far too large; I would recommend using the explicit sizing directives \biggl and \biggr.

  • The code uses the split environment but doesn't provide any alignment points. A normal choice for the first line would be the = sign; align the second line so that it starts slightly to the right of the previous line's alignment point.

  • For absolute value signs, do not use \mid, which is defined as a relational operator and therefore provides ample spacing around the vertical bars. Instead, either use simple vertical bars or, better yet, define a macro such as \newcommand\abs[1]{\lvert#1\rvert} to provide a more structured way of setting up the expressions.

The following code uses the \abs macro and shows two different outcomes: first with and then without the automatically sized outer parentheses. Observe that the second possibility doesn't require the \vphantom construct.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\newcommand\abs[1]{\lvert#1\rvert}
\begin{document}
\begin{equation}\label{testequation}
\begin{split}
d_{m}^{\sim \phi}(A,f)
&= \left( \vphantom{\sum_{i=1;i\neq p_i}^{length\left(R\right)}}  \abs{1-Y(R)}^{5} -\abs{-f(M)}^{9} \right. \\
&\quad +\left.\sum_{i=1;\ i\neq p_{i}}^{\text{length}(H)} \abs{I(i) -f(i)}^{m} \right)^{1/m}
\end{split}
\end{equation}
\begin{equation}\label{testequation}
\begin{split}
d_{m}^{\sim \phi}(A,f)
&= \biggl(  \abs{1-Y(R)}^{5} -\abs{-f(M)}^{9} \\
&\quad +\sum_{i=1;\ i\neq p_{i}}^{\text{length}(H)} \abs{I(i) -f(i)}^{m} \biggr)^{1/m}
\end{split}
\end{equation}
\end{document} 
karlkoeller
  • 124,410
Mico
  • 506,678
  • Mico, if you are interested, take a look at https://tex.meta.stackexchange.com/a/7303/27635 – karlkoeller May 27 '17 at 08:15
  • @karlkoeller - Thanks -- I'm definitely very interested. I ran your query code just now and was informed about 161 [!!] instances of the site bug afflicting my postings. Yikes! Much much better to find out this way, though, rather than by running a manual search. By the way, is there a way to restrict the search to just the most recent version of whatever posting/answer the algorithm finds? The reason I ask is that the algorithm appears to have "found" some answers which I had already located and fixed manually (replacing the single backslashes with double backslashes, that is). – Mico May 27 '17 at 08:28
  • I don't really know how to achieve this. Try asking in the chat and let know. – karlkoeller May 27 '17 at 08:31
  • See https://meta.stackoverflow.com/q/349797/2404343 – karlkoeller May 27 '17 at 10:33