在公式中添加长标签 - 不使用“记住图片”选项

在公式中添加长标签 - 不使用“记住图片”选项

我想为一些文本/公式添加一些标签。我发现解决方案总体上运行良好。但是,当我将其应用于我的测试时,它看起来像这样: 示例公式。但是我希望文本保持(至少)更紧密地靠在一起。

tikz我也不想使用需要“记住图片”选项的解决方案,因为我担心它可能会在其他地方引起问题(我的文档中有很多图片。

下面我附上了我的tex代码。

谢谢!

        \documentclass{article}
        \usepackage{tikz}

        \begin{document}

        \begin{equation}
        \nonumber
        1818AaCc-1day-14 => 
        \tikz[baseline]{
            \node[draw=blue,rounded corners,anchor=base] (m1)
            {$18$};
            \node[above of=m1] (l1) {$\theta_{B,CDD}$};
            \draw[<-,blue] (l1) -- (m1);
        }
        \tikz[baseline]{
            \node[draw=red,rounded corners,anchor=base] (m2)
            {$18$};
            \node[below of=m2] (l2) {$\theta_{B,HDD}$};
            \draw[<-,red] (l2) -- (m2);
        }
        \tikz[baseline]{
            \node[draw=blue,rounded corners,anchor=base] (m3)
            {$A$};
            \node[above of=m3] (l3) {$CDD_{L}$};
            \draw[<-,blue] (l3) -- (m3);
        }
        \tikz[baseline]{
            \node[draw=red,rounded corners,anchor=base] (m4)
            {$a$};
            \node[below of=m4] (l4) {$HDD_{L}$};
            \draw[<-,red] (l4) -- (m4);
        }
        \tikz[baseline]{
            \node[draw=green,rounded corners,anchor=base] (m5)
            {$A$};
            \node[above of=m5] (l5) {$DPH_{L,L}$};
            \draw[<-,green] (l5) -- (m5);
        }
        \tikz[baseline]{
            \node[draw=green,rounded corners,anchor=base] (m6)
            {$a$};
            \node[below of=m6] (l6) {$DPH_{L,U}$};
            \draw[<-,green] (l6) -- (m6);
        }
        -
        \tikz[baseline]{
            \node[draw=green,rounded corners,anchor=base] (m7)
            {$3$-day};
            \node[above of=m7] (l7) {$d_{inert}$};
            \draw[<-,green] (l7) -- (m7);
        }
        -
        \tikz[baseline]{
            \node[draw=green,rounded corners,anchor=base] (m8)
            {$14$};
            \node[below of=m8] (l8) {$\theta_{Dp,Crit}$};
            \draw[<-,green] (l8) -- (m8);
        }
        \end{equation}


        \end{document}

答案1

您可以使用overlay选项来设置下方和上方节点,并使用一些选项\hspace并将标签交替放置在不同的高度,以便清晰显示。我还使用了positioning库来获得更好的结果。

   \documentclass{article}
    \usepackage{tikz}
    \usetikzlibrary{positioning}
    \begin{document}

    \begin{equation}
    \nonumber
    1818AaCc-1day-14 =>
    \tikz[baseline]{
        \node[draw=blue,rounded corners,anchor=base] (m1)
        {\strut$18$};
        \node[above = of m1,overlay] (l1) {$\theta_{B,CDD}$};
        \draw[<-,blue] (l1) -- (m1);
    }
    \hspace{1ex}\tikz[baseline]{
        \node[draw=red,rounded corners,anchor=base] (m2)
        {\strut$18$};
        \node[below = 3ex of m2,overlay] (l2) {$\theta_{B,HDD}$};
        \draw[<-,red] (l2) -- (m2);
    }
    \hspace{1ex}\tikz[baseline]{
        \node[draw=blue,rounded corners,anchor=base] (m3)
        {\strut$A$};
        \node[above = 3ex of m3,overlay] (l3) {$CDD_{L}$};
        \draw[<-,blue] (l3) -- (m3);
    }
    \hspace{1ex}\tikz[baseline]{
        \node[draw=red,rounded corners,anchor=base] (m4)
        {\strut$a$};
        \node[below = of m4,overlay] (l4) {$HDD_{L}$};
        \draw[<-,red] (l4) -- (m4);
    }
    \hspace{1ex}\tikz[baseline]{
        \node[draw=green,rounded corners,anchor=base] (m5)
        {\strut$A$};
        \node[above = of m5,overlay] (l5) {$DPH_{L,L}$};
        \draw[<-,green] (l5) -- (m5);
    }
    \hspace{1ex}\tikz[baseline]{
        \node[draw=green,rounded corners,anchor=base] (m6)
        {\strut$a$};
        \node[below = 3ex of m6,overlay] (l6) {$DPH_{L,U}$};
        \draw[<-,green] (l6) -- (m6);
    }
    -
    \tikz[baseline]{
        \node[draw=green,rounded corners,anchor=base] (m7)
        {\strut$3$-day};
        \node[above = of m7,overlay] (l7) {$d_{inert}$};
        \draw[<-,green] (l7) -- (m7);
    }
    -
    \tikz[baseline]{
        \node[draw=green,rounded corners,anchor=base] (m8)
        {\strut$14$};
        \node[below = of m8,overlay] (l8) {$\theta_{Dp,Crit}$};
        \draw[<-,green] (l8) -- (m8);
    }
    \end{equation}


    \end{document}

在此处输入图片描述

调整我介绍的所有参数以满足您的需要。

相关内容