方程内的 TikZ 图像

方程内的 TikZ 图像

我正在尝试写一个涉及费曼图总和的方程,这个方程看起来像“img1 + img2 + ... = a”,其中每个图像都是像我上一个问题中的图表(定义 Tikz 图形中边缘的轨迹)。当我编译方程式时,第一个图表以文本形式出现,而其他图表都正常,我该如何解决这个问题?

\documentclass{article}
\usepackage{tikz} 
\usepackage{tikz-feynman}
\tikzfeynmanset{compat=1.1.0}
\usetikzlibrary{shapes,arrows,positioning,automata,backgrounds,calc,er,patterns,positioning,quotes}

\begin{document}
\begin{equation}
    a=\begin{tikzpicture}[baseline={(0, 1cm-\MathAxis pt)},nb/.style={sloped,below},na/.style={sloped,above},scale=0.3]
        % ~~~ circles ~~~~~~~~~~~~~~~~~~~~~~~~~~
        \node[draw,circle={radius=13mm},scale=0.7] (e) at (0,0) {$x$};
        \node[draw,circle={radius=13mm},scale=0.7] (j) at (5,0) {$0$};
        
        % ~~~ arms ~~~~~~~~~~~~~~~~~~~~~~~~~~
        \draw (e) -- node[nb] {\tiny m} (  45:2) coordinate (A1);
        \draw (e) -- node[nb] {\tiny m} ( 135:2) coordinate (A2);
        \draw (e) -- node[na] {\tiny m} ( -45:2) coordinate (A3);
        \draw (e) -- node[na] {\tiny m} (-135:2) coordinate (A4);
        
        \draw (j) -- node[nb] {\tiny m} ++(  45:2) coordinate (B1);
        \draw (j) -- node[nb] {\tiny m} ++( 135:2) coordinate (B2);
        \draw (j) -- node[na] {\tiny m} ++( -45:2) coordinate (B3);
        \draw (j) -- node[na] {\tiny m} ++(-135:2) coordinate (B4);

        %\draw (e) -- node[nb] {\tiny m} (45:4) coordinate (D1);
        %\draw (j) -- node[nb] {\tiny m} ++(135:3) coordinate (D2);
        
        % ~~~ connections ~~~~~~~~~
        \draw (A1) .. controls ++(90:1) and ++(90:1) .. (B2);
        \draw (A2) .. controls ++(90:3) and ++(90:3) .. (B1);
        \draw (A3) .. controls ++(-90:1) and ++(-90:1) .. (B4);
        \draw (A4)  .. controls ++(-90:3) and ++(-90:3) .. (B3);
\end{tikzpicture}
+
\begin{tikzpicture}[baseline={(0, 1cm-\MathAxis pt)},nb/.style={sloped,below},na/.style={sloped,above},scale=0.3]
        % ~~~ circles ~~~~~~~~~~~~~~~~~~~~~~~~~~
        \node[draw,circle={radius=13mm},scale=0.7] (e) at (0,0) {$x$};
        \node[draw,circle={radius=13mm},scale=0.7] (j) at (5,0) {$0$};
        
        % ~~~ arms ~~~~~~~~~~~~~~~~~~~~~~~~~~
        \draw (e) -- node[nb] {\tiny m} (  45:2) coordinate (A1);
        \draw (e) -- node[nb] {\tiny m} ( 135:2) coordinate (A2);
        \draw (e) -- node[na] {\tiny m} ( -45:2) coordinate (A3);
        \draw (e) -- node[na] {\tiny m} (-135:2) coordinate (A4);
        
        \draw (j) -- node[nb] {\tiny m} ++(  45:2) coordinate (B1);
        \draw (j) -- node[nb] {\tiny m} ++( 135:2) coordinate (B2);
        \draw (j) -- node[na] {\tiny m} ++( -45:2) coordinate (B3);
        \draw (j) -- node[na] {\tiny m} ++(-135:2) coordinate (B4);

        %\draw (e) -- node[nb] {\tiny m} (45:4) coordinate (D1);
        %\draw (j) -- node[nb] {\tiny m} ++(135:3) coordinate (D2);
        
        % ~~~ connections ~~~~~~~~~
        \draw (A1) .. controls ++(90:3) and ++(90:3) .. (B1);
        \draw (A2) .. controls ++(90:3) and ++(90:3) .. (B2);
        \draw (A3) .. controls ++(-90:1) and ++(-90:1) .. (B4);
        \draw (A4)  .. controls ++(-90:3) and ++(-90:3) .. (B3);
\end{tikzpicture}
+
\begin{tikzpicture}[baseline={(0, 1cm-\MathAxis pt)},nb/.style={sloped,below},na/.style={sloped,above},scale=0.3]
        % ~~~ circles ~~~~~~~~~~~~~~~~~~~~~~~~~~
        \node[draw,circle={radius=13mm},scale=0.7] (e) at (0,0) {$x$};
        \node[draw,circle={radius=13mm},scale=0.7] (j) at (5,0) {$0$};
        
        % ~~~ arms ~~~~~~~~~~~~~~~~~~~~~~~~~~
        \draw (e) -- node[nb] {\tiny m} (  45:2) coordinate (A1);
        \draw (e) -- node[nb] {\tiny m} ( 135:2) coordinate (A2);
        \draw (e) -- node[na] {\tiny m} ( -45:2) coordinate (A3);
        \draw (e) -- node[na] {\tiny m} (-135:2) coordinate (A4);
        
        \draw (j) -- node[nb] {\tiny m} ++(  45:2) coordinate (B1);
        \draw (j) -- node[nb] {\tiny m} ++( 135:2) coordinate (B2);
        \draw (j) -- node[na] {\tiny m} ++( -45:2) coordinate (B3);
        \draw (j) -- node[na] {\tiny m} ++(-135:2) coordinate (B4);

        %\draw (e) -- node[nb] {\tiny m} (45:4) coordinate (D1);
        %\draw (j) -- node[nb] {\tiny m} ++(135:3) coordinate (D2);
        
        % ~~~ connections ~~~~~~~~~
        \draw (A1) .. controls ++(90:3) and ++(90:3) .. (B1);
        \draw (A2) .. controls ++(90:3) and ++(90:3) .. (B2);
        \draw (A3) .. controls ++(-90:3) and ++(-90:3) .. (B3);
        \draw (A4)  .. controls ++(-90:3) and ++(-90:3) .. (B4);
\end{tikzpicture}
\end{equation}

\end{document}

输出结果如下: 在此处输入图片描述

开头的文本是第一个图表的代码,它按原样编译,而不是显示实际图表。我尝试了评论中的建议,但还没有奏效。我刚刚注意到,如果我在 $$ 符号之间写方程式而不是方程式环境,它确实会起作用,并且所有图表都会显示出来

\documentclass{article}
\usepackage{tikz} 
\usepackage{tikz-feynman}
\tikzfeynmanset{compat=1.1.0}
\usetikzlibrary{shapes,arrows,positioning,automata,backgrounds,calc,er,patterns,positioning,quotes}

\begin{document}

$\langle\mathcal{O}_1(x)\mathcal{O}_1(0)\rangle=&\begin{tikzpicture}[baseline={(0, 1cm-\MathAxis pt)},nb/.style={sloped,below},na/.style={sloped,above},scale=0.3]
        % ~~~ circles ~~~~~~~~~~~~~~~~~~~~~~~~~~
        \node[draw,circle={radius=13mm},scale=0.7] (e) at (0,0) {$x$};
        \node[draw,circle={radius=13mm},scale=0.7] (j) at (5,0) {$0$};
        
        % ~~~ arms ~~~~~~~~~~~~~~~~~~~~~~~~~~
        \draw (e) -- node[nb] {\tiny m} (  45:2) coordinate (A1);
        \draw (e) -- node[nb] {\tiny m} ( 135:2) coordinate (A2);
        \draw (e) -- node[na] {\tiny m} ( -45:2) coordinate (A3);
        \draw (e) -- node[na] {\tiny m} (-135:2) coordinate (A4);
        
        \draw (j) -- node[nb] {\tiny m} ++(  45:2) coordinate (B1);
        \draw (j) -- node[nb] {\tiny m} ++( 135:2) coordinate (B2);
        \draw (j) -- node[na] {\tiny m} ++( -45:2) coordinate (B3);
        \draw (j) -- node[na] {\tiny m} ++(-135:2) coordinate (B4);

        %\draw (e) -- node[nb] {\tiny m} (45:4) coordinate (D1);
        %\draw (j) -- node[nb] {\tiny m} ++(135:3) coordinate (D2);
        
        % ~~~ connections ~~~~~~~~~
        \draw (A1) .. controls ++(90:1) and ++(90:1) .. (B2);
        \draw (A2) .. controls ++(90:3) and ++(90:3) .. (B1);
        \draw (A3) .. controls ++(-90:1) and ++(-90:1) .. (B4);
        \draw (A4)  .. controls ++(-90:3) and ++(-90:3) .. (B3);
\end{tikzpicture}
+
\begin{tikzpicture}[baseline={(0, 1cm-\MathAxis pt)},nb/.style={sloped,below},na/.style={sloped,above},scale=0.3]
        % ~~~ circles ~~~~~~~~~~~~~~~~~~~~~~~~~~
        \node[draw,circle={radius=13mm},scale=0.7] (e) at (0,0) {$x$};
        \node[draw,circle={radius=13mm},scale=0.7] (j) at (5,0) {$0$};
        
        % ~~~ arms ~~~~~~~~~~~~~~~~~~~~~~~~~~
        \draw (e) -- node[nb] {\tiny m} (  45:2) coordinate (A1);
        \draw (e) -- node[nb] {\tiny m} ( 135:2) coordinate (A2);
        \draw (e) -- node[na] {\tiny m} ( -45:2) coordinate (A3);
        \draw (e) -- node[na] {\tiny m} (-135:2) coordinate (A4);
        
        \draw (j) -- node[nb] {\tiny m} ++(  45:2) coordinate (B1);
        \draw (j) -- node[nb] {\tiny m} ++( 135:2) coordinate (B2);
        \draw (j) -- node[na] {\tiny m} ++( -45:2) coordinate (B3);
        \draw (j) -- node[na] {\tiny m} ++(-135:2) coordinate (B4);

        %\draw (e) -- node[nb] {\tiny m} (45:4) coordinate (D1);
        %\draw (j) -- node[nb] {\tiny m} ++(135:3) coordinate (D2);
        
        % ~~~ connections ~~~~~~~~~
        \draw (A1) .. controls ++(90:3) and ++(90:3) .. (B1);
        \draw (A2) .. controls ++(90:3) and ++(90:3) .. (B2);
        \draw (A3) .. controls ++(-90:1) and ++(-90:1) .. (B4);
        \draw (A4)  .. controls ++(-90:3) and ++(-90:3) .. (B3);
\end{tikzpicture}
+
\begin{tikzpicture}[baseline={(0, 1cm-\MathAxis pt)},nb/.style={sloped,below},na/.style={sloped,above},scale=0.3]
        % ~~~ circles ~~~~~~~~~~~~~~~~~~~~~~~~~~
        \node[draw,circle={radius=13mm},scale=0.7] (e) at (0,0) {$x$};
        \node[draw,circle={radius=13mm},scale=0.7] (j) at (5,0) {$0$};
        
        % ~~~ arms ~~~~~~~~~~~~~~~~~~~~~~~~~~
        \draw (e) -- node[nb] {\tiny m} (  45:2) coordinate (A1);
        \draw (e) -- node[nb] {\tiny m} ( 135:2) coordinate (A2);
        \draw (e) -- node[na] {\tiny m} ( -45:2) coordinate (A3);
        \draw (e) -- node[na] {\tiny m} (-135:2) coordinate (A4);
        
        \draw (j) -- node[nb] {\tiny m} ++(  45:2) coordinate (B1);
        \draw (j) -- node[nb] {\tiny m} ++( 135:2) coordinate (B2);
        \draw (j) -- node[na] {\tiny m} ++( -45:2) coordinate (B3);
        \draw (j) -- node[na] {\tiny m} ++(-135:2) coordinate (B4);

        %\draw (e) -- node[nb] {\tiny m} (45:4) coordinate (D1);
        %\draw (j) -- node[nb] {\tiny m} ++(135:3) coordinate (D2);
        
        % ~~~ connections ~~~~~~~~~
        \draw (A1) .. controls ++(90:3) and ++(90:3) .. (B1);
        \draw (A2) .. controls ++(90:3) and ++(90:3) .. (B2);
        \draw (A3) .. controls ++(-90:3) and ++(-90:3) .. (B3);
        \draw (A4)  .. controls ++(-90:3) and ++(-90:3) .. (B4);
\end{tikzpicture}$
\end{document}

答案1

如果您tikzpicture在文档序言中没有定义选项

\tikzset{T/.style = {baseline = -0.5ex,
        nb/.style={sloped,below, font=\tiny},
        na/.style={sloped,above, font=\tiny},
        scale=0.3}
        }

并添加比您的 MWE 编译的tikzpicture选项:[T]luaLaTeX

(没有错误,没有警告,没有坏框)

在此处输入图片描述

相关内容