2

I have the following problem:

enter image description here

Obviously I want the = to be aligned and I need two lines for the equation following the third =.

Also I'm not so sure whether I used the \big{[} and \big{]} commands correctly!?

Code so far as follows:

\documentclass[12pt, a4paper] {article}
\usepackage{amsmath}
\DeclareMathOperator{\var}{var}
\usepackage{mathdesign}
\renewcommand{\vec}[1]{\mathbf{#1}}

\begin{document}
\begin{equation}
\begin{split}
\vec{V}_i &= E[\boldsymbol{\hat{\vec{\varepsilon}}}^*_i \boldsymbol{\hat{\vec{\varepsilon}}}^*_{i}' \;\;|\;\; \vec{X}^*_i]\\
&= \big{[}[\boldsymbol{\vec{\varepsilon}}^*_i - \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i)] [\boldsymbol{\vec{\varepsilon}}^*_i - \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i)]' \;\;|\;\; \vec{X}^*_{i}\big{]}
&= E[\boldsymbol{\vec{\varepsilon}}^*_i \boldsymbol{\vec{\varepsilon}}^*_{i}' - \boldsymbol{\vec{\varepsilon}}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i)' \vec{X}^*_{i}' - \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i) \boldsymbol{\vec{\varepsilon}}^*_{i}'\\ + \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i) (\hat{\vec{\theta}}_i - \vec{\theta}_i)' \vec{X}^*_{i}' \;\;|\;\; \vec{X}^*_i]\\
&= \vec{I} \sigma^2_{\boldsymbol{\vec{\varepsilon}}^*_{i}} + \vec{X}^*_i (\vec{X}'_i \vec{X}_i)^{-1} \vec{X}^*_{i}' \sigma^2_{\boldsymbol{\vec{\varepsilon}}^*_{i}}.
\label{eq: covariance}
\end{split}
\end{equation}

\end{document}
0

5 Answers 5

2

You can use the multlined environment from mathtools. I also defined an \EV command, that works with a given command (following an example in the mathtools documentation). It has a simple syntax (\EV{A \given B} and gives a correct spacing for the Expected Value, and has delimiters and vertical line that adapt to the contents size in the star version; otherwise, it can take an optional argument (\big, \Big, &c.) for the size. Unfortunately, it doesn't work with line breaks, so the multilined part had to be done by hand.

\documentclass[12pt, a4paper] {article}
\usepackage{mathtools}
\DeclareMathOperator{\var}{var}
\usepackage{mathdesign}
\renewcommand{\vec}[1]{\mathbf{#1}}

\providecommand\given{}
\DeclarePairedDelimiterXPP\EV[1]{E}[]{}{
\renewcommand\given{\nonscript\;\delimsize\vert\nonscript\;\mathopen{}}
#1}
\begin{document}

\begin{equation}
\begin{split}
\vec{V}_i &= \EV*{\boldsymbol{\hat{\vec{\varepsilon}}}^{*}_i \boldsymbol{\hat{\vec{\varepsilon}}^{*} _i}{'}\given \vec{X}^{*}_i}\\
&= \EV[\big]{[\boldsymbol{\vec{\varepsilon}}^*_i - \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i)] [\boldsymbol{\vec{\varepsilon}}^*_i - \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i)]' \given \vec{X}^*_{i}}\\
&=\!\begin{multlined}[t]E\bigl[\boldsymbol{\vec{\varepsilon}}^*_i \boldsymbol{\vec{\varepsilon}}^*_{i}{'} - \boldsymbol{\vec{\varepsilon}}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i)' \vec{X}^*_{i}{'} - \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i) \boldsymbol{\vec{\varepsilon}}^*_{i}{'}\\
+ \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i) (\hat{\vec{\theta}}_i - \vec{\theta}_i)' \vec{X}^*_{i}{'} \;\big\vert\; \vec{X}^*_i\bigr]
\end{multlined}\\
&= \vec{I} \sigma^2_{\boldsymbol{\vec{\varepsilon}}^*_{i}} + \vec{X}^*_i (\vec{X}'_i \vec{X}_i)^{-1} \vec{X}^*_{i}{'} \sigma^2_{\boldsymbol{\vec{\varepsilon}}^*_{i}}.
\label{eq: covariance}
\end{split}
\end{equation}

\end{document} 

enter image description here

1

Insert a \phantom equality sign (with appropriate spacing around it - as in {}={}) and add \qquad to push that part of the equation to the right.

Here is a mock-up of what it will look like, using strutted boxes to represent your equation components:

enter image description here

\documentclass{article}
\usepackage{amsmath}

\newcommand{\strutboxed}[1]{\boxed{\mathstrut\rule{#1}{0pt}}}

\begin{document}
\begin{equation}
  \begin{split}
    \strutboxed{2em} &= \strutboxed{15em} \\
                     &= \strutboxed{20em} \\
                     &= \strutboxed{15em} \\
                     &\phantom{{}={}} \qquad \strutboxed{10em} \\
                     &= \strutboxed{12em}.
  \end{split}
\end{equation}

\end{document}

You should also use \bigL[ and/or \bigR] and friends rather than \big. See the amsmath user guide for more information on these and other pairs:

enter image description here

1

i was stopped short by the error

! Double superscript.

which was caused by several instances of this sub/superscript combination:

\vec{X}^*_{i}'

the ^* and ' are both superscripts, and, although this may not be immediately obvious, tex wants to consider them as a single group. so either precede the apostrophe (prime) by an empty group {} to separate it from the asterisk, or combine them as ^{*\prime}. (i believe the separation is what is wanted.)

also, the second line needs \\ at the end, and the line after the third = needs & plus some space at the beginning to indent it, as well as {} before the plus to get the correct spacing for a binary operator.

here is the repaired display:

\documentclass[12pt, a4paper] {article}
\usepackage{amsmath}
\DeclareMathOperator{\var}{var}
\usepackage{mathdesign}
\renewcommand{\vec}[1]{\mathbf{#1}}

\begin{document}
\begin{equation}
\begin{split}
\vec{V}_i &= E[\boldsymbol{\hat{\vec{\varepsilon}}}^*_i
  \boldsymbol{\hat{\vec{\varepsilon}}}^*_{i}{}' \;\;|\;\; \vec{X}^*_i]\\
&= \big{[}[\boldsymbol{\vec{\varepsilon}}^*_i
  - \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i)]
    [\boldsymbol{\vec{\varepsilon}}^*_i - \vec{X}^*_i (\hat{\vec{\theta}}_i
  - \vec{\theta}_i)]' \;\;|\;\; \vec{X}^*_{i}\big{]}\\
&= E[\boldsymbol{\vec{\varepsilon}}^*_i \boldsymbol{\vec{\varepsilon}}^*_{i}{}'
 - \boldsymbol{\vec{\varepsilon}}^*_i (\hat{\vec{\theta}}_i
 - \vec{\theta}_i)' \vec{X}^*_{i}{}' - \vec{X}^*_i (\hat{\vec{\theta}}_i
 - \vec{\theta}_i) \boldsymbol{\vec{\varepsilon}}^*_{i}{}'\\
& \qquad{}
 + \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i) (\hat{\vec{\theta}}_i
 - \vec{\theta}_i)' \vec{X}^*_{i}{}' \;\;|\;\; \vec{X}^*_i]\\
&= \vec{I} \sigma^2_{\boldsymbol{\vec{\varepsilon}}^*_{i}}
 + \vec{X}^*_i (\vec{X}'_i \vec{X}_i)^{-1} \vec{X}^*_{i}{}'
   \sigma^2_{\boldsymbol{\vec{\varepsilon}}^*_{i}}.
\label{eq: covariance}
\end{split}
\end{equation}

\end{document}

output of example code

1

Following your question-answer, I thought "why not just use an align instead of two equations?". I tried it out and it worked, so here it is. Note: \DeclarePairedDelimiterXPP just won't work for me. I must have an outdated mathtools. You can put it back in. I substituted it with E\big[ and E[.

\documentclass[12pt, a4paper] {article}
\usepackage{mathtools}
\DeclareMathOperator{\var}{var}
\usepackage{mathdesign}
\renewcommand{\vec}[1]{\mathbf{#1}}

\providecommand\given{}
\begin{document}


I expect the abnormal returns to be jointly normally distributed with a zero conditional mean and conditional covariance matrix $\vec{V}_i$, to, as Campbell, et al show, get:
\begin{align}
\begin{split}
E[\boldsymbol{\hat{\vec{\varepsilon}}}^*_i \;\;|\;\; \vec{X}^*_i] &= E[\vec{R}^*_i - \vec{X}^*_i \hat{\vec{\theta}}_i \;\;|\;\; \vec{X}^*_i]\\
&= E[(\vec{R}^*_i - \vec{X}^*_i \hat{\vec{\theta}}_i) - \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i) \;\;|\;\; \vec{X}^*_i]\\
&= 0.
\label{eq: expectedmean}
\end{split}\\
\begin{split}
\vec{V}_i &= E[\boldsymbol{\hat{\vec{\varepsilon}}}^{*}_i \boldsymbol{\hat{\vec{\varepsilon}}^{*} _i}{'}\given \vec{X}^{*}_i]\\
&= E\big[[\boldsymbol{\vec{\varepsilon}}^*_i - \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i)] [\boldsymbol{\vec{\varepsilon}}^*_i - \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i)]' \given \vec{X}^*_{i}\big]\\
&=\!
\begin{multlined}[t]
E\bigl[\boldsymbol{\vec{\varepsilon}}^*_i \boldsymbol{\vec{\varepsilon}}^*_{i}{'} - \boldsymbol{\vec{\varepsilon}}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i)' \vec{X}^*_{i}{'} - \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i) \boldsymbol{\vec{\varepsilon}}^*_{i}{'}\\
+ \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i) (\hat{\vec{\theta}}_i - \vec{\theta}_i)' \vec{X}^*_{i}{'} \;\big\vert\; \vec{X}^*_i\bigr]
\end{multlined}\\
&= \vec{I} \sigma^2_{\boldsymbol{\vec{\varepsilon}}^*_{i}} + \vec{X}^*_i (\vec{X}'_i \vec{X}_i)^{-1} \vec{X}^*_{i}{'} \sigma^2_{\boldsymbol{\vec{\varepsilon}}^*_{i}}.
\label{eq: covariance}
\end{split}
\end{align}

\end{document}

The labeling also works fine.

2
  • You should add some vertical spacing between the two split environments — something like \\[2ex]. As for `mathtools, I use version 1.5, dated 2014/08/04.
    – Bernard
    Commented Dec 13, 2014 at 12:43
  • Yeah it's probably a good idea. Then again, it's the OP's business, and I guess he can do that :). As for mathtools, I have \ProvidesPackage{mathtools}% [2013/02/12 v1.13 mathematical typesetting tools]. I will consider updating :).
    – MickG
    Commented Dec 13, 2014 at 13:48
0

Thanks, Bernard for your help.

However I do encounter another problem now aligning this equations with my previous ones.

\documentclass[12pt, a4paper] {article}
\usepackage{mathtools}
\DeclareMathOperator{\var}{var}
\usepackage{mathdesign}
\renewcommand{\vec}[1]{\mathbf{#1}}

\providecommand\given{}
\DeclarePairedDelimiterXPP\EV[1]{E}[]{}{
\renewcommand\given{\nonscript\;\delimsize\vert\nonscript\;\mathopen{}}
#1}
\begin{document}


I expect the abnormal returns to be jointly normally distributed with a zero conditional mean and conditional covariance matrix $\vec{V}_i$, to, as Campbell, et al show, get:
\begin{equation}
\begin{split}
E[\boldsymbol{\hat{\vec{\varepsilon}}}^*_i \;\;|\;\; \vec{X}^*_i] &= E[\vec{R}^*_i - \vec{X}^*_i \hat{\vec{\theta}}_i \;\;|\;\; \vec{X}^*_i]\\
&= E[(\vec{R}^*_i - \vec{X}^*_i \hat{\vec{\theta}}_i) - \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i) \;\;|\;\; \vec{X}^*_i]\\
&= 0.
\label{eq: expectedmean}
\end{split}
\end{equation}

\begin{equation}
\begin{split}
\vec{V}_i &= \EV*{\boldsymbol{\hat{\vec{\varepsilon}}}^{*}_i \boldsymbol{\hat{\vec{\varepsilon}}^{*} _i}{'}\given \vec{X}^{*}_i}\\
&= \EV[\big]{[\boldsymbol{\vec{\varepsilon}}^*_i - \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i)] [\boldsymbol{\vec{\varepsilon}}^*_i - \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i)]' \given \vec{X}^*_{i}}\\
&=\!\begin{multlined}[t]E\bigl[\boldsymbol{\vec{\varepsilon}}^*_i \boldsymbol{\vec{\varepsilon}}^*_{i}{'} - \boldsymbol{\vec{\varepsilon}}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i)' \vec{X}^*_{i}{'} - \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i) \boldsymbol{\vec{\varepsilon}}^*_{i}{'}\\
+ \vec{X}^*_i (\hat{\vec{\theta}}_i - \vec{\theta}_i) (\hat{\vec{\theta}}_i - \vec{\theta}_i)' \vec{X}^*_{i}{'} \;\big\vert\; \vec{X}^*_i\bigr]
\end{multlined}\\
&= \vec{I} \sigma^2_{\boldsymbol{\vec{\varepsilon}}^*_{i}} + \vec{X}^*_i (\vec{X}'_i \vec{X}_i)^{-1} \vec{X}^*_{i}{'} \sigma^2_{\boldsymbol{\vec{\varepsilon}}^*_{i}}.
\label{eq: covariance}
\end{split}
\end{equation}

\end{document} 

Gives me the following output:enter image description here

Whereas I'd like to align equation (2)'s = to the right to be in line with equation (1)'s =, because I have previous equations having their = at the same horizontal measures as equation 1.

Thanks!

1
  • Comment aside, if you load mathdesign with no font option, your document will use the default Computer Modern.
    – Bernard
    Commented Dec 13, 2014 at 12:50

You must log in to answer this question.

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