软件包 PGF 数学错误: 未知函数 `L' (在 '-L* 1.9 * 1' 中)。}

软件包 PGF 数学错误: 未知函数 `L' (在 '-L* 1.9 * 1' 中)。}

我正在使用此代码

\begin{equation} 
G=\begin{matrix}
&  
\begin{tikzpicture}
\def\xs{1} %shift in x direction
\def\ys{0.5} %shift in y direction
\def\nm{2} % number of 2d matrices in the 3d matrix
\foreach \x [count = \xi] in {L,1}
{
    \matrix [matrix of math nodes,left delimiter={[},right delimiter={]},fill=white,ampersand replacement=\&] %see explanation
    (mm\x)%give the matrix a name
    at(-\x * 1.9 * \xs, -\x * 1.7 * \ys) %shift the matrix
    {
        \node {g_\x}; \& \node {\cdots};\&\node {g_\x};\\
        \node {\vdots}; \& \node {\ddots};\&\node {\vdots};\\
        \node { g_\x}; \& \node {\cdots};\&\node {g_\x};\\
    }; 
}
\draw [dotted,gray](mm1.north west) -- (mmL.north west);
\hspace*{2mm}\draw [dotted,gray](mm1.north east) -- (mmL.north east);
\hspace*{-2mm}\draw [dotted,gray](mm1.south east) -- (mmL.south east);
\end{tikzpicture}
\end{matrix},
\end{equation}

我收到此错误,你能帮我修复吗

答案1

这修复了错误和其他一些问题。但是,我认为底层代码并不是真正最佳的,因此从长远来看,您可能需要从头开始重写它。在这里,我只造成最小的损害。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{equation} \label{3dmatrix}
G^{3D}_{M\times K\times L}=
\begin{tikzpicture}[baseline={(C.base)}]
 \def\xs{1} %shift in x direction
 \def\ys{0.5} %shift in y direction
 \def\nm{2} % number of 2d matrices in the 3d matrix
 \foreach \x [count = \xi] in {1,...,\nm}
 {
     \matrix [matrix of math nodes,left delimiter={[},right delimiter={]},
     fill=white,fill opacity=0.7,text opacity=1,ampersand replacement=\&] 
     (mm\x)%give the matrix a name
     at(-\x * 1.9 * \xs, -\x * 1.7 * \ys) %shift the matrix
     {
         \node {g_{1}^{1^{\x}}}; \& \node {\cdots};\&\node {g_{K}^{1^{\x}}};\\
         \node {\vdots}; \& \node (c-\x) {\ddots};\&\node {\vdots};\\
         \node { g_{ 1}^{M^{\x}}}; \& \node {\cdots};\&\node {g_{K}^{M^{\x}}};\\
     }; 
 }
 \draw [dotted,gray](mm1.north west) -- (mm\nm.north west);
 \draw [dotted,gray](mm1.north east) -- (mm\nm.north east);
 \draw [dotted,gray](mm1.south east) -- (mm\nm.south east);
 \path (c-1) -- (c-\nm) node[midway](C){\phantom{C}};
\end{tikzpicture}
\;,
\end{equation}
\end{document}

在此处输入图片描述

相关内容