# How to typeset matrix inside aligned environment?

Could you help to comment how to typeset matrix inside aligned environment ? The following code gives a lot of "Missing \$ inserted" when pdflatex... Many thanks !

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\title{}         % Enter your title between curly braces
\author{}        % Enter your name between curly braces
\date{}          % Enter your date or \today between curly braces
\maketitle

\begin{aligned} a = \left(\begin{matrix} a_{1} \\ a_{2} \\ a_{3} \end{matrix}\right) \text{in the basis } \{\vec{e}_i\} \\ a = \left(\begin{matrix} a'_{1} \\ a'_{2} \\ a'_{3} \end{matrix}\right) \text{in the basis } \{\vec{\varepsilon}_i\} \end{aligned}

\end{document}

• the answer given is good. but it fails to mention that blank lines aren't allowed in any math environment. (this is for the purpose of syntax checking, and can't be changed.) – barbara beeton Apr 29 '18 at 2:45
• I need aligned inside instead of align*. Could you help to suggest how to achieve this ? – SOUser Apr 29 '18 at 3:28 ## 1 Answer I'm not certain what final result you are after (in terms of the exact place you want alignment or whether this is a fragment of something larger), but you could use \begin{align*}... to set these equations:  \begin{align*} a &= \left(\begin{matrix} a_{1} \\ a_{2} \\ a_{3} \end{matrix}\right) \text{in the basis } \{\vec{e}_i\} \\ a &= \left(\begin{matrix} a'_{1} \\ a'_{2} \\ a'_{3} \end{matrix}\right) \text{in the basis } \{\vec{\varepsilon}_i\} \end{align*}  • shorter is \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*} a & = \begin{pmatrix} a_{1} \\ a_{2} \\ a_{3} \end{pmatrix} \text{ in the basis } \{\vec{e}_i\} \\ a &= \begin{pmatrix} a'_{1} \\ a'_{2} \\ a'_{3} \end{pmatrix} \text{ in the basis } \{\vec{\varepsilon}_i\} \end{align*} \end{document}  – Zarko Apr 28 '18 at 17:50 • I need aligned inside  instead of align*. Could you help to suggest how to achieve this ? – SOUser Apr 29 '18 at 3:27
• @SOUser You should be able to replace \begin{align*} by \[ \begin{aligned}  (and similar at the end) in the code block above to get the same result. As Barbara Beeton correctly pointed out, your error message resulted from the blank line in your original post. – John Apr 29 '18 at 12:10