如何改变 tikz 中箭头的颜色和透明度?

如何改变 tikz 中箭头的颜色和透明度?

我有以下代码。

\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{cd,shapes,arrows.meta}
\begin{document}
\begin{tikzcd}[cells={nodes={scale=0.5,draw=gray,thin,rectangle,rounded corners}},
row sep=normal,column sep=scriptsize]
&1,\color{red}2  \ar[r,"\lambda",shift left]\ar[ld,"\bar{p}\mu",swap,blue] 
&   2,\color{red}2 \ar[r,"\lambda",shift left] \ar[l,"\mu",shift left]  
&   |[draw=none]| \cdots \ar[r,"\lambda",shift left] \ar[l,"\mu",shift left] 
&  .,\color{red}2  \ar[l,"\mu",shift left] \\
% 
0,\color{cyan}0 \ar[r,"\lambda",shift left] 
&   1,\color{cyan}0 \ar[r,"\lambda",shift left] \ar[l,"\eta",shift left] \ar[u,"\phi",swap] 
&   2,\color{cyan}0 \ar[r,"\lambda",shift left] \ar[l,"q\eta",shift left] \ar[u,"\phi",swap] 
\ar{lu}[description]{\bar{q}\eta}
&   |[draw=none]| \cdots \ar[r,"\lambda",shift left] \ar[l,"q\eta",shift left] 
\ar{lu}[description]{\bar{q}\eta} 
& .,\color{cyan}0 \ar[l,"q\eta",shift left]\ar[u,"\phi",shift left]
\ar{lu}[description]{\bar{q}\eta} 
\end{tikzcd}
\end{document}

生成图形

在此处输入图片描述

我想更改colors of the diagonal arrowshead shape。同时使 以使$\bar{q}\eta$ fill transparent某些侧面符号不会重叠。如何在不改变图比例的情况下做到这一点?

答案1

如果您不想更改缩放比例,标签会变得非常接近,在我看来这不是很漂亮。正如我在上面的评论中所述,您不能只将填充设为透明description。这会导致类似于完全没有填充的情况。

下面我使用的技巧是改变绘制顺序。如果你先画对角线,然后再画下面的箭头,你就会得到正确的重叠。至少我希望这是你想要的。

其余问题均已在此网站上进行了处理,因此不再进一步解释。

% arara: pdflatex

\documentclass[a4paper]{article}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}[%
    ,cells={nodes={scale=0.5,draw=gray,thin,rectangle,rounded corners}}
    ,row sep=normal
    ,column sep=scriptsize
    ,every arrow/.append style=-latex]
        & 1,\color{red}2  \ar[r,"\lambda",shift left]\ar[ld,"\bar{p}\mu",swap,blue]\arrow[blue,latex-]{dr}[description]{\bar{q}\eta} 
        & 2,\color{red}2 \ar[r,"\lambda",shift left] \ar[l,"\mu",shift left] \arrow[blue,latex-]{dr}[description]{\bar{q}\eta} 
        & |[draw=none]| \cdots \ar[r,"\lambda",shift left] \ar[l,"\mu",shift left] \arrow[blue,latex-]{dr}[description]{\bar{q}\eta}
        & .,\color{red}2  \ar[l,"\mu",shift left] \\
        0,\color{cyan}0 \ar[r,"\lambda",shift left] 
        &   1,\color{cyan}0 \ar[r,"\lambda",shift left] \ar[l,"\eta",shift left] \ar[u,"\phi",swap] 
        &   2,\color{cyan}0 \ar[r,"\lambda",shift left] \ar[l,"q\eta",shift left] \ar[u,"\phi",swap]
        &   |[draw=none]| \cdots \ar[r,"\lambda",shift left] \ar[l,"q\eta",shift left]  
        & .,\color{cyan}0 \ar[l,"q\eta",shift left]\ar[u,"\phi",shift left]
\end{tikzcd}
\end{document}

在此处输入图片描述

相关内容