1

I want to write the following word equation in Latex: enter image description here

I have the following codes:

\begin{align}                  
\mathbf {P_{t} &= \sum_{j=1}^{\rho } \left ( I - G_{0} \right )^{-1} \left [ D_{j} + D_{0}  \left ( I - G_{0} \right )^{-1} B_{j}\right ] Y_{t-j} + \sum_{j=1}^{\rho } \left ( I - G_{0} \right )^{-1} \left [ G_{j} + D_{0}  \left ( I - B_{0} \right )^{-1} C_{j}\right ] P_{t-j} \nonumber \\
               &\hphantom{=} + \sum_{j=1}^{\rho } \left ( I - G_{0} \right )^{-1} \left [ G_{j} + D_{0}  \left ( I - B_{0} \right )^{-1} C_{j}\right ] P_{t-j} \nonumber \\
               &\hphantom{=}  + B_{j} Y_{t-j} + \left ( I - G_{0} \right )^{-1} D_{0} \left ( I - B_{0} \right )^{-1}A^{y} v_{t}^{y} + u_{p}^{t}}, \label{eqn:{2}'}                  
\end{align} 

I was trying to break it up using \nonumber \\ and &\hphantom{=} but it is just not working. I am getting some errors. Any help would be appreciated. Thanks.

Note this my preamble:

\documentclass[12pt,reqno]{amsart}

% Packages
\usepackage[onehalfspacing]{setspace}
\usepackage{graphicx}
\usepackage{amssymb,amsthm}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{float}
\usepackage[utf8]{inputenc}
\makeatletter
\newcommand*\rel@kern[1]{\kern#1\dimexpr\macc@kerna}
\newcommand*\widebar[1]{%
  \begingroup
  \def\mathaccent##1##2{%
    \rel@kern{0.8}%
    \overline{\rel@kern{-0.8}\macc@nucleus\rel@kern{0.2}}%
    \rel@kern{-0.2}%
  }%
  \macc@depth\@ne
  \let\math@bgroup\@empty \let\math@egroup\macc@set@skewchar
  \mathsurround\z@ \frozen@everymath{\mathgroup\macc@group\relax}%
  \macc@set@skewchar\relax
  \let\mathaccentV\macc@nested@a
  \macc@nested@a\relax111{#1}%
  \endgroup
}
\makeatother
\usepackage{cite}
%\usepackage{natbib}
%\bibpunct{(}{)}{;}{;}{,}{,}
\usepackage{xr-hyper}
\usepackage[
  colorlinks=true,
  citecolor=blue,
  urlcolor=blue,
  linkcolor=blue
]{hyperref}
\usepackage{bm}
\usepackage{fullpage}
\usepackage{ amssymb }
\usepackage{caption} 
\usepackage{forest}
\captionsetup{labelfont=normalfont,
              labelsep=colon}
\usepackage{mathabx}
\usepackage{subfig}
\usetikzlibrary{arrows.meta,shapes,positioning}
%
\tikzset{
    full/.style={circle,draw,inner sep=0, minimum size=1mm,fill=black},
    every node/.style={minimum height=5mm,font=\footnotesize}
}
%
\makeatletter
\def\subsection{\@startsection{subsection}{1}%
  \z@{.5\linespacing\@plus.7\linespacing}{-.5em}%
  {\normalfont\itshape}}
\def\@sect#1#2#3#4#5#6[#7]#8{%
  \edef\@toclevel{\ifnum#2=\@m 0\else\number#2\fi}%
  \ifnum #2>\c@secnumdepth \let\@secnumber\@empty
  \else \@xp\let\@xp\@secnumber\csname the#1\endcsname\fi
  \@tempskipa #5\relax
  \ifnum #2>\c@secnumdepth
    \let\@svsec\@empty
  \else
    \refstepcounter{#1}%
    \edef\@secnumpunct{%
      \ifdim\@tempskipa>\z@ % not a run-in section heading
        \@ifnotempty{#8}{.\@nx\enspace}%
      \else
        \@ifempty{#8}{.}{.\@nx\enspace}%
      \fi
    }%
    \@ifempty{#8}{%
      \ifnum #2=\tw@ \def\@secnumfont{\bfseries}\fi}{}%
    \protected@edef\@svsec{%
      \ifnum#2<\@m
        \@ifundefined{#1name}{}{%
          \ignorespaces\csname #1name\endcsname\space
        }%
      \fi
      \@seccntformat{#1}%
    }%
  \fi
  \ifdim \@tempskipa>\z@ % then this is not a run-in section heading
    \begingroup #6\relax
    \@hangfrom{\hskip #3\relax\@svsec}{\interlinepenalty\@M #8\par}%
    \endgroup
    \ifnum#2>\@m \else \@tocwrite{#1}{#8}\fi
  \else
  \def\@svsechd{#6\hskip #3\@svsec
    \@ifnotempty{#8}{\ignorespaces#8\unskip
       %\@addpunct.
       }%
    \ifnum#2>\@m \else \@tocwrite{#1}{#8}\fi
  }%
  \fi
  \global\@nobreaktrue
  \@xsect{#5}}
\makeatother

\pagestyle{plain}

\setlength{\parskip}{\baselineskip}
\setlength{\parindent}{12pt}

\setcounter{secnumdepth}{2}

\allowdisplaybreaks[4]
% Commenting/debugging
\let\IG\iffalse
\let\ENDIG\fi

%% Shortcuts
\newcommand{\td}[2]{\dfrac{d #1}{d #2}}
\newcommand{\std}[2]{\dfrac{d^2 #1}{d {#2}^2}}
\newcommand{\ctd}[3]{\dfrac{d^2 #1}{d #2 d #3}}

\newcommand{\pd}[2]{\dfrac{\partial #1}{\partial #2}}
\newcommand{\spd}[2]{\dfrac{\partial^2 #1}{\partial {#2}^2}}
\newcommand{\cpd}[3]{\dfrac{\partial^2 #1}{\partial #2 \partial #3}}

\newcommand{\pdi}[2]{\partial #1/\partial #2}

\newcommand{\LR}{\Leftrightarrow}
\newcommand{\Lg}{\mathcal{L}}
\newcommand{\half}{\tfrac{1}{2}}
\newcommand{\eqp}{\phantom{=}}
\newcommand{\eqs}{\buildrel s \over =}
\newcommand{\me}{\mathrm{e}}
%begin codes for footnotes (symbols)
\makeatletter
\newcommand*{\myfnsymbolsingle}[1]{%
    \ensuremath{%
        \ifcase#1% 0
        \or % 1
        \dagger%   
        \or % 2
        1 
        \or % 3  
        2
        \or % 4   
        3
        \or % 5
        4
        \else % >= 6
        \@ctrerr  
        \fi
    }%   
}      
\makeatother

\newcommand*{\myfnsymbol}[1]{%
  \myfnsymbolsingle{\value{#1}}%
}

% remove upper boundary by multiplying the symbols if needed
\usepackage{alphalph}
\newalphalph{\myfnsymbolmult}[mult]{\myfnsymbolsingle}{}

\renewcommand*{\thefootnote}{%
  \myfnsymbolmult{\value{footnote}}%
}
%end codes for footnotes (symbols) 
  • 2
    I hate to be a bore, but I really would ask you to review the tips for creating a good MWE, especially in light of comments on another recent question of yours. Your code is, again, extremely bloated and unhelpful - and the person that's most unhelpful to is you! It needs to go on a diet ;) – Au101 Jul 15 '16 at 3:58
  • 2
    this has just a single equation number, so why not just use \begin{split} ... \end{split} within an equation? that's what it's for. – barbara beeton Jul 15 '16 at 4:56
  • @barbarabeeton In principle that's the neatest idea and it's what I tried first when writing my answer, but I completely changed tack, because the different line heights of each line means the equation label (which is rightly vertically centred) is not in line with any of the lines of the equation. I didn't like this effect as much, so I numbered it manually instead – Au101 Jul 15 '16 at 4:59
  • 1
    @Au101 -- to my eyes, there's too much "air" between the first and second lines. i'd be tempted to try \smashing the bottom of (only) the sum-component on the first line, regardless of how the numbering is applied. – barbara beeton Jul 15 '16 at 5:07
  • @barbarabeeton Added as an option :) – Au101 Jul 15 '16 at 5:17
4

What about this:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\setcounter{equation}{2}

\begin{align}
  \mathbf{P}_{t} = \sum_{j = 1}^{\rho} (\mathbf{I} &-
  \mathbf{G}_{0})^{-1} [\mathbf{D}_{j} + \mathbf{D}_{0} (\mathbf{I} -
  \mathbf{B}_{0})^{-1} \mathbf{B}_{j}] \mathbf{Y}_{t - j} \nonumber
  \\
  &+ \sum_{j = 1}^{\rho} (\mathbf{I} - \mathbf{G}_{0})^{-1}
  [\mathbf{G}_{j} + \mathbf{D}_{0} (\mathbf{I} - \mathbf{B}_{0})^{-1}
  \mathbf{C}_{j}] \mathbf{P}_{t - j} \tag{\theequation$'$} \\
  &+ (\mathbf{I} - \mathbf{G}_{0})^{-1} \mathbf{D}_{0} (\mathbf{I} -
  \mathbf{B}_{0})^{-1} \mathbf{A}^{y} \mathbf{v}_{t}^{y} +
  \mathbf{u}_{t}^{p}, \nonumber
\end{align}

\end{document}

enter image description here

Done simply with a \nonumber command before the \\ of the first line, a \tag command before the \\ of the second line and a final \nonumber at the end of the last line, using the align environment.

Also, you might like to consider using \smash[b]{...} (as recommended by barbara beeton in the comments) to tighten up the equation and remove that considerable chasm. Whatever you think looks best:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\setcounter{equation}{2}

\begin{align}
  \mathbf{P}_{t} = \smash[b]{\sum_{j = 1}^{\rho}} (\mathbf{I} &-
  \mathbf{G}_{0})^{-1} [\mathbf{D}_{j} + \mathbf{D}_{0} (\mathbf{I} -
  \mathbf{B}_{0})^{-1} \mathbf{B}_{j}] \mathbf{Y}_{t - j} \nonumber
  \\
  &+ \sum_{j = 1}^{\rho} (\mathbf{I} - \mathbf{G}_{0})^{-1}
  [\mathbf{G}_{j} + \mathbf{D}_{0} (\mathbf{I} - \mathbf{B}_{0})^{-1}
  \mathbf{C}_{j}] \mathbf{P}_{t - j} \tag{\theequation$'$} \\
  &+ (\mathbf{I} - \mathbf{G}_{0})^{-1} \mathbf{D}_{0} (\mathbf{I} -
  \mathbf{B}_{0})^{-1} \mathbf{A}^{y} \mathbf{v}_{t}^{y} +
  \mathbf{u}_{t}^{p}, \nonumber
\end{align}

\end{document}

enter image description here

An alternative with split, where lines are “equalized” by smashing the summation symbols and inserting a vertical phantom:

\documentclass{article}
\usepackage{amsmath}

\newcommand{\bv}[1]{\mathbf{#1}}

\begin{document}

\setcounter{equation}{2}

\begin{equation}
\begin{split}
\vphantom{\Bigg|}
\bv{P}_{t} =
  \smash{\sum_{j = 1}^{\rho}}
  (\bv{I} &- \bv{G}_{0})^{-1}
    [\bv{D}_{j} + \bv{D}_{0} (\bv{I} - \bv{B}_{0})^{-1} \bv{B}_{j}] \bv{Y}_{t - j}
\vphantom{\Bigg|}
  \\
  &+ \smash{\sum_{j = 1}^{\rho}} (\bv{I} - \bv{G}_{0})^{-1}
    [\bv{G}_{j} + \bv{D}_{0} (\bv{I} - \bv{B}_{0})^{-1}
    \bv{C}_{j}] \bv{P}_{t - j}
  \\
\vphantom{\Bigg|}
  &+ (\bv{I} - \bv{G}_{0})^{-1} \bv{D}_{0} (\bv{I} -
    \bv{B}_{0})^{-1} \bv{A}_{\vphantom{t}}^{y} \bv{v}_{t}^{y} + \bv{u}_{t}^{p},
\end{split}
\tag{\theequation$'$}
\end{equation}

\end{document}

enter image description here

Finally, some advice, please avoid using \left and \right unless you need them, see for example:

  • 1
    Nitpicking: \mathbf{A}_{\vphantom{t}}^{y} in the last line – egreg Jul 15 '16 at 7:30
  • 2
    I've taken the liberty of adding a variant on your second solution – egreg Jul 15 '16 at 7:48
  • Thank you @egreg, it does look very nice that way, I'm sure your approach would have stood very well as an answer on its own and by all means feel free to post it, but thanks for the extra help :) – Au101 Jul 15 '16 at 15:25
1

Here is an example:

\documentclass[12pt,reqno]{amsart}

\usepackage{newtxmath}

\begin{document}

\setcounter{equation}{1}
\renewcommand\theequation{\arabic{equation}$'$}
\begin{align}
\mathbf {\mathbf{P}}_{t} =& \sum_{j=1}^{\rho } \left ( {\mathbf{I}} - {\mathbf{G}}_{0} \right )^{-1} \left [ {\mathbf{D}}_{j} + {\mathbf{D}}_{0}  \left ( {\mathbf{I}} - {\mathbf{B}}_{0} \right )^{-1} {\mathbf{B}}_{j}\right ] Y_{t-j}\nonumber\\
               &\quad+ \sum_{j=1}^{\rho } \left ( {\mathbf{I}} - {\mathbf{G}}_{0} \right )^{-1} \left [ {\mathbf{G}}_{j} + {\mathbf{D}}_{0}  \left ( {\mathbf{I}} - {\mathbf{B}}_{0} \right )^{-1} {\mathbf{C}}_{j}\right ] {\mathbf{P}}_{t-j} \nonumber \\
               &\quad+ \left ( {\mathbf{I}} - {\mathbf{G}}_{0} \right )^{-1} {\mathbf{D}}_{0} \left ( {\mathbf{I}} - {\mathbf{B}}_{0} \right )^{-1}{\mathbf{A}}^{y} {\mathbf{v}}_{t}^{y} + {\mathbf{u}}^{p}_{t}, \label{eqn:{2}'}
\end{align} 

\end{document}

Preview:

enter image description here

1

What about helping yourself with a macro:

\newcomand{\foo}[2][]{\ensuremath{\mathbf{#2}_{#1}}}

used in @Jagath AR's answer

\begin{align}
  \foo P[t]=\sum_{j=1}^\rho (\foo I-\foo G[0])^{-1} ... \nonumber
  & ... \nonumber
  & ... \foo A^y\foo v[t]^y+\foo u[t]^p
\end{align}
  • What's \ensuremath for? – egreg Jul 15 '16 at 11:29
  • If you want to use the command outside math or displaymath environment. – Crowley Jul 15 '16 at 11:33
  • Why would you? Just to clutter your typescript? ;-) Using $\foo{A}$ when the variable is in the text is much clearer and not more difficult to type. – egreg Jul 15 '16 at 11:36
  • I'd prefer \( \foo A\) and for sentences full of variables I'm sometimes getting lost... – Crowley Jul 15 '16 at 13:01
1

I propose two other solutions: one with multline, the other with align and an alignment of the equation number between the second and last line, as in the image of the question:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{array, mathtools}

\newtagform{prime}{(}{$'$)}

\begin{document}

\setcounter{equation}{1}
\usetagform{prime}
\begin{multline}
  \mathbf{P}_{t} ={∑_{j = 1}^{ρ}} (\mathbf{I}- \mathbf{G}_{0})⁻¹ [\mathbf{D}_{j} + \mathbf{D}_{0} (\mathbf{I} -
  \mathbf{B}_{0})⁻¹ \mathbf{B}_{j}] \mathbf{Y}_{t - j}
  \\[-3ex]
  + {∑_{j = 1}^{ρ}} (\mathbf{I} - \mathbf{G}_{0})⁻¹
  [\mathbf{G}_{j} + \mathbf{D}_{0} (\mathbf{I} - \mathbf{B}_{0})⁻¹
    \mathbf{C}_{j}] \mathbf{P}_{t - j} \\[-1.5ex]
    + {}(\mathbf{I} - \mathbf{G}_{0})⁻¹ \mathbf{D}_{0} (\mathbf{I} -
    \mathbf{B}_{0})⁻¹ \mathbf{A}^{y} \mathbf{v}_{t}^{y} +   \mathbf{u}_{t}^{p},
  \end{multline}


  \begin{align}
    \mathbf{P}_{t} ={∑_{j = 1}^{ρ}}(\mathbf{I} & - \mathbf{G}_{0})⁻¹ [\mathbf{D}_{j} + \mathbf{D}_{0} (\mathbf{I} -
    \mathbf{B}_{0})⁻¹ \mathbf{B}_{j}] \mathbf{Y}_{t - j} \notag
    \\[-0.5ex]
                                                     & \begin{array}{@{} >{\displaystyle}l@{}}
    {}+ \smash[t]{∑_{j = 1}^{ρ}} (\mathbf{I} - \mathbf{G}_{0})⁻¹
    [\mathbf{G}_{j} + \mathbf{D}_{0} (\mathbf{I} - \mathbf{B}_{0})⁻¹
    \mathbf{C}_{j}] \mathbf{P}_{t - j} \\
    \phantom{\sum}  +  (\mathbf{I} - \mathbf{G}_{0})⁻¹ \mathbf{D}_{0} (\mathbf{I} -
    \mathbf{B}_{0})⁻¹ \mathbf{A}^{y} \mathbf{v}_{t}^{y} +
    \mathbf{u}_{t}^{p},
    \end{array}
  \end{align}

\end{document} 

enter image description here

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.