LaTeX formats the equation wrong and doesnt show the whole equation in the output

This is how it looks like in LaTeX. And it should be looking like the handwriting here:

I need the explanation with the down pointed brace, because these are complex numbers and hard to understand, when i look before the exam on it. But unfortunately, with \begin{equation*} etc. alone i cant make the "=" and so on not among themselves. I need here the align. But for the underbraces i need the \begin{equation*} etc. So I dont know how to manage this mess. Hope i get a quick answer :s This is the code:

\begin{align*}
\Vec{a}&= \begin{pmatrix*}[r] a_1\\a_2 \end{pmatrix*} \in \mathbb{C}^2\\
\bar{\Vec{a}}&= \begin{pmatrix*}[r] \bar{a}_1\\ \bar{a}_2 \end{pmatrix*}\\
\Vec{a}&= \begin{pmatrix*}[r] 1-2i\\1+2i \end{pmatrix*}\\
\bar{\Vec{a}}&= \begin{pmatrix*} 1+2i\\1-2i \end{pmatrix*}\\
(\bar{\Vec{a}})^T &= (a+2i;1-2i)\\
\Vec{b}&= \begin{pmatrix*}[r] i\\-i \end{pmatrix*}\\
\langle \Vec{a},\Vec{b} \rangle &= (1+2i;1-2i) \cdot \begin{pmatrix*}[r] i\\-i \end{pmatrix*}\\
&=  \begin{equation*}
\underbrace{(1+2i}_{\substack{a_1}}\underbrace{i}_{\substack{b_1}}+ \underbrace{(1-2i)}_{\substack{a_2}} \cdot \underbrace{(-i)}_{\substack{b_2}}\\
\end{equation*}
&= i = 2i^2-i+2i^2\\
&= i^2=-1\\
&= \sout{i}-\sout{i}-2-2\\
&= -4
\end{align*}

• Would you mind posting a full compilable code? Where does the \Vect (with an =uppercase V) come from? I had to remember \sout is defined in ulem – Bernard Apr 29 '18 at 11:43
• In the LaTeX wiki, \sout was for crossing out, i need to cross the two "i". This is the code where LaTeX formats it wrong in the output. This is the exact Problem-Code. \vect is a vector. You can see from my handwriting post, how it has to begin. In the output, the order of the equation is a pure chaos and not how it has supposed to be. – Lillien Sabrina Gluch Apr 29 '18 at 11:56
• i mean, you see the right order in the handwriting. obviously you see in the handwriting, i was running out of space, but you can still see the order – Lillien Sabrina Gluch Apr 29 '18 at 11:57
• I could guess Vect was for a vector, but HOW is it defined? This is not standard LaTeX. – Bernard Apr 29 '18 at 12:01
• i am using sharelatex.com. and also in the wiki it says \vect{} for a vector – Lillien Sabrina Gluch Apr 29 '18 at 12:10

Here is a possibility. It seems \sout won't work in math mode,a,d anyway, overstriking a formula when there's a minus sign will make it invisible. That's why I suggest to use the \cancel command, from the nomonymous package:

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

\begin{document}

\begin{align*}
\vec{a}
&= \begin{pmatrix*}[r] a_1\\a_2 \end{pmatrix*} \in \mathbb{C}^2\\
\bar{\vec{a}}&= \begin{pmatrix*}[r] \bar{a}_1\\ \bar{a}_2 \end{pmatrix*}\\
\vec{a}
&= \begin{pmatrix*}[r] 1-2i\\1+2i \end{pmatrix*}\\
\bar{\vec{a}}&= \begin{pmatrix*} 1+2i\\1-2i \end{pmatrix*}\\
(\bar{\vec{a}})^T &= (a+2i;1-2i)\\
\vec{b}&= \begin{pmatrix*}[r] i\\-i \end{pmatrix*}\\
\langle\vec{a},\vec{b} \rangle &= (1+2i;1-2i) \cdot \begin{pmatrix*}[r] i\\-i \end{pmatrix*}\\
&= (\underbrace{1+2i}_{a_1})\mkern-2mu\underbracket[0.6pt]{\vphantom{(}\mkern2mu i\mkern2mu}_{b_1}\mkern-2mu+\mathrlap{ \underbrace{(1-2i)}_{a_2} (\underbracket[0.6pt]{\vphantom{(}- i}_{b_2})} \\
&= i + 2i^2-i+2i^2\\
&= \cancel{ i-i }-2-2 & &( i^2=-1) \\
&= -4
\end{align*}

\end{document}


• what does the mkern2mu, \mathrlap and \vphantom do? i dont know this – Lillien Sabrina Gluch Apr 29 '18 at 14:06
• \vphantom{(}inserts the height of its content (a parenthesis), here, so the terms under the braces or under the brackets are all at the same vertical position. \mathrlap says to the compiler to consider its content has 0 width; I added it to have the explanation i² = -1 not too far from the computation on the left. \mkern 2mu adds some mathematical kerning around i because the bracket would have too tight for my tast. mu is a length unit which is used only in math mode; its value is 1/18em (em is the width of M in the current font). For instance, a thinspace (\,) has length 3mu. – Bernard Apr 29 '18 at 14:27
• @Bernard -- although there are parentheses around the lst element "(-i)", they aren't included in the scope of the underbracket, so that's higher than the earlier one. you still need the \phantom`. – barbara beeton Apr 29 '18 at 15:51
• ah okay thanks :) now i know how i can use it in the future – Lillien Sabrina Gluch Apr 29 '18 at 15:57
• @barbarabeeton: That's right. I confess I didn't even check. I'll fix it in a moment. Thanks, milady! – Bernard Apr 29 '18 at 16:09