1

I'm so frustrated with using latex to input mathematical equations. Now I have been noticed that the error"! LaTeX Error: Bad math environment delimiter." and the error with\gather.

 \documentclass{article}
 \usepackage{amsmath}
 \usepackage{mathtools}
 \begin{document}
 \begin{gather}
\intertext{The Household Problem:}
  V(k_e,k_s;s,z,q)=\max_{c_t,l_t,h_t,k_e^(t+1),k_s^(t+1)}\{U(c_t,l_t)+\beta 
  E\[V(k_e^(t+1),k_s^(t+1;s^(t+1),z^(t+1),q^(t+1))\] \\
\shortintertext{subject to}
\begin{split}
 c+k_e^(t+1)/q+k_s^(t+1)&=(1-\tau_k)[R_e(\lambda)hk_e+R_S(\lambda)k_s]\\
 &+(1-\tau_l)W(\lambda)l+(1-\delta_e(h))k_e/q+(1-\delta_s)k_s+T_(\lambda)\\
 & -A_s(k_s^(t+1),k_s)-A_e(k_e^(t+1)/q,k_e/q;\eta),
\end{split}
\intertext{and s^(t+1)=S(\delta)}
\intertext{Form a period t+1 value Lagrangian:}
\begin{split}
\mathcal{L} & =E_0\sum\limits_{t=0}^\infty \beta^t U(c_t,l_t)+\Lambda_t\{(1-
\tau_k^t)(r_e^t h k_e^t +r_s^tk_s^t) \\
 & +(1-\tau_l^t)W(\lambda)l+(1-\delta_e(h))k_e/q+(1-
 \delta_s)k_s+T_(\lambda)\\
 & -A_s(k_s^(t+1),k_s)-A_e(k_e^(t+1)/q,k_e/q;\eta)-c_t -k_e^(t+1)/q -
k_s^(t+1)\}\\
\end{split}
\intertext{First Order Conditions Of Household:}
\frac{\partial\mathcal{L}_(t+1)}{c_t} = \beta\theta\frac{1}{c_t}=\Lambda_t\\
\frac{\partial\mathcal{L}_(t+1)}{l_t} =\frac{\beta(1-\theta)}{l_t-
1}=\Lambda_t    
\tau_l^tw_t(\lambda)\\
\frac{\partial\mathcal{L}_(t+1)}{k_s^(t+1)} =2\phi_s k_s^t+1-2(k_s^t)^2-
k_s^t=0\\
\frac{\partial\mathcal{L}_(t+1)}{k_e^(t+1)} =2e^\eta\phi_tk_e^t+1-2\kappa_e 
k_e^t-k_e^tq=0\\
\frac{\partial\mathcal{L}_(t+1)}{h_t} =\r_e^t=\frac{1}{q(1-\tau_k^t)} 
bh^\omega-1\\
k_e^{t+1}=(1-\delta_s)k_s^t+i_s^t,\quad  0<\delta_s<1\\
\intertext{Dynamic Budget Constraints:}
\begin{split}
c_t &= k_e^{(t+1)}\frac{1}{q}+k_s^{(t+1)}+(1-\tau_k^t)(r_ehk_e+r_sk_s)+(1-
 \tau_l)wl \\
&\quad+ (1-\lambda_e(h))k_e/q+(1-\lambda_s)k_s+T(\lambda)\\
&\quad- A_s(k_s^{(t+1)},k_s)-A_e(k_e^{(t+1)}/q,k_e/q;\eta)
\end{split}
 \\Transversality\quad Condition
\intertext{First Order Conditions Of Firms:}
\shortintertext{F.O.C with respect to k_e:}r_e=\alpha_e z h^{(\alpha_e-1)} 
 k_e^{(\alpha_e-1)}k_s^{\alpha_s}l^{(1-\alpha_e-\alpha_s)}\\
 \shortintertext{F.O.C with respect to k_s:}r_s=\alpha_s z h^{(\alpha_e)} 
 k_e^{\alpha_e} k_s^{(\alpha_s-1)}l^{(1-\alpha_e-\alpha_s)}\\
 \shortintertext{F.O.C with respect to l:}w=(1-\alpha_e-\alpha_s)z 
  h^{\alpha_e}k_e^{\alpha_e}k_s^{\alpha_s}\\
  \shortintertext{F.O.C with respect to h:}r_e\widetilde{k_e}=\alpha_e z 
 h^{(\alpha_e-1)}k_e^{\alpha_e} k_s^{\alpha_s} l^{(1-\alpha_e-\alpha_s)}\\
  \ln{z_{(t+1)}}=(1 
 \rho_a)\ln{\overline{z}}+\rho_a\ln{z_t}+\varepsilon_{(a,t)}\\
  \intertext{Government:}
  \tau=\tau_k(r_e h k_e +r_s k_s)+\tau_e wl
   \end{gather}
   \end{document}

I spent about one hour but still could't figure out so come to here to ask questions. I sincerely appreciate your help!

5
  • In your code there are many errors: for example it is k_s^{t+1} instead of k_s^(t+1).
    – Sebastiano
    Apr 1 '18 at 22:05
  • the main error is you have \] which is end pf equation instruction on the second line of the mathematics Apr 1 '18 at 22:08
  • I corrected them but still can't run. It is my second time to use \latex, however, I have to master it ASAP. Thank you!!!
    – E.K
    Apr 1 '18 at 22:13
  • @E.K, mastering latex is far from being easy, it requires years to only relatively well use a small portion of it. Start small, then try to expand your knowledge step by step.
    – BambOo
    Apr 1 '18 at 22:49
  • Yes, I also want to learn through that way but the seminar requires everyone use Latex, which I first heard about. Thank you so much for your comments.
    – E.K
    Apr 2 '18 at 23:10
2

enter image description here

How are you entering these codes? there were tex errors on more or less every line, spurious \] mis-matched } and missing $ around nested math expressions in text.

It is hard to debug a big alignment like gather or align as the errors are reported at the end, but if you add the expressions one line at a time and fix each error as it is reported you would not get into such a position.

 \documentclass{article}
 \usepackage{amsmath}
 \usepackage{mathtools}
 \begin{document}
 \begin{gather}
\intertext{The Household Problem:}
  V(k_e,k_s;s,z,q)=\max_{c_t,l_t,h_t,k_e^{t+1},k_s^{t+1}}
  U(c_t,l_t)+\beta 
  E[V(k_e^{t+1},k_s^(t+1;s^{t+1},z^{t+1},q^{t+1})]\\
\shortintertext{subject to}
\begin{split}
 c+k_e^{t+1}/q+k_s^{t+1}&=(1-\tau_k)[R_e(\lambda)hk_e+R_S(\lambda)k_s]\\
 &+(1-\tau_l)W(\lambda)l+(1-\delta_e(h))k_e/q+(1-\delta_s)k_s+T_{\lambda}\\
 & -A_s(k_s^{t+1},k_s)-A_e(k_e^{t+1}/q,k_e/q;\eta),
\end{split}\\
\intertext{and $s^{t+1}=S(\delta)$}
\intertext{Form a period $t+1$ value Lagrangian:}
\begin{split}
\mathcal{L} & =E_0\sum\limits_{t=0}^\infty \beta^t U(c_t,l_t)+\Lambda_t\{(1-
\tau_k^t)(r_e^t h k_e^t +r_s^tk_s^t) \\
 & +(1-\tau_l^t)W(\lambda)l+(1-\delta_e(h))k_e/q+(1-
 \delta_s)k_s+T_{\lambda}\\
 & -A_s(k_s^{t+1},k_s)-A_e(k_e^{t+1}/q,k_e/q;\eta)-c_t -k_e^{t+1}/q -
k_s^{t+1}\}\\
\end{split}\\
\intertext{First Order Conditions Of Household:}
\frac{\partial\mathcal{L}_{t+1}}{c_t} = \beta\theta\frac{1}{c_t}=\Lambda_t\\
\frac{\partial\mathcal{L}_{t+1}}{l_t} =\frac{\beta(1-\theta)}{l_t-
1}=\Lambda_t    
\tau_l^tw_t(\lambda)\\
\frac{\partial\mathcal{L}_{t+1}}{k_s^{t+1}} =2\phi_s k_s^t+1-2(k_s^t)^2-
k_s^t=0\\
\frac{\partial\mathcal{L}_{t+1}}{k_e^{t+1}} =2e^\eta\phi_tk_e^t+1-2\kappa_e 
k_e^t-k_e^tq=0\\
\frac{\partial\mathcal{L}_{t+1}}{h_t} =r_e^t=\frac{1}{q(1-\tau_k^t)} 
bh^\omega-1\\
k_e^{t+1}=(1-\delta_s)k_s^t+i_s^t,\quad  0<\delta_s<1\\
\intertext{Dynamic Budget Constraints:}
\begin{split}\\
c_t &= k_e^{(t+1)}\frac{1}{q}+k_s^{(t+1)}+(1-\tau_k^t)(r_ehk_e+r_sk_s)+(1-
 \tau_l)wl \\
&\quad+ (1-\lambda_e(h))k_e/q+(1-\lambda_s)k_s+T(\lambda)\\
&\quad- A_s(k_s^{(t+1)},k_s)-A_e(k_e^{(t+1)}/q,k_e/q;\eta)
\end{split}
\\Transversality\quad Condition
\intertext{First Order Conditions Of Firms:}
\shortintertext{F.O.C with respect to $k_e$:}
 r_e=\alpha_e z h^{(\alpha_e-1)} 
 k_e^{(\alpha_e-1)}k_s^{\alpha_s}l^{(1-\alpha_e-\alpha_s)}\\
 \shortintertext{F.O.C with respect to $k_s$:}
r_s=\alpha_s z h^{(\alpha_e)} 
 k_e^{\alpha_e} k_s^{(\alpha_s-1)}l^{(1-\alpha_e-\alpha_s)}\\
 \shortintertext{F.O.C with respect to l:}
w=(1-\alpha_e-\alpha_s)z 
  h^{\alpha_e}k_e^{\alpha_e}k_s^{\alpha_s}\\
  \shortintertext{F.O.C with respect to $h$:}
r_e\widetilde{k_e}=\alpha_e z 
 h^{(\alpha_e-1)}k_e^{\alpha_e} k_s^{\alpha_s} l^{(1-\alpha_e-\alpha_s)}\\
  \ln{z_{(t+1)}}=(1 
 \rho_a)\ln{\overline{z}}+\rho_a\ln{z_t}+\varepsilon_{(a,t)}\\
  \intertext{Government:}
  \tau=\tau_k(r_e h k_e +r_s k_s)+\tau_e wl\\
   \end{gather}
   \end{document}
3
  • David,YOU ARE MY HERO!
    – E.K
    Apr 1 '18 at 22:23
  • @E.K pleasse see the notes I added to my answer Apr 1 '18 at 22:25
  • Yes, I did. I sincerely appreciate your help .
    – E.K
    Apr 2 '18 at 23:08
1

I would use no “intertext” at all.

Note that exponents should be like ^{t+1} rather than ^(t+1) (similarly for subscripts). Also \[ is not a bracket.

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}

 \begin{document}

The Household Problem:
\begin{equation}
  V(k_e,k_s;s,z,q)=
  \max_{\substack{c_t,l_t,h_t,\\k_e^{t+1},k_s^{t+1}}}
  \{U(c_t,l_t)+\beta E[V(k_e^{t+1},k_s^{t+1};s^{t+1},z^{t+1},q^{t+1})]
\end{equation}
subject to
\begin{equation}
\begin{split}
 c+k_e^{t+1}/q+k_s^{t+1}&=(1-\tau_k)[R_e(\lambda)hk_e+R_S(\lambda)k_s]\\
 &+(1-\tau_l)W(\lambda)l+(1-\delta_e(h))k_e/q+(1-\delta_s)k_s+T(\lambda)\\
 & -A_s(k_s^{t+1},k_s)-A_e(k_e^{t+1}/q,k_e/q;\eta),\\
s^{t+1}&=S(\delta)
\end{split}
\end{equation}
Form a period $t+1$ value Lagrangian:
\begin{equation}
\begin{split}
\mathcal{L} & =E_0\sum\limits_{t=0}^\infty \beta^t U(c_t,l_t)+\Lambda_t\{(1-
\tau_k^t)(r_e^t h k_e^t +r_s^tk_s^t) \\
 & +(1-\tau_l^t)W(\lambda)l+(1-\delta_e(h))k_e/q+(1-
 \delta_s)k_s+T(\lambda)\\
 & -A_s(k_s^{t+1},k_s)-A_e(k_e^{t+1}/q,k_e/q;\eta)-c_t -k_e^{t+1}/q -
k_s^{t+1}
\end{split}
\end{equation}
First Order Conditions Of Household:
\begin{align}
\frac{\partial\mathcal{L}_{t+1}}{c_t} &= \beta\theta\frac{1}{c_t}=\Lambda_t\\
\frac{\partial\mathcal{L}_{t+1}}{l_t} &=\frac{\beta(1-\theta)}{l_t-1}=\Lambda_t    
  \tau_l^tw_t(\lambda)\\
\frac{\partial\mathcal{L}_{t+1}}{k_s^{t+1}} &=2\phi_s k_s^t+1-2(k_s^t)^2-
k_s^t=0\\
\frac{\partial\mathcal{L}_{t+1}}{k_e^{t+1}} &=2e^\eta\phi_tk_e^t+1-2\kappa_e 
k_e^t-k_e^tq=0\\
\frac{\partial\mathcal{L}_{t+1}}{h_t} &=r_e^t=\frac{1}{q(1-\tau_k^t)} 
bh^\omega-1\\
k_e^{t+1}&=(1-\delta_s)k_s^t+i_s^t,\quad  0<\delta_s<1
\end{align}
Dynamic Budget Constraints:
\begin{equation}
\begin{split}
c_t &= k_e^{(t+1)}\frac{1}{q}+k_s^{(t+1)}+(1-\tau_k^t)(r_ehk_e+r_sk_s)+(1-
 \tau_l)wl \\
&\quad+ (1-\lambda_e(h))k_e/q+(1-\lambda_s)k_s+T(\lambda)\\
&\quad- A_s(k_s^{(t+1)},k_s)-A_e(k_e^{(t+1)}/q,k_e/q;\eta)
\end{split}
\end{equation}
First Order Conditions Of Firms:
\begin{align}
r_e&=\alpha_e z h^{(\alpha_e-1)} 
  k_e^{(\alpha_e-1)}k_s^{\alpha_s}l^{(1-\alpha_e-\alpha_s)}
&&\text{(with respect to $k_e$)}\\
r_s&=\alpha_s z h^{(\alpha_e)} 
  k_e^{\alpha_e} k_s^{(\alpha_s-1)}l^{(1-\alpha_e-\alpha_s)}
&&\text{(with respect to $k_s$)}\\
w&=(1-\alpha_e-\alpha_s)z 
  h^{\alpha_e}k_e^{\alpha_e}k_s^{\alpha_s}
&&\text{(with respect to $l$)}\\
r_e\widetilde{k_e}&=\alpha_e z 
  h^{(\alpha_e-1)}k_e^{\alpha_e} k_s^{\alpha_s} l^{(1-\alpha_e-\alpha_s)}
&&\text{(with respect to $h$)}\\
\ln{z_{t+1}}&=(1-\rho_a)\ln{\overline{z}}+\rho_a\ln{z_t}+\varepsilon_{(a,t)}
\end{align}
Government:
\begin{equation}
\tau=\tau_k(r_e h k_e +r_s k_s)+\tau_e wl
\end{equation}

\end{document}

enter image description here

2
  • I used because I followed an example given by others. Thank you so much.
    – E.K
    Apr 2 '18 at 23:11
  • @E.K Separating the various parts allows for much greater flexibility.
    – egreg
    Apr 2 '18 at 23:14
1

i only try to correct errors in your first two equations and improve their appearance. In this i introduce new environments \substack{...} and replace split with multlined:

\documentclass{article}
%\usepackage{amsmath}
\usepackage{mathtools}% also load amsmath

\begin{document}
\noindent
The Household Problem:
\begin{gather}
\begin{multlined}[0.8\linewidth]
V(k_e,k_s;s,z,q) = \max_{\substack{c_t,l_t,h_t,\\
                        k_e^{(t+1)},k_s^(t+1)}}
        \{U(c_t,l_t)\}          \\
        + \beta E\Bigl[V\bigl(k_e^{(t+1)},
                              k_s^{(t+1)};
                              s^{(t+1)},
                              z^{(t+1)},
                              q^{(t+1)}\bigr)\Bigr]
\end{multlined}
\shortintertext{subject to}
\begin{multlined}[0.8\linewidth]
c+k_e^{(t+1)}/q+k_s^{(t+1)}
    = (1-\tau_k)\bigl[R_e(\lambda)hk_e+R_S(\lambda)k_s\bigr]    \\
    +(1-\tau_l)W(\lambda)l+(1-\delta_e(h))k_e/q+(1-\delta_s)k_s+T_(\lambda)\\
    - A_s\bigl(k_s^{(t+1)},k_s)-A_e(k_e^{(t+1)}/q,k_e/q;\eta\bigr),
\end{multlined}
\intertext{and $s^{(t+1)}=S(\delta)$. Form a period $t+1$ value Lagrangian:}
\vdots
\end{gather}
\end{document}

similar cleaning of errors are required in all remaining rows. this task i left to you, if you interested for shoved approach of writing your equations.

main errors are noted in David Carlisle answer.

enter image description here

1
  • Thank you for your new way to fix my errors. Wish you a good day.:-)
    – E.K
    Apr 2 '18 at 23:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.