LaTeX 中的等距表格

LaTeX 中的等距表格

有人能帮我用一个简单的 LaTeX 代码来画出类似附图的东西吗? 3D 矩阵表

答案1

基于以下可能的解决方案http://www.texample.net/tikz/examples/sudoku-3d-cube/

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{positioning}

\definecolor{colortop}{RGB}{184,223,155}
\definecolor{colorside}{RGB}{0,209,54}

\DeclareMathOperator{\Att}{Att}
\DeclareMathOperator{\Item}{Item}

\begin{document}

\pagestyle{empty}
\begin{tikzpicture}[every node/.style={minimum size=1cm,font=\scriptsize},on grid]
\begin{scope}[every node/.append style={yslant=-0.5,rotate=90},yslant=-0.5]
  \shade[right color=colorside!30, left color=colorside!50] (-1,0) rectangle +(4,3);
  \node at (-0.5,2.25) {};
  \node at (0.5,2.25) {$\Att_1$};
  \node at (1.5,2.25) {$\Att_2$};
  \node at (2.5,2.25) {$\Att_3$};
  \node at (-0.5,0.75) {User};
  \node at (0.5,0.75) {$1$};
  \node at (1.5,0.75) {$0$};
  \node at (2.5,0.75) {$0$};
  \draw (-1,0) grid[ystep=1.5] (3,3);
\end{scope}
\begin{scope}[every node/.append style={yslant=0.5},yslant=0.5]
  \shade[right color=colorside!70,left color=colorside!10] (3,-3) rectangle +(5,3);
  \node at (3.5,-0.5) {};
  \node at (4.5,-0.5) {$\Att_1$};
  \node at (5.5,-0.5) {$\Att_2$};
  \node at (6.5,-0.5) {$\Att_3$};
  \node at (7.5,-0.5) {$\Att_4$};
  \node at (3.5,-1.5) {$\Item_1$};
  \node at (4.5,-1.5) {$0$};
  \node at (5.5,-1.5) {$1$};
  \node at (6.5,-1.5) {$1$};
  \node at (7.5,-1.5) {$1$};
  \node at (3.5,-2.5) {$\Item_2$};
  \node at (4.5,-2.5) {$0$};
  \node at (5.5,-2.5) {$0$};
  \node at (6.5,-2.5) {$1$};
  \node at (7.5,-2.5) {$0$};
  \draw (3,-3) grid (8,0);
\end{scope}
\begin{scope}[every node/.append style={
    yslant=0.5,xslant=-1},yslant=0.5,xslant=-1
  ]
  \shade[bottom color=colortop!10, top color=colortop!80] (8,4) rectangle +(-5,-4);
  \node[font=\scriptsize\color{red},rotate=-90] at (5.5,2) {User--item feature matrix};
\end{scope}
\end{tikzpicture}

\end{document}

在此处输入图片描述

我征得了所有者的同意,编辑了此答案。

答案2

这里有一个pst-3dplot执行:

在此处输入图片描述

\documentclass{article}
\usepackage{pst-3dplot,xcolor,multido,graphicx}

\newcommand{\clap}[1]{\makebox[0pt]{\footnotesize #1}}
\begin{document}

\begin{pspicture}(-4,-4)(4,4)
  % Draw box shape + colour
  \psset{linewidth = 0.5pt, linecolor = black!30, fillstyle = solid, unit = 1.2, Alpha = 50, Beta = 30}
  \pstThreeDSquare[plane = xy, fillcolor = green!65!white](0,0,3)(5,0,0)(0,5,0)
  \pstThreeDSquare[plane = xz, fillcolor = red!65!white](0,5,0)(5,0,0)(0,0,3)
  \pstThreeDSquare[plane = yz, fillcolor = blue!65!white](5,0,0)(0,5,0)(0,0,3)

  % Draw on box shape
  \pstThreeDLine(5,0,1.5)(5,5,1.5)
  \multido{\rY=1.25+1.25}{3}{\pstThreeDLine(5,\rY,0)(5,\rY,3)}
  \multido{\iZ=1+1}{2}{\pstThreeDLine(5,5,\iZ)(0,5,\iZ)}
  \multido{\iX=1+1}{4}{\pstThreeDLine(\iX,5,0)(\iX,5,3)}

  % Annotate the faces
  \psset{planecorr = normal, plane = yz, pOrigin = c}
  \pstPlanePut(5,0.625,0.75){\clap{\texttt{User}}}
  \pstPlanePut(5,1.875,0.75){\clap{0}}\pstPlanePut(5,1.875,2.25){\clap{\texttt{Att\_1}}}
  \pstPlanePut(5,3.125,0.75){\clap{1}}\pstPlanePut(5,3.125,2.25){\clap{\texttt{Att\_2}}}
  \pstPlanePut(5,4.375,0.75){\clap{1}}\pstPlanePut(5,4.375,2.25){\clap{\texttt{Att\_3}}}

  \psset{plane = xz}
  \pstPlanePut(4.5,5,0.5){\clap{\texttt{Item\_2}}}
    \pstPlanePut(3.5,5,0.5){\clap{0}}
    \pstPlanePut(2.5,5,0.5){\clap{0}}
    \pstPlanePut(1.5,5,0.5){\clap{1}}
    \pstPlanePut(0.5,5,0.5){\clap{1}}
  \pstPlanePut(4.5,5,1.5){\clap{\texttt{Item\_1}}}
    \pstPlanePut(3.5,5,1.5){\clap{0}}
    \pstPlanePut(2.5,5,1.5){\clap{1}}
    \pstPlanePut(1.5,5,1.5){\clap{1}}
    \pstPlanePut(0.5,5,1.5){\clap{0}}
  %   
    \pstPlanePut(3.5,5,2.5){\clap{\texttt{Att\_1}}}
    \pstPlanePut(2.5,5,2.5){\clap{\texttt{Att\_2}}}
    \pstPlanePut(1.5,5,2.5){\clap{\texttt{Att\_3}}}
    \pstPlanePut(0.5,5,2.5){\clap{\texttt{Att\_4}}}

  \psset{plane = xy}
  \pstPlanePut(2.5,2.5,3){\clap{\rotatebox[origin=c]{-45}{\normalsize User-item feature matrix}}}
\end{pspicture}

\end{document}

相关内容