2

I have an long equation that I must break. However, when I do so, a set of parenthesis disappears. Furthermore, the formation of the equation is odd. What should I do? As you will see in the image, the first equation seems ok, but it's the second one. The red marking shows the missing parenthesis. Thank you.

\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\begin{document}

\begin{alignat}{2}
\begin{aligned}
&\frac{d}{dt}\left(\frac{\partial \mathcal{L}}{\partial \Dot{x}}\right)-\frac{\partial \mathcal{L}}{\partial x}=F &&\Rightarrow \left(2m_0+2m_1+2m_2\right)\Ddot{x}+\left(L_1m_1\cos\theta_2+2L_1m_2\cos\theta_1\right)\Ddot{\theta}_1\\
&\:&&+\left(L_1m_1\sin\theta_1+2L_1m_2\sin\theta_1\right)\Dot{\theta}_1^2+\left(L_2m_2\sin\theta_2\right)\Dot{\theta}_2^2=2F\\
%%%%%%%%%%%%SECOND EQUATION%%%%%%%%%%%%
&\frac{d}{dt}\left(\frac{\partial \mathcal{L}}{\partial\Dot{\theta}_1}\right)-\frac{\partial\mathcal{L}}{\partial\theta_1}=0&&\Rightarrow\left(12\,m_{1}\,\cos\theta_1+24\,m_{2}\,\cos\theta_1\right)\Ddot{x}+\left(2\,m_{1}+15\,L_{1}\,m_{1}\\
 &\:&&+24\,L_{1}\,m_{2}-9\,L_{1}\,m_{1}\,\cos\left(2\,\theta_{1}\right)\right)\Ddot{\theta}_1+\left(12\,L_{2}\,m_{2}\,\cos\left(\theta_{1}-\theta_{2}\right)\right)\Ddot{\theta}_2\\
 &\:&&+\left(9\,L_{1}\,m_{1}\,\sin\left(2\,\theta _{1}\right)\right)\Dot{\theta}_1^2+\left(12\,L_{2}\,m_{2}\,\sin\left(\theta _{1}-\theta _{2}\right)\right)\Dot{\theta}_2^2\\
 &\:&&-12\,g\,m_{1}\,\sin\theta _{1}=0
\end{aligned}
\end{alignat}

\end{document} 

enter image description here

1
  • 8
    don't ignore errors. You can't have \left/\right on different lines. Oct 19, 2020 at 9:22

2 Answers 2

2

As @UlrikeFischer has already noted in a comment, your code contains a syntax error, as \left and \right mustn't span line breaks.

The simplest fix is to get rid of almost all \left and \right sizing modifiers, especially since they don't actually do anything (other than to create a syntax error.)

enter image description here

\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath,amssymb}
\usepackage{geometry}

\begin{document}

\begin{align}
\smash[b]{\frac{d}{dt}
 \left(\frac{\partial \mathcal{L}}{\partial \Dot{x}}\right)
 -\frac{\partial \mathcal{L}}{\partial x}=F }\Rightarrow{}
& (2m_0+2m_1+2m_2)\Ddot{x}
 +(L_1m_1\cos\theta_2+2L_1m_2\cos\theta_1)\Ddot{\theta}_1\notag\\
&\quad+
  (L_1m_1\sin\theta_1+2L_1m_2\sin\theta_1)\Dot{\theta}_1^2
+(L_2m_2\sin\theta_2)\Dot{\theta}_2^2\notag\\
&= 2F\\
%%
\smash[b]{\frac{d}{dt}
 \left(\frac{\partial \mathcal{L}}{\partial\Dot{\theta}_1}\right)
 -\frac{\partial\mathcal{L}}{\partial\theta_1}=0}\Rightarrow{}
&(12m_{1}\cos\theta_1+24m_{2}\cos\theta_1)\Ddot{x}
 +\bigl[2m_{1}+15L_{1}m_{1}+24L_{1}m_{2}\notag\\
&\quad-\phantom{(}9L_{1}m_{1}
 \cos(2\theta_{1})\bigr]\Ddot{\theta}_1
+(12L_{2}m_{2}\cos(\theta_{1}-\theta_{2}))\Ddot{\theta}_2\notag\\
&\quad+(9L_{1}m_{1}\sin(2\theta _{1}))\Dot{\theta}_1^2
      +(12L_{2}m_{2}\sin(\theta _{1}-\theta _{2}))\Dot{\theta}_2^2\notag\\
&\quad-12gm_{1}\sin\theta _{1}\notag\\
&=0
\end{align}

\end{document} 
2

I propose this variant layout, to avoid overfull boxes. It requires the nccmath package (to be loaded before mathtools). I removed the unnecessary \left...\right pairs, and replaced the others with the bigl ... \bigr pair. Last, I used the diffcoeff package to simplify the typing of derivatives in Leibniz notation:

\documentclass[11pt,a4paper]{article}
\usepackage[english]{babel}
\usepackage{nccmath}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{diffcoeff}

\begin{document}

\begin{fleqn}
\begin{align}
 & \begin{alignedat}{2}%
  & \diff*{\biggl(\diffp{\mathcal{L}}{\Dot{x}}\biggr)}{t} & & -\diffp{\mathcal{L}}{x} = F\Rightarrow \\
 & & & \phantom{{}+{}}(2m_0+2m_1+2m_2)\Ddot{x}+(L_1m_1\cos\theta_2+2L_1m_2\cos\theta_1)\Ddot{\theta}_1\\
 & & & +(L_1m_1\sin\theta_1+2L_1m_2\sin\theta_1)\Dot{\theta}_1^2+(L_2m_2\sin\theta_2)\Dot{\theta}_2^2=2F
\end{alignedat}\\[2ex]
%%%%%%%%%%%%%SECOND EQUATION%%%%%%%%%%%%
 & \begin{alignedat}{2}
 & \diff*{\biggl(\diffp{\mathcal{L}}{\Dot{\theta_1}}\biggr)}{t} & & -\diffp{\mathcal{L}}{\theta_1}=0\Rightarrow \\%
 & & &\phantom{{}+{}}(12\,m_{1}\,\cos\theta_1+ 24\,m_{2}\,\cos\theta_1)\Ddot{x}\\ %
 & & & + \bigl(2\,m_{1}+15\,L_{1}\,m_{1}+24\,L_{1}\,m_{2}-9\,L_{1}\,m_{1}\,\cos 2\,\theta_{1}\bigr)\Ddot{\theta}_1\\
 & & & +\bigl(12\,L_{2}\,m_{2}\,\cos(\theta_{1}-\theta_{2})\bigr)\Ddot{\theta}_2 +(9\,L_{1}\,m_{1}\,\sin 2\,\theta _{1})\Dot{\theta}_1^2\\
 & & & +\bigl(12\,L_{2}\,m_{2}\,\sin(\theta _{1}-\theta _{2})\bigr)\Dot{\theta}_2^2-12\,g\,m_{1}\,\sin\theta _{1}=0
 \end{alignedat}
\end{align}
 \end{fleqn}

\end{document} 

enter image description here

3
  • Thanks for the edit, @Zarko!
    – Bernard
    Oct 19, 2020 at 12:59
  • +1! Is the mathtools necessary? I wasn't aware for diffcoeff ...
    – Zarko
    Oct 19, 2020 at 13:02
  • Here, it's not necessary, but it's loaded, because I tried other solutions using it (initially, I tried \MoveEqLeft[some number], and finally decided it was simpler to use use the fleqn environment). But I think it's recommendable to load it systematically (except for very simple layouts), because it completes amsmath with some quite valuable command/environments.
    – Bernard
    Oct 19, 2020 at 13:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .