So I am writing a transition matrix for markov chains using the gauss
package. Here's what I have:
Code:
\documentclass[12pt]{article}
\usepackage{float}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{gauss}
\begin{document}
\begin{align*}
T\left(s, a_1, s^\prime\right) &=
\begin{bmatrix}
0 & 0.5 & 0.5 & 0 & 0\\
0 & 0 & 0 & 0.5 & 0.5\\
0 & 0 & 0 & 0.9 & 0.1 \\
0 & 0 & 0 & 1 & 0\\
0 & 0 & 0 & 0 & 1
\end{bmatrix}\\
T\left(s, a_1, s^\prime\right) &=
\begin{gmatrix}[b]
\mathllap{S_1\quad} 0 & 0.5 & 0.5 & 0 & 0\\
\mathllap{S_2\quad} 0 & 0 & 0 & 0.5 & 0.5\\
\mathllap{S_3\quad} 0 & 0 & 0 & 0.9 & 0.1 \\
\mathllap{S_4\quad} 0 & 0 & 0 & 1 & 0\\
\mathllap{S_5\quad} 0 & 0 & 0 & 0 & 1\colops
\def\colmultlabel#1{\makebox[1.2em]{$#1$}}
\mult0{S_1}
\mult1{S_2}
\mult2{S_3}
\mult3{S_4}
\mult4{S_5}
\end{gmatrix}\\
T\left(s, a_1, s^\prime\right) &=
\begin{bmatrix}
0 & 0.5 & 0.5 & 0 & 0\\
0 & 0 & 0 & 0.5 & 0.5\\
0 & 0 & 0 & 0.9 & 0.1 \\
0 & 0 & 0 & 1 & 0\\
0 & 0 & 0 & 0 & 1
\end{bmatrix}
\end{align*}
\end{document}
Output:
I realized that the gmatrix
outputs a normal matrix placed like a normal matrix from amsmath
, but the problem is that the labels do not get factored in. That is, the row and column labels do not create space for it to be separated from the equals sign on its line or the equation above.
How to fix it?
^\prime
when'
creates the identical output with much less input effort?\prime
gave me a bigger sign, and it wasn’t positioned correctly.\prime
in the document. I asked you why you would input^\prime
-- which is definitely not the same as\prime
-- given that'
creates the identical output but does so with much less input effort.