해당 코드와 함께 다음 행렬이 있습니다. 첨부된 이미지는 출력을 보여줍니다. 그 이미지를 학술 논문에 넣어야 하기 때문에 실제 디자인은 스타일 측면에서 조금 선을 넘었다고 생각했습니다. 즉, 좀 더 "수학적"으로 보이게 만들어야 한다는 뜻입니다.
\documentclass{standalone}
%\usepackage[showframe]{geometry}
\usepackage{tikz}
\definecolor{gris}{RGB}{250,250,250}
\usepackage{lmodern}
\usetikzlibrary{matrix,
positioning}
\tikzset{
mymatrix/.style = {matrix of nodes,
nodes in empty cells,
nodes={minimum height=3ex, minimum width=1em,
inner sep=0pt, outer sep=0pt, anchor=center,
draw, very thin,scale=0.8,transform shape},
column sep=0pt,
row sep=0pt,
inner sep=0.5\pgflinewidth, outer sep=1pt,
draw, thick},
empty node/.style = {draw,fill=gris},
every label/.append style = {font=\large, text=teal}
}
\makeatletter
\def\tikz@lib@matrix@empty@cell{%
\iftikz@lib@matrix@empty%
\node[name=\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn,empty node]{};\fi}
\makeatother
\usepackage{bm}
\newcommand{\MatrixVariable}[1]{\bm{{#1}}}
\begin{document}
\begin{tikzpicture}[node distance=0pt,scale=0.6,nodes={transform
shape}]
\matrix (m1) [mymatrix,
label={[rotate=90, anchor=south,black]left: Movies},
label={[black]below:$\MatrixVariable{{R}}$},
label={[black]above:Users},
nodes={fill=gray!30}]
{
1 & & 3 & & & 5 & & & 5 & & 4 & \\
& & 5 & 4 & & & 4 & & & 2 & 1 & 3 \\
2 & 4 & & 1 & 2 & & 3 & & 4 & 3 & 5 & \\
& 2 & 4 & & 5 & & & 4 & & & 2 & \\
& & 4 & 3 & 4 & 2 & & & & & 2 & 5 \\
1 & & 3 & & 3 & & & 2 & & & 4 & \\
};
\node (approx) [right=of m1,scale=2] {$\approx$};
\matrix (m2) [mymatrix=none, right=0.1em of approx,
label={[rotate=90, anchor=south east,xshift=-0.7em,black]left: Movies},
label={[black]below:$\MatrixVariable{{Q}}$},
label={[black]above:$f$-factors},
nodes={minimum width=2.2em,fill=white}]
{
0.1& -0.4 & -0.2 \\
-0.5& 0.6 & 0.5 \\
-0.2& 0.3 &0.5 \\
1.1& 2.1 & 0.3 \\
-0.7&2.1 & -2 \\
-1& 0.7 & 0.3 \\
};
\node (times) [right=of m2,scale=2] {$\cdot$};
\matrix (m3) [mymatrix=none, right=of times,
label={[rotate=90, anchor=north,black]right: $f$-factors},
label={[black]below:$\MatrixVariable{{P}^{T}}$},
label={[black]above:Users},
nodes={minimum width=2em,fill=white}]
{
1.1&-2 & 0.3 & 0.5 &-2 & -0.5 & 0.8 & -0.4 & 0.3 & 1.4 & 2.4 & -0.9\\
-0.8& 0.7 & 0.5 & 1.4 &0.3 & -1 & 1.4 & 2.9 & 0.7 & - 1.2 & 1.3& 0.4\\
2.1& -0.4 & 0.6 & 1.7 & 2.4 & 0.9 & -0.3 & 0.4 & 0.8 & 0.7 & -0.6&0.1 \\
};
\end{tikzpicture}
\end{document}
제가 염두에 둔 것은 다음과 같습니다.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\begin{pmatrix}
x_{11} & x_{12} & x_{13} & \dots & x_{1n} \\
x_{21} & x_{22} & x_{23} & \dots & x_{2n} \\
\hdotsfor{5} \\
x_{d1} & x_{d2} & x_{d3} & \dots & x_{dn}
\end{pmatrix}
=
\begin{pmatrix}
x_{11} & x_{12} & x_{13} & \dots & x_{1n} \\
x_{21} & x_{22} & x_{23} & \dots & x_{2n} \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
x_{d1} & x_{d2} & x_{d3} & \dots & x_{dn}
\end{pmatrix}
\]
\end{document}
영화, 사용자 및 요인 레이블에 문제가 있습니다. 이것 좀 도와주실 수 있나요?
ps: 이것도 생각해봤는데 k인수를 더 추가하면 좋을 것 같아요.
답변1
사용 array
및rotatebox
MWE
\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\begin{document}
\[\begin{array}{ccc}
\text{Users} & & \text{factors}\\
\rotatebox[origin=c]{90}{\text{Movies}}
\begin{pmatrix}
x_{11} & x_{12} & x_{13} & \dots & x_{1n} \\
x_{21} & x_{22} & x_{23} & \dots & x_{2n} \\
\hdotsfor{5} \\
x_{d1} & x_{d2} & x_{d3} & \dots & x_{dn}
\end{pmatrix}
&=&
\rotatebox[origin=c]{90}{\text{Movies}}
\begin{pmatrix}
x_{11} & x_{12} & x_{13} & \dots & x_{1n} \\
x_{21} & x_{22} & x_{23} & \dots & x_{2n} \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
x_{d1} & x_{d2} & x_{d3} & \dots & x_{dn}
\end{pmatrix}
\end{array}\]
\end{document}
답변2
아마도 당신은 다음을 좋아했을 것입니다:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\underbrace{\!
\begin{pmatrix}
x_{11} & x_{12} & \dots & x_{1n} \\
x_{21} & x_{22} & \dots & x_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
x_{d1} & x_{d2} & \dots & x_{dn}
\end{pmatrix}\!
}_{\mathbf{R}_{\text{Movies}\times \text{Users}}}
\approx
\underbrace{\!
\begin{pmatrix}
y_{11} & y_{12} & \dots & y_{1n} \\
y_{21} & y_{22} & \dots & y_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
y_{d1} & y_{d2} & \dots & y_{dn}
\end{pmatrix}\!
}_{\mathbf{Q}_{\text{Movies}\times f\text{-factors}}}
\cdot
\underbrace{
\begin{pmatrix}\!
z_{11} & z_{12} & \dots & z_{1n} \\
z_{21} & z_{22} & \dots & z_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
z_{d1} & z_{d2} & \dots & z_{dn}
\end{pmatrix}\!
}_{\mathbf{P}^T_{f\text{-factors}\times\text{Users}}}
\]
\end{document}