答案1
一定要叫矩阵吗?还是表格也可以?
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{bigdelim}
\begin{document}
\begin{tabular}{l c c c c l}
& & \color{blue}From: & & & \\
& \color{blue}D & \color{blue}R & \color{blue}L & & \color{blue}To: \\
\ldelim[{3}{*}[P = ] & .70 & .10 & .30 &\rdelim]{3}{*} & \color{blue}D \\
& .20 & .80 & .30 & & \color{blue}R \\
& .10 & .10 & .40 & & \color{blue}L \\
\end{tabular}
\end{document}
答案2
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{bigdelim}
\begin{document}
\begin{tabular}{l c c c c >{\color{blue}}l}
& & \color{blue}From: \\
& \color{blue}D & \color{blue}R & \color{blue}L & & To: \\
\ldelim[{3}{*}[P = ] & .70 & .10 & .30 &\rdelim]{3}{*} & D \\
& .20 & .80 & .30 & & R \\
& .10 & .10 & .40 & & L \\
\end{tabular}
\end{document}
答案3
您将需要昨天的 [2016-11-30]tabstackengine
版本 V2.01 才能如此简单地完成此操作。
\documentclass{article}
\usepackage{tabstackengine}[2016-11-30]
\usepackage{xcolor}
\begin{document}
\[
\fixTABwidth{T}
\savestack\thematrix{$\bracketMatrixstack{~~.70~~ & .10 & .30\\.20&.80&.30\\.10&.10&.40}$}
P = \color{cyan}\stackon{\thematrix}{
\stackon[5pt]{\makebox[\maxTABwd]{D}\makebox[\maxTABwd]{R}\makebox[\maxTABwd]{L}}{From:}
} ~~\renewcommand\stackalignment{l}\stackon{\Centerstack[c]{D\\R\\L}}{To:}
\]
\end{document}
还有一种变体:
\documentclass{article}
\usepackage{tabstackengine}[2016-11-30]
\usepackage{xcolor}
\begin{document}
\[
\setstacktabbedgap{2ex}
\setstackgap{L}{1.2\baselineskip}
\savestack\thematrix{$\bracketMatrixstack{.70 & .10 & .30\\.20&.80&.30\\.10&.10&.40}$}
P = \color{cyan}\stackon[6pt]{\thematrix}{
\stackon[5pt]{%
\makebox[\TABwd{1}]{D}\kern2ex\makebox[\TABwd{2}]{R}\kern2ex\makebox[\TABwd{3}]{L}}{From:}
} ~~\renewcommand\stackalignment{l}\stackon[6pt]{\Centerstack[c]{D\\R\\L}}{To:}
\]
\end{document}
答案4
这里有一个blkarray
执行:
\documentclass{article}
\usepackage{blkarray,xcolor}
\newcommand{\chead}[1]{\mbox{\small\color{cyan}#1}}
\begin{document}
\[
\begin{blockarray}{ r @{} *{3}{c} >{\color{cyan}}c }
& & \chead{\makebox[0pt]{From:}} \\
& \chead{$D$} & \chead{$R$} & \chead{$L$} & \chead{\makebox[0pt]{To:}} \\
\begin{block}{ r @{} [ *{3}{c} ] >{\color{cyan}}c }
& .70 & .10 & .30 & D \\
P =~ & .20 & .80 & .30 & R \\
& .10 & .10 & .40 & L \\
\end{block}
\end{blockarray}
\]
\end{document}