TransWikia.com

Draw dephased exact sequence diagram

TeX - LaTeX Asked by jacopoburelli on April 21, 2021

I was wondering whether there was a simple way to draw the following diagram, the problem is that I don’t know how to draw three diagram dephased of a little bit with the elements under, not the colors. All I can do is

begin{tikzcd}
            &                             & B_{n+1} arrow[d] arrow[r] & C_{n+1}                     &   
0 arrow[r] & A_n arrow[r] arrow[d]     & B_n arrow[r] arrow[d]     & C_n arrow[r] arrow[d]     & 0 
0 arrow[r] & A_{n-1} arrow[d] arrow[r] & B_{n-1} arrow[r] arrow[d] & C_{n-1} arrow[r] arrow[d] & 0 
0 arrow[r] & A_{n-2} arrow[r]           & B_{n-2}                     & C_{n-2}                     &  
end{tikzcd}

enter image description here

Any help or reference would appreciated.

2 Answers

Well, my code isn't pretty but I think it gets the job done. I feel more comfortable with plain tikz for tweaking all the positions (the key for legibility, I think), so I prefer this method to tikz-cd or tikz matrix library.

documentclass[border=2mm]{standalone}
usepackage    {tikz}
usetikzlibrary{calc}

begin{document}
begin{tikzpicture}[line join=round, line cap=round, y={(0,-1)}, every node/.style={minimum size=1.1cm},->]
% Distances
defsepx{2.6} 
defsepy{2.6}
deflx  {0.7}
defly  {0.7}
foreachx in {1,...,5} foreachy in {1,...,4}
{%
  coordinate (M-x-y) at (x*sepx,y*sepy);
}
% Black nodes
node (N-3-1) at (M-3-1) {$B_{n+1}$};
node (N-4-1) at (M-4-1) {$C_{n+1}$};
node (N-1-2) at (M-1-2) {$0$};
node (N-2-2) at (M-2-2) {$A_n$};
node (N-3-2) at (M-3-2) {$B_n$};
node (N-4-2) at (M-4-2) {$C_n$};
node (N-5-2) at (M-5-2) {$0$};
node (N-1-3) at (M-1-3) {$0$};
node (N-2-3) at (M-2-3) {$A_{n-1}$};
node (N-3-3) at (M-3-3) {$B_{n-1}$};
node (N-4-3) at (M-4-3) {$C_{n-1}$};
node (N-5-3) at (M-5-3) {$0$};
node (N-1-4) at (M-1-4) {$0$};
node (N-2-4) at (M-2-4) {$A_{n-2}$};
node (N-3-4) at (M-3-4) {$B_{n-2}$};
node (N-4-4) at (M-4-4) {$C_{n-2}$};
% Black arrows
foreachx in {1,...,4} foreachy in{2,3}
{%
  pgfmathtruncatemacroz{x+1}
  draw (N-x-y) -- (N-z-y);
}
foreachx in {1,2,3}
{%
  pgfmathtruncatemacroz{x+1}
  draw (N-x-4) -- (N-z-4);
}
foreachy in{2,3}
{%
  pgfmathtruncatemacroz{y+1}
  draw (N-2-y) -- (N-2-z);
}
foreachx in {3,4} foreachy in{1,2,3}
{%
  pgfmathtruncatemacroz{y+1}
  draw (N-x-y) -- (N-x-z);
}
% Red and blue nodes
node[red]  (R-3-1) at ($(M-3-1)+(0.5*lx,0.5*ly)$) {rotatebox{135}{$in$}};
node[red]  (R-3-1) at ($(M-3-1)+(lx,ly)$)         {$b$};
node[red]  (R-4-1) at ($(M-4-1)+(0.5*lx,0.5*ly)$) {rotatebox{135}{$in$}};
node[red]  (R-4-1) at ($(M-4-1)+(lx,ly)$)         {$c$};
node[red]  (R-2-2) at ($(M-2-2)+(0.5*lx,0.5*ly)$) {rotatebox{135}{$in$}};
node[red]  (R-2-2) at ($(M-2-2)+(lx,ly)$)         {$a$};
node[red]  (R-3-1) at ($(M-3-1)+(0.5*lx,0.5*ly)$) {rotatebox{135}{$in$}};
node[red]  (R-3-1) at ($(M-3-1)+(lx,ly)$)         {$b$};
node[red]  (R-4-1) at ($(M-4-1)+(0.5*lx,0.5*ly)$) {rotatebox{135}{$in$}};
node[red]  (R-4-1) at ($(M-4-1)+(lx,ly)$)         {$c$};
node[red]  (R-2-2) at ($(M-2-2)+(0.5*lx,0.5*ly)$) {rotatebox{135}{$in$}};
node[red]  (R-2-2) at ($(M-2-2)+(lx,ly)$)         {$a$};
node[blue] (R-3-2) at ($(M-3-2)+(0.5*lx,0.5*ly)$) {rotatebox{135}{$in$}};
node[blue] (R-3-2) at ($(M-3-2)+(lx,ly)$)         {$phantom{--}betacolor{red}begin{array}{l}+partial b+Delta bend{array}$};
node[blue] (R-4-2) at ($(M-4-2)+(0.5*lx,0.5*ly)$) {rotatebox{135}{$in$}};
node[blue] (R-4-2) at ($(M-4-2)+(lx,ly)$)         {$phantom{+Deltagamma}gammacolor{red}+Deltagamma$};
node[blue] (R-2-3) at ($(M-2-3)+(0.5*lx,0.5*ly)$) {rotatebox{135}{$in$}};
node[blue] (R-2-3) at ($(M-2-3)+(lx,ly)$)         {$phantom{+partial a}alphacolor{red}+partial a$};
node[blue] (R-3-3) at ($(M-3-3)+(lx,ly)$)         {$partialbeta$};
node[blue] (R-4-3) at ($(M-4-3)+(lx,ly)$)         {$0$};
node[blue] (R-2-4) at ($(M-2-4)+(lx,ly)$)         {$partialalpha$};
node[blue] (R-3-4) at ($(M-3-4)+(lx,ly)$)         {$partial^2beta=0$};
% Red and blue arrows
draw[red]  (R-3-1) -- (R-4-1);
draw[red]  (R-3-1) -- (R-3-2);
draw[red]  (R-4-1) -- (R-4-2);
draw[red]  (R-2-2) -- (R-3-2);
draw[red]  (R-2-2) -- (R-2-3);
draw[blue] (R-3-2) -- (R-3-3);
draw[blue] (R-3-2) -- (R-4-2);
draw[blue] (R-4-2) -- (R-4-3);
draw[blue] (R-2-3) -- (R-3-3);
draw[blue] (R-3-3) -- (R-4-3);
draw[blue] (R-2-3) -- (R-2-4);
draw[blue] (R-3-3) -- (R-3-4);
draw[blue] (R-2-4) -- (R-3-4);
draw[red]  ($(R-3-2.north east)!0.3!(R-3-2.south east)$) -- ($(R-4-2.north west)!0.3!(R-4-2.south west)$);
% Arrow labels
node       at ($(M-3-2)!0.5!(M-4-2)$) [above=-2mm] {$psi$};
node[blue] at ($(R-2-3)!0.5!(R-3-3)$) [below=-2mm] {$psi$};
node[blue] at ($(R-3-3)!0.5!(R-4-3)$) [below=-2mm] {$psi$};
node[blue] at ($(R-2-4)!0.5!(R-3-4)$) [below=-2mm] {$varphi$};
node[blue] at ($(R-3-2)!0.5!(R-3-3)$) [right=-2mm] {$partial$};
node[blue] at ($(R-4-2)!0.5!(R-4-3)$) [right=-2mm] {$partial$};
node[blue] at ($(R-2-3)!0.5!(R-2-4)$) [right=-2mm] {$partial$};
node[blue] at ($(R-3-3)!0.5!(R-3-4)$) [right=-2mm] {$partial$};
% Dots ...
node at ($(M-2-1)!0.5!(M-3-1)$) {$cdots$};
node at ($(M-4-1)!0.5!(M-5-1)$) {$cdots$};
end{tikzpicture} 
end{document}

This is what I get: enter image description here

Correct answer by Juan Castaño on April 21, 2021

This is not an answer, but an extended reply to a comment question from the OP. I suggested creating one layer in each color and overlaying them with an (x,y) shift. As to how that might be done, I sure tikz has its own ways of retaining and overlaying layers, but here I use stackinset to overlay three (in this case identical) layers.

documentclass{article}
usepackage{tikz-cd,stackengine}
begin{document}scriptsize
setbox0=hbox{begin{tikzcd}
            &                             & B_{n+1} arrow[d] arrow[r] & C_{n+1}                     &   
0 arrow[r] & A_n arrow[r] arrow[d]     & B_n arrow[r] arrow[d]     & C_n arrow[r] arrow[d]     & 0 
0 arrow[r] & A_{n-1} arrow[d] arrow[r] & B_{n-1} arrow[r] arrow[d] & C_{n-1} arrow[r] arrow[d] & 0 
0 arrow[r] & A_{n-2} arrow[r]           & B_{n-2}                     & C_{n-2}                     &  
end{tikzcd}}
setbox2=hbox{color{red}begin{tikzcd}
            &                             & B_{n+1} arrow[d] arrow[r] & C_{n+1}                     &   
0 arrow[r] & A_n arrow[r] arrow[d]     & B_n arrow[r] arrow[d]     & C_n arrow[r] arrow[d]     & 0 
0 arrow[r] & A_{n-1} arrow[d] arrow[r] & B_{n-1} arrow[r] arrow[d] & C_{n-1} arrow[r] arrow[d] & 0 
0 arrow[r] & A_{n-2} arrow[r]           & B_{n-2}                     & C_{n-2}                     &  
end{tikzcd}}
setbox4=hbox{color{blue}begin{tikzcd}
            &                             & B_{n+1} arrow[d] arrow[r] & C_{n+1}                     &   
0 arrow[r] & A_n arrow[r] arrow[d]     & B_n arrow[r] arrow[d]     & C_n arrow[r] arrow[d]     & 0 
0 arrow[r] & A_{n-1} arrow[d] arrow[r] & B_{n-1} arrow[r] arrow[d] & C_{n-1} arrow[r] arrow[d] & 0 
0 arrow[r] & A_{n-2} arrow[r]           & B_{n-2}                     & C_{n-2}                     &  
end{tikzcd}}
stackinset{c}{10pt}{c}{-35pt}{copy4}{%
stackinset{c}{16pt}{c}{-5pt}{copy2}{%
copy0}}  
end{document}

enter image description here

Answered by Steven B. Segletes on April 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP