3
$\begingroup$

$$ \qquad \quad \ \ 1 \ \ \ \ 2 \ \ \ \ \ 3 \ \ \ \ 4 \ \ \ \ 5 \ \ \ \ \ \\ A = \begin{bmatrix} h & e & l & l & o \\ m & s & e & * & * \\ m & e & t & a & * \end{bmatrix}$$

$$
\qquad \qquad 1 \ \ \ \  2 \ \ \ \ \ 3 \ \ \ \ 4 \ \ \ \ 5 \ \ \ \ \ \\
A = \begin{bmatrix}
h & e & l & l & o \\
m & s & e & * & * \\
m & e & t & a & *
\end{bmatrix}$$

Is there a way I can indicate the numbers of the rows and columns to the sides/top/bottom of my matrix less painfully? If not, this is a feature request.

| |
$\endgroup$
3
$\begingroup$

Here is something close to what you wanted: $$ \begin{array}{cc} & \begin{array}{ccccc} 1 & 2 & 3 & 4 & 5\\ \end{array} \\ A = & \left[ \begin{array}{ccccc} h & e & l & l & o \\ m & s & e & * & * \\ m & e & t & a & * \end{array} \right] \end{array} $$

I learned it from http://latex-tricks.blogspot.com/2009/11/matrix-with-row-and-column-labels.html

Essentially you use the nested array environment here so that you don't need to adjust the spaces between the labels.


$$
\begin{array}{cc} 
&
\begin{array}{ccccc} 1 & 2 & 3 & 4 & 5\\
\end{array}
\\
A =
&
\left[
\begin{array}{ccccc}
h & e & l & l & o \\
m & s & e & * & * \\
m & e & t & a & *
\end{array}
\right]
\end{array}
$$

[Added] The example in the linked post above gave the following example, which also has row labels: $$ \begin{array}{c c} & \begin{array}{c c c} a & b &c \\ \end{array} \\ \begin{array}{c c c} p \\ q\\ r \end{array} & \left[ \begin{array}{c c c} .1 & .1 & 0 \\ .4 & 1 & 0 \\ .8 & 0 & .4 \end{array} \right] \end{array} $$

$$
\begin{array}{c c} 
& \begin{array}{c c c} a & b &c \\ \end{array} \\
\begin{array}{c c c}p\\q\\r \end{array} &
\left[
\begin{array}{c c c}
.1 & .1 & 0 \\
.4 & 1 & 0 \\
.8 & 0 & .4
\end{array}
\right]
\end{array}
$$
| |
$\endgroup$
  • 1
    $\begingroup$ Thanks for the tip. Any way to label the rows? $\endgroup$ – jeremy909 May 2 at 0:54
  • $\begingroup$ @jeremy909: yes, basically it is in the linked blog post. What kind of row labels are you expecting? $\endgroup$ – T. S May 3 at 15:24
  • $\begingroup$ Your edit is exactly what I wanted. Thanks for the help!! $\endgroup$ – jeremy909 May 3 at 17:29
  • $\begingroup$ @jeremy909: You are welcome! $\endgroup$ – T. S May 3 at 19:57
1
$\begingroup$

Not a working answer on MSE since the physics package cannot be imported via \require{physics} here, but if otherwise, the following code would produce what you want:

\begin{matrix}
\mqty{1 & 2 & 3 & 4 & 4}\\
\mqty[h & e & l & l & o \\
m & s & e & * & * \\
m & e & t & a & *]
\end{matrix}

Note that AMS-related packages available in MathJax provide no functionality to achieve the desired effect. Having reposted this question on LaTeX SE (see here), I learned from @DavidCarlisle's comment that currently this might be impossible to achieve with MathJax:

… [M]athjax doesn't use tex at all, some javascript emulates some latex packages but any such emulation has to be written from scratch in javascript, it can't use the package code.

If you really need this effect, you may ask a question on SE using the mathjax tag.

| |
$\endgroup$

You must log in to answer this question.

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