Latex 混合数学和tikz时,数学环境分隔符不正确

Latex 混合数学和tikz时,数学环境分隔符不正确,latex,figure,tikz,Latex,Figure,Tikz,下面的代码 \documentclass{standalone} \begin{document} \[ X = \begin{tikzpicture} \matrix[matrix of math nodes,left delimiter = (,right delimiter = ),row sep=10pt,column sep = 10pt] (m) {

下面的代码

    \documentclass{standalone}
    \begin{document}
            \[ X = 
            \begin{tikzpicture}
            \matrix[matrix of math nodes,left delimiter = (,right delimiter = ),row sep=10pt,column sep = 10pt] (m)
            {
                1&3&-8 \\
                2&0&1 \\
                -7&9&1 \\
            };
            \end{tikzpicture}
            \]
    \end{document}
生成“错误的数学环境分隔符。]”错误。我在另一个tex文件中将上述代码作为一个数字包含在内。如果我使用$$而不是[],它将编译,但“X”将内联,而不是以矩阵为中心。如何解决此问题


***我已将tikz包含在主文件中。

您收到的错误来自独立文档类,您可以了解更多信息

在您的案例中,我建议的一种解决方法是同时使用
TikZ
编写X,以下是我的做法:

\documentclass[preview]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{matrix}
    \begin{document}
            \begin{tikzpicture}
                \node (matrix) [matrix of math nodes,
                left delimiter = (,right delimiter = ),
                row sep=10pt,
                column sep = 10pt] {
                    1   &   3   &   -8 \\
                    2   &   0   &   1 \\
                    -7  &   9   &   1 \\
                };
                \node [left=3mm of matrix] {$X=$};
            \end{tikzpicture}
    \end{document}
要获得: