\input 调用的文件中的框架环境无法正常工作

\input 调用的文件中的框架环境无法正常工作

下面的例子工作正常,但如果我将框架环境放在 \input 调用的文件 matrix.tex 中,那么我会收到一条错误消息,并且文件无法编译。

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\usepackage{tikz}
\usetikzlibrary{matrix,shapes,arrows,calc}

\usepackage{adjustbox}
\usetheme{CambridgeUS}


\begin{document}

\begin{frame}{example}
        \input{matrix}    
\end{frame}

\end{document}

文件 matrix.tex:

\begin{adjustbox}{max totalsize={.99\textheight},center}    

\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=4 and 6, semithick]


\matrix(m) [matrix of math nodes, nodes in empty cells, nodes={minimum size=.7cm, outer sep=0pt, text height=1.0ex, text depth=.25ex}]
{
   9 &    &     & 8 &   &     &  12    &    &   & 13 &    &  &    &   &    &    &     \\
     &    &     &   &   &     &        &    &   &    &    &  &    &   &    &    &     \\
     &    & 1   &   &   &  2  &        &    & 7 &    &    & 1&    &   &    &    &     \\
 10  &    &     & 10&   &     &  12    &    &   & 14 &    &  &    &   &    &    &     \\
     &    &     &   &   &     &        &    &   &    &    &  &    &   &    &    &     \\
     &    &  2  &   &   & 1   &        &    & 2 &    &    &2 &    &   &    &    &     \\
     };


\draw [blue] (m-1-1.north west) rectangle (m-6-12.south east);

% Lineas horizontales
\foreach \i in {3} {
  \draw[blue] (m-\i-1.south west) -- (m-\i-12.south east);
}

% Lineas verticales
\foreach \j in {3,6,9} {
  \draw[blue] (m-1-\j.north east) -- (m-6-\j.south east);
}


\foreach \i in {3,6} {
    \foreach \j in {3,6,9,12} {
            \draw[blue] (m-\i-\j.south west) rectangle (m-\i-\j.north east);
    }
}


\end{tikzpicture}

\end{adjustbox}

相关内容