Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

\right) doesn't work on LaTeX multiline equation

I'm writing an equation on LaTeX and when I want to close the formula with \right) it doesn't work. I'll post my code here to see if anyone can help me:

\begin{equation*}
\begin{split}
 &\bigtriangledown h=\left( \frac{1}{2}\cdot \cos \left(\frac{1}{2}\cdot x\right) \cdot \cos(y) + \cos(x) \cdot \cos(y),
 \frac{-1}{2} \cdot  \cos\left(\cos \left(\frac{1}{2}\cdot y\right)\right)\cdot \\ &\sin\left(\frac{1}{2} \cdot y\right) - \sin\left(\frac{1}{2}\cdot x\right) \cdot \sin(y) - \sin(x) \cdot \sin(y) \right) 
\end{split}
\end{equation*}
like image 425
Andres Otero Avatar asked Apr 16 '16 18:04

Andres Otero


People also ask

How do you make a multiline equation in LaTeX?

For equations longer than a line use the multline environment. Insert a double backslash to set a point for the equation to be broken. The first part will be aligned to the left and the second part will be displayed in the next line and aligned to the right.

How do I align multiple equal signs in LaTeX?

The eqnarray environment lets you align equations so that, for example, all of the equals signs "=" line up. To do this, put ampersand "&" signs around the text you want LaTeX to align, e.g. Each equation can be labelled separately, just put the label command after the relevant equation.

How do you center align an equation in LaTeX?

Instead of centering you may consider to align all equations at the equal sign and center the whole multiline environment. For this, use the align or align* environment, see the amsmath user's guide (or type texdoc amsldoc at the command prompt). In any case, use amsmath .


1 Answers

This is happening because the paired \left( and \right) cannot be broken over different lines in multi-line environments. So one cannot start \left( on one line of a multi-line equation and pair it with \right) on another line.

You can trick it, though, by giving it a fake matching paren: \left( \right. The period . matches any kind of bracket. Now it will accept this on its own, and simply produce a left parenthesis. You have to remember to do the same with the right paren, and you have to adjust sizes yourself since the automatic resizing won't work. I find that for your example you may want \Bigg( \Bigg. paired with \Bigg. \Bigg)

\begin{equation*}
\begin{split}
 & \bigtriangledown h=
 \Bigg( \Bigg. 
    \frac{1}{2}\cdot \cos \left(\frac{1}{2}\cdot x\right) \cdot \cos(y)
        + \cos(x) \cdot \cos(y), 
    \frac{-1}{2} \cdot  \cos\left(\cos \left(\frac{1}{2}\cdot y\right)\right)\cdot \\ 
 & \sin\left(\frac{1}{2} \cdot y\right) 
        - \sin\left(\frac{1}{2}\cdot x\right) \cdot \sin(y) 
        - \sin(x) \cdot \sin(y) 
\Bigg. \Bigg) 
\end{split}
\end{equation*}

This now works, but I'd move the alignment point to after = so the next line is indented (or, rather, after the opening parenthesis). However, I'd first suggest to look into yet other options availed by amsmath package.

Since you do not want numbering any way, and may want to align precisely, one option that gives more control is the align environment. With your equations, rearranged a little

\usepackage{amsmath}

\begin{align*}
    \bigtriangledown h = \Bigg( \Bigg. & 
        \frac{1}{2}\cdot \cos \left(\frac{1}{2}\cdot x\right) \cdot \cos(y)
            + \cos(x) \cdot \cos(y), \\
    & -\frac{1}{2} \cdot  \cos\left(\cos \left(\frac{1}{2}\cdot y\right)\right)\cdot
        \sin\left(\frac{1}{2} \cdot y\right) \\
    &   - \sin\left(\frac{1}{2}\cdot x\right) \cdot \sin(y) 
        - \sin(x) \cdot \sin(y) \Bigg. \Bigg)
\end{align*}

There is a number of other environments for multi-line equations, to suit different cases. Here is a clear page on Aligning Equations and here is the official amsmath User's Guide (pdf).


This is the image of both examples above, first the one using align, wrapped together with

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}

\begin{document}
% ... example using align environment, a line of text, example with split
\end{document}

equations

I kept the second example as in the OP but consider aligning after the = sign, as mentioned.

like image 187
zdim Avatar answered Sep 30 '22 12:09

zdim