1

Basically I would like to have the following in a single line instead of the line break right before \begin{alignat}

$\begin{pmatrix}
component1 \\ component2
\end{pmatrix}=$\begin{alignat}{2}
0 \label{eq:first}\\    
0 \label{eq:second}
\end{alignat}

So, how can I use a vectors components to reference/label it like an equation?

Arun Debray
  • 7,126
  • 2
  • 30
  • 54
John Doe
  • 145

1 Answers1

2

I was able to adapt this answer to this context. It seems a bit hacky, but appears to do the job, and even works with hyperref.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\newsavebox{\mymatrix}
\begin{align} \sbox{\mymatrix}{$\displaystyle
    \begin{pmatrix}
    \mathit{component}_1 \\ \mathit{component}_2
    \end{pmatrix} \hspace{1ex} = \hspace{2ex}
$}\raisebox{-.5\ht\mymatrix}[0pt][0pt]{\usebox{\mymatrix}}
    0 \label{eggs} \\
    0 \label{wine}
\end{align}
Now, I refer to \eqref{eggs} and \eqref{wine}.
\end{document}

enter image description here

If you want to place delimiters around the second vector, you can place the entire equation into the \mymatrix box and blank space into the second part, as follows:

\newsavebox{\mymatrix}
\begin{align} \sbox{\mymatrix}{$\displaystyle
    \begin{pmatrix}
    \mathit{component}_1 \\ \mathit{component}_2
    \end{pmatrix} = \begin{pmatrix}
    0 \\
    0
    \end{pmatrix}
$}\raisebox{-.5\ht\mymatrix}[0pt][0pt]{\usebox{\mymatrix}}
 \label{eggs} \\
 \label{wine}
\end{align}

This method is a little cleaner, and might be better even if you don't want to delimit the second vector.

enter image description here

Arun Debray
  • 7,126
  • 2
  • 30
  • 54