Graphics, Figures & TablesHow can we number a matrix with row/column names?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
jjmm
Posts: 13
Joined: Tue Jul 12, 2016 5:23 am

How can we number a matrix with row/column names?

Post by jjmm »

Hi,

We know how to label a matrix and reference it. It is done by \label and \ref. Could we label a matrix with a label and reference it likewise?

This matrix with a label is from here

https://tex.stackexchange.com/questions ... characters

Code: Select all

\documentclass[12pt]{report}
\usepackage{blkarray}
\usepackage{amsmath}

\begin{document}

\[
\begin{blockarray}{cccccc}
a & b & c & d & e \\
\begin{block}{(ccccc)c}
  1 & 1 & 1 & 1 & 1 & f \\
  0 & 1 & 0 & 0 & 1 & g \\
  0 & 0 & 1 & 0 & 1 & h \\
  0 & 0 & 0 & 1 & 1 & i \\
  0 & 0 & 0 & 0 & 1 & j \\
\end{block}
\end{blockarray}
 \]

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

How can we number a matrix with row/column names?

Post by Johannes_B »

You chose an unnumbered math environment. Simply use a numbered one.

Code: Select all

\documentclass[12pt]{report}
    \usepackage{blkarray}
    \usepackage{amsmath}
     
    \begin{document}
     
     \begin{equation}
    \begin{blockarray}{cccccc}
    a & b & c & d & e \\
    \begin{block}{(ccccc)c}
      1 & 1 & 1 & 1 & 1 & f \\
      0 & 1 & 0 & 0 & 1 & g \\
      0 & 0 & 1 & 0 & 1 & h \\
      0 & 0 & 0 & 1 & 1 & i \\
      0 & 0 & 0 & 0 & 1 & j \\
    \end{block}
    \end{blockarray}
\label{matrix}
     \end{equation}
     
look at \ref{matrix}
    \end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
jjmm
Posts: 13
Joined: Tue Jul 12, 2016 5:23 am

How can we number a matrix with row/column names?

Post by jjmm »

Thank you, Johannes! It works!
Post Reply