2

I have the following code.

\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}

which generates the figure

enter image description here

I want to change the colors of the diagonal arrows and the head shape. Also to make the $\bar{q}\eta$ fill transparent so that some part of the side symbols will not be overlapped. How to do that without changing the scale of the plot?

Litun
  • 3,295
  • Do you want to have all diagonal arrows changed? You already have succeeded on one. Which arrow head do you want? For all arrows?. If you fill transparent, the arrow will be visible as well, which is not what you want, I guess. – LaRiFaRi Jan 07 '16 at 12:48
  • I mean the diagonal arrows with $\bar{q}\eta$. – Litun Jan 07 '16 at 12:50
  • yes both label and arrow – Litun Jan 07 '16 at 12:59
  • 1
    If I understand your problem correctly, you like to make visible labels of arrows, which are overlapped with other labels. What you not simple increase for example row sep to large? – Zarko Jan 07 '16 at 13:00

1 Answers1

3

If you do not want to change the scaling, the labels will get very close which is not very beautiful in my opinion. As I have stated in my comment above, you can not just make the fill of the description transparent. This would result in something similar to no fill at all.

The trick I use below is to change the order of drawing. If you do the diagonals first and then the lower arrows, you will get a correct overlapping. At least I hope this is what you want.

The other questions are all treated on this site already and are therefore not explained further.

% 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}

enter image description here

LaRiFaRi
  • 43,807
  • How to reduce the size of the pair of arrows on both sides of the .... – Litun Jan 07 '16 at 13:09
  • 1
    use &[-5mm] or similar for the separators in your first row. Please note that the blue labels are on different heights as the arrows are starting at different points. I would put a white 1,2 with surrounding rectangle and draw the \cdots on top. This will get everything nicely aligned. – LaRiFaRi Jan 07 '16 at 13:18
  • How to change the arrow heads to angle 60 . – Litun Jan 07 '16 at 16:02