How to draw lines on a tikz-cd diagramDrawing an arrow between two parts of a sentenceSetting the name of matrix in tikz-cdRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeCannot draw this diagram using tikz-cdTikZ/ERD: node (=Entity) label on the insideHow to draw a diagram using tikzcdTikZ: Drawing an arc from an intersection to an intersectionDouble diagram in tikz-cdHow to draw stair case diagram using tikz-cd?Draw an ellipse in Tikz-cd around diagram

You cannot touch me, but I can touch you, who am I?

How does Loki do this?

Did Dumbledore lie to Harry about how long he had James Potter's invisibility cloak when he was examining it? If so, why?

How do scammers retract money, while you can’t?

What Brexit proposals are on the table in the indicative votes on the 27th of March 2019?

Type int? vs type int

Pole-zeros of a real-valued causal FIR system

How can I get through very long and very dry, but also very useful technical documents when learning a new tool?

How does the UK government determine the size of a mandate?

Balance Issues for a Custom Sorcerer Variant

How can I kill an app using Terminal?

Customer Requests (Sometimes) Drive Me Bonkers!

Two monoidal structures and copowering

Integer addition + constant, is it a group?

How long to clear the 'suck zone' of a turbofan after start is initiated?

Is there a problem with hiding "forgot password" until it's needed?

Why didn't Theresa May consult with Parliament before negotiating a deal with the EU?

Implement the Thanos sorting algorithm

Avoiding estate tax by giving multiple gifts

Is the destination of a commercial flight important for the pilot?

Sequence of Tenses: Translating the subjunctive

How to pronounce the slash sign

Class Action - which options I have?

How did Doctor Strange see the winning outcome in Avengers: Infinity War?



How to draw lines on a tikz-cd diagram


Drawing an arrow between two parts of a sentenceSetting the name of matrix in tikz-cdRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeCannot draw this diagram using tikz-cdTikZ/ERD: node (=Entity) label on the insideHow to draw a diagram using tikzcdTikZ: Drawing an arc from an intersection to an intersectionDouble diagram in tikz-cdHow to draw stair case diagram using tikz-cd?Draw an ellipse in Tikz-cd around diagram













3















I am drawing a matrix using tikz-cd. I would like to draw some vertical and horizontal lines on it too to indicate particular submatrices but I don't understand the syntax. This is my M(N)WE:



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20")]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
foreach x in 1,3

draw
([yshift=-3,xshift=-.125pgflinewidth]mat-x-1.south west) --
([yshift=-3,xshift=-.125pgflinewidth]mat-x-12.south east);

foreach y in 2

draw
([yshift=.5pgflinewidth]mat-1-y.north east) --
([yshift=.5pgflinewidth]mat-14-y.south east);

endtikzcd

enddocument


This is syntactically incorrect but works if you remove the foreach loops. How can I use the foreach...draw commands with a tikz-cd drawn matrix?










share|improve this question
























  • You seem to be mixing two things. Yes, tikz-cd is using a tikz matrix, but the tikzcd environment does not give you a tikzpicture environment in which you can just use draw.

    – marmot
    8 hours ago











  • @marmot Yes I am definitely confused. Is there some way to use tikz-cd to make the matrix and also use draw to draw on it? Or alternatively some other way to draw horizontal and vertical lines to separate submatrices?

    – Anush
    8 hours ago












  • Yes: tex.stackexchange.com/a/405152/121799

    – marmot
    8 hours ago











  • @marmot Ah. I tried just now bpaste.net/show/db6d4ebda072 but this doesn't work because mat doesn't exist. I need some pure tikz-cd solution it seems.

    – Anush
    8 hours ago















3















I am drawing a matrix using tikz-cd. I would like to draw some vertical and horizontal lines on it too to indicate particular submatrices but I don't understand the syntax. This is my M(N)WE:



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20")]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
foreach x in 1,3

draw
([yshift=-3,xshift=-.125pgflinewidth]mat-x-1.south west) --
([yshift=-3,xshift=-.125pgflinewidth]mat-x-12.south east);

foreach y in 2

draw
([yshift=.5pgflinewidth]mat-1-y.north east) --
([yshift=.5pgflinewidth]mat-14-y.south east);

endtikzcd

enddocument


This is syntactically incorrect but works if you remove the foreach loops. How can I use the foreach...draw commands with a tikz-cd drawn matrix?










share|improve this question
























  • You seem to be mixing two things. Yes, tikz-cd is using a tikz matrix, but the tikzcd environment does not give you a tikzpicture environment in which you can just use draw.

    – marmot
    8 hours ago











  • @marmot Yes I am definitely confused. Is there some way to use tikz-cd to make the matrix and also use draw to draw on it? Or alternatively some other way to draw horizontal and vertical lines to separate submatrices?

    – Anush
    8 hours ago












  • Yes: tex.stackexchange.com/a/405152/121799

    – marmot
    8 hours ago











  • @marmot Ah. I tried just now bpaste.net/show/db6d4ebda072 but this doesn't work because mat doesn't exist. I need some pure tikz-cd solution it seems.

    – Anush
    8 hours ago













3












3








3








I am drawing a matrix using tikz-cd. I would like to draw some vertical and horizontal lines on it too to indicate particular submatrices but I don't understand the syntax. This is my M(N)WE:



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20")]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
foreach x in 1,3

draw
([yshift=-3,xshift=-.125pgflinewidth]mat-x-1.south west) --
([yshift=-3,xshift=-.125pgflinewidth]mat-x-12.south east);

foreach y in 2

draw
([yshift=.5pgflinewidth]mat-1-y.north east) --
([yshift=.5pgflinewidth]mat-14-y.south east);

endtikzcd

enddocument


This is syntactically incorrect but works if you remove the foreach loops. How can I use the foreach...draw commands with a tikz-cd drawn matrix?










share|improve this question
















I am drawing a matrix using tikz-cd. I would like to draw some vertical and horizontal lines on it too to indicate particular submatrices but I don't understand the syntax. This is my M(N)WE:



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20")]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
foreach x in 1,3

draw
([yshift=-3,xshift=-.125pgflinewidth]mat-x-1.south west) --
([yshift=-3,xshift=-.125pgflinewidth]mat-x-12.south east);

foreach y in 2

draw
([yshift=.5pgflinewidth]mat-1-y.north east) --
([yshift=.5pgflinewidth]mat-14-y.south east);

endtikzcd

enddocument


This is syntactically incorrect but works if you remove the foreach loops. How can I use the foreach...draw commands with a tikz-cd drawn matrix?







tikz-pgf tikz-cd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 8 hours ago







Anush

















asked 8 hours ago









AnushAnush

2006




2006












  • You seem to be mixing two things. Yes, tikz-cd is using a tikz matrix, but the tikzcd environment does not give you a tikzpicture environment in which you can just use draw.

    – marmot
    8 hours ago











  • @marmot Yes I am definitely confused. Is there some way to use tikz-cd to make the matrix and also use draw to draw on it? Or alternatively some other way to draw horizontal and vertical lines to separate submatrices?

    – Anush
    8 hours ago












  • Yes: tex.stackexchange.com/a/405152/121799

    – marmot
    8 hours ago











  • @marmot Ah. I tried just now bpaste.net/show/db6d4ebda072 but this doesn't work because mat doesn't exist. I need some pure tikz-cd solution it seems.

    – Anush
    8 hours ago

















  • You seem to be mixing two things. Yes, tikz-cd is using a tikz matrix, but the tikzcd environment does not give you a tikzpicture environment in which you can just use draw.

    – marmot
    8 hours ago











  • @marmot Yes I am definitely confused. Is there some way to use tikz-cd to make the matrix and also use draw to draw on it? Or alternatively some other way to draw horizontal and vertical lines to separate submatrices?

    – Anush
    8 hours ago












  • Yes: tex.stackexchange.com/a/405152/121799

    – marmot
    8 hours ago











  • @marmot Ah. I tried just now bpaste.net/show/db6d4ebda072 but this doesn't work because mat doesn't exist. I need some pure tikz-cd solution it seems.

    – Anush
    8 hours ago
















You seem to be mixing two things. Yes, tikz-cd is using a tikz matrix, but the tikzcd environment does not give you a tikzpicture environment in which you can just use draw.

– marmot
8 hours ago





You seem to be mixing two things. Yes, tikz-cd is using a tikz matrix, but the tikzcd environment does not give you a tikzpicture environment in which you can just use draw.

– marmot
8 hours ago













@marmot Yes I am definitely confused. Is there some way to use tikz-cd to make the matrix and also use draw to draw on it? Or alternatively some other way to draw horizontal and vertical lines to separate submatrices?

– Anush
8 hours ago






@marmot Yes I am definitely confused. Is there some way to use tikz-cd to make the matrix and also use draw to draw on it? Or alternatively some other way to draw horizontal and vertical lines to separate submatrices?

– Anush
8 hours ago














Yes: tex.stackexchange.com/a/405152/121799

– marmot
8 hours ago





Yes: tex.stackexchange.com/a/405152/121799

– marmot
8 hours ago













@marmot Ah. I tried just now bpaste.net/show/db6d4ebda072 but this doesn't work because mat doesn't exist. I need some pure tikz-cd solution it seems.

– Anush
8 hours ago





@marmot Ah. I tried just now bpaste.net/show/db6d4ebda072 but this doesn't work because mat doesn't exist. I need some pure tikz-cd solution it seems.

– Anush
8 hours ago










2 Answers
2






active

oldest

votes


















5














Are you looking for this?



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20"),nodes in empty cells,
execute at end picture=
foreach x in 1,3

draw
([yshift=-3,xshift=-.125pgflinewidth]tikzcdmatrixname-x-1.south west) --
([yshift=-3,xshift=-.125pgflinewidth]tikzcdmatrixname-x-12.south east);

foreach y in 3

draw
([yshift=.5pgflinewidth]tikzcdmatrixname-1-y.north west) --
([yshift=.5pgflinewidth]tikzcdmatrixname-6-y.south west);
]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtikzcd
enddocument


enter image description here



Here I was employing Henri Menke's nice answer and added nodes in empty cells and changed some numbers to only use existing nodes.



ADDENDUM: If you want to the lines right in the middle between the cells without having to add all the shifts by fractions of the line width, you could use the calc library.



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
usetikzlibrarycalc
begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20"),nodes in empty cells,
execute at end picture=
foreach x [evaluate=x as xp using int(x+1)] in 1,3

draw ($(tikzcdmatrixname-x-2.south)!0.5!(tikzcdmatrixname-xp-2.north)$)
coordinate (aux)
([xshift=-.1em]tikzcdmatrixname.west
foreach y [evaluate=y as ym using int(y-1)] in 3
aux);
]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtikzcd
enddocument


As for the question what this might be good for: there are certain things that are somewhat harder to achieve with a table like e.g.



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
usetikzlibrarycalc,through,backgrounds
tikzsetcircle through 3 points/.style n args=3%
insert path=let p1=($(#1)!0.5!(#2)$),
p2=($(#1)!0.5!(#3)$),
p3=($(#1)!0.5!(#2)!1!-90:(#2)$),
p4=($(#1)!0.5!(#3)!1!90:(#3)$),
p5=(intersection of p1--p3 and p2--p4)
in ,
at=(p5),
circle through= (#1)

begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20"),nodes in empty cells,
execute at end picture=
foreach x [evaluate=x as xp using int(x+1)] in 1,3

draw ($(tikzcdmatrixname-x-2.south)!0.5!(tikzcdmatrixname-xp-2.north)$)
coordinate (aux)
([xshift=-.1em]tikzcdmatrixname.west
foreach y [evaluate=y as ym using int(y-1)] in 3
aux);

beginscope[on background layer]
node[circle through 3
points=tikzcdmatrixname-2-2tikzcdmatrixname-3-1tikzcdmatrixname-3-3,
fill=blue!20];
endscope
]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtikzcd
enddocument


enter image description here



Yet for many purposes, the table approach suggested by Joule V is just fine or even better. It really depends on what you want to do in the end.






share|improve this answer

























  • Yes, exactly! Thank you so much.

    – Anush
    8 hours ago











  • The calc addition is very educational. Thank you.

    – Anush
    6 hours ago











  • I'm not aiming to make a war but I do think the last figure is still not difficult ;) We just need some help of a remember picture, overlay TikZ picture :)

    – JouleV
    6 hours ago






  • 1





    @JouleV This meant to be really friendly. AFAIK you cannot achieve this with remember picture easily because you cannot draw it on the background after the table is "done" unless you use atbegshi or something like this, or do something with blend mode .

    – marmot
    6 hours ago


















5














Just for fun: if you want to make that matrix, why don't use a table? The code is much shorter:



documentclassarticle
begindocument
renewcommandarraystretch1.3
begintabularcc
&&0&0&0&0&0&0&0&0&0&0\hline
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular
enddocument


enter image description here



Coloring the text is not difficult, isn't it? If you want to draw some arrows, tikzmark may be an option. Anyway, if I were you, I would use a simple table. :)




Add an arrow



documentclassarticle
usepackagetikz
begindocument
renewcommandarraystretch1.3
begintabularcc
&&0&0&0&0&0&0&0&0&0&0\hline
&0&1&2&3&4&5&6&7&8&9&10\
0&tikz[baseline,remember picture]node[anchor=base,inner sep=0pt] (node1) 1;&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&tikz[baseline,remember picture]node[anchor=base,inner sep=0pt] (node2) 3;&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular

begintikzpicture[remember picture,overlay]
draw[red,very thick,-latex] (node1) -- (node2);
endtikzpicture
enddocument


enter image description here




Color row(s)



documentclassarticle
usepackagetikz
usepackagexcolor,colortbl
begindocument
renewcommandarraystretch1.3
begintabularcc
rowcolorred!20&&0&0&0&0&0&0&0&0&0&0\hline
rowcolorred!20&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular
enddocument


enter image description here




Color column(s)



documentclassarticle
usepackagetikz
usepackagexcolor,colortbl
begindocument
renewcommandarraystretch1.3
begintabularccc>columncoloryellow!50cc>columncolorgreen!20ccccc
&&0&0&0&0&0&0&0&0&0&0\hline
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular
enddocument


enter image description here




It is never impossible to work with tables using table commands :)






share|improve this answer

























  • I will also add arrows in the table and color some of the elements.

    – Anush
    8 hours ago






  • 2





    And: most users load tikz anyway for the tikzlings. ;-)

    – marmot
    8 hours ago











  • Can you color an entire submatrix of a table out of interest? Say rows 1-2 and columns 4-6?

    – Anush
    8 hours ago






  • 3





    @Anush To color, you have cellcolor. To make arrows, you can have a look at this nice answer.

    – JouleV
    8 hours ago






  • 2





    @Anush I edited my answer: I added some ways to add arrows, color columns and rows.

    – JouleV
    7 hours ago










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f481723%2fhow-to-draw-lines-on-a-tikz-cd-diagram%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









5














Are you looking for this?



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20"),nodes in empty cells,
execute at end picture=
foreach x in 1,3

draw
([yshift=-3,xshift=-.125pgflinewidth]tikzcdmatrixname-x-1.south west) --
([yshift=-3,xshift=-.125pgflinewidth]tikzcdmatrixname-x-12.south east);

foreach y in 3

draw
([yshift=.5pgflinewidth]tikzcdmatrixname-1-y.north west) --
([yshift=.5pgflinewidth]tikzcdmatrixname-6-y.south west);
]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtikzcd
enddocument


enter image description here



Here I was employing Henri Menke's nice answer and added nodes in empty cells and changed some numbers to only use existing nodes.



ADDENDUM: If you want to the lines right in the middle between the cells without having to add all the shifts by fractions of the line width, you could use the calc library.



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
usetikzlibrarycalc
begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20"),nodes in empty cells,
execute at end picture=
foreach x [evaluate=x as xp using int(x+1)] in 1,3

draw ($(tikzcdmatrixname-x-2.south)!0.5!(tikzcdmatrixname-xp-2.north)$)
coordinate (aux)
([xshift=-.1em]tikzcdmatrixname.west
foreach y [evaluate=y as ym using int(y-1)] in 3
aux);
]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtikzcd
enddocument


As for the question what this might be good for: there are certain things that are somewhat harder to achieve with a table like e.g.



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
usetikzlibrarycalc,through,backgrounds
tikzsetcircle through 3 points/.style n args=3%
insert path=let p1=($(#1)!0.5!(#2)$),
p2=($(#1)!0.5!(#3)$),
p3=($(#1)!0.5!(#2)!1!-90:(#2)$),
p4=($(#1)!0.5!(#3)!1!90:(#3)$),
p5=(intersection of p1--p3 and p2--p4)
in ,
at=(p5),
circle through= (#1)

begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20"),nodes in empty cells,
execute at end picture=
foreach x [evaluate=x as xp using int(x+1)] in 1,3

draw ($(tikzcdmatrixname-x-2.south)!0.5!(tikzcdmatrixname-xp-2.north)$)
coordinate (aux)
([xshift=-.1em]tikzcdmatrixname.west
foreach y [evaluate=y as ym using int(y-1)] in 3
aux);

beginscope[on background layer]
node[circle through 3
points=tikzcdmatrixname-2-2tikzcdmatrixname-3-1tikzcdmatrixname-3-3,
fill=blue!20];
endscope
]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtikzcd
enddocument


enter image description here



Yet for many purposes, the table approach suggested by Joule V is just fine or even better. It really depends on what you want to do in the end.






share|improve this answer

























  • Yes, exactly! Thank you so much.

    – Anush
    8 hours ago











  • The calc addition is very educational. Thank you.

    – Anush
    6 hours ago











  • I'm not aiming to make a war but I do think the last figure is still not difficult ;) We just need some help of a remember picture, overlay TikZ picture :)

    – JouleV
    6 hours ago






  • 1





    @JouleV This meant to be really friendly. AFAIK you cannot achieve this with remember picture easily because you cannot draw it on the background after the table is "done" unless you use atbegshi or something like this, or do something with blend mode .

    – marmot
    6 hours ago















5














Are you looking for this?



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20"),nodes in empty cells,
execute at end picture=
foreach x in 1,3

draw
([yshift=-3,xshift=-.125pgflinewidth]tikzcdmatrixname-x-1.south west) --
([yshift=-3,xshift=-.125pgflinewidth]tikzcdmatrixname-x-12.south east);

foreach y in 3

draw
([yshift=.5pgflinewidth]tikzcdmatrixname-1-y.north west) --
([yshift=.5pgflinewidth]tikzcdmatrixname-6-y.south west);
]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtikzcd
enddocument


enter image description here



Here I was employing Henri Menke's nice answer and added nodes in empty cells and changed some numbers to only use existing nodes.



ADDENDUM: If you want to the lines right in the middle between the cells without having to add all the shifts by fractions of the line width, you could use the calc library.



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
usetikzlibrarycalc
begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20"),nodes in empty cells,
execute at end picture=
foreach x [evaluate=x as xp using int(x+1)] in 1,3

draw ($(tikzcdmatrixname-x-2.south)!0.5!(tikzcdmatrixname-xp-2.north)$)
coordinate (aux)
([xshift=-.1em]tikzcdmatrixname.west
foreach y [evaluate=y as ym using int(y-1)] in 3
aux);
]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtikzcd
enddocument


As for the question what this might be good for: there are certain things that are somewhat harder to achieve with a table like e.g.



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
usetikzlibrarycalc,through,backgrounds
tikzsetcircle through 3 points/.style n args=3%
insert path=let p1=($(#1)!0.5!(#2)$),
p2=($(#1)!0.5!(#3)$),
p3=($(#1)!0.5!(#2)!1!-90:(#2)$),
p4=($(#1)!0.5!(#3)!1!90:(#3)$),
p5=(intersection of p1--p3 and p2--p4)
in ,
at=(p5),
circle through= (#1)

begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20"),nodes in empty cells,
execute at end picture=
foreach x [evaluate=x as xp using int(x+1)] in 1,3

draw ($(tikzcdmatrixname-x-2.south)!0.5!(tikzcdmatrixname-xp-2.north)$)
coordinate (aux)
([xshift=-.1em]tikzcdmatrixname.west
foreach y [evaluate=y as ym using int(y-1)] in 3
aux);

beginscope[on background layer]
node[circle through 3
points=tikzcdmatrixname-2-2tikzcdmatrixname-3-1tikzcdmatrixname-3-3,
fill=blue!20];
endscope
]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtikzcd
enddocument


enter image description here



Yet for many purposes, the table approach suggested by Joule V is just fine or even better. It really depends on what you want to do in the end.






share|improve this answer

























  • Yes, exactly! Thank you so much.

    – Anush
    8 hours ago











  • The calc addition is very educational. Thank you.

    – Anush
    6 hours ago











  • I'm not aiming to make a war but I do think the last figure is still not difficult ;) We just need some help of a remember picture, overlay TikZ picture :)

    – JouleV
    6 hours ago






  • 1





    @JouleV This meant to be really friendly. AFAIK you cannot achieve this with remember picture easily because you cannot draw it on the background after the table is "done" unless you use atbegshi or something like this, or do something with blend mode .

    – marmot
    6 hours ago













5












5








5







Are you looking for this?



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20"),nodes in empty cells,
execute at end picture=
foreach x in 1,3

draw
([yshift=-3,xshift=-.125pgflinewidth]tikzcdmatrixname-x-1.south west) --
([yshift=-3,xshift=-.125pgflinewidth]tikzcdmatrixname-x-12.south east);

foreach y in 3

draw
([yshift=.5pgflinewidth]tikzcdmatrixname-1-y.north west) --
([yshift=.5pgflinewidth]tikzcdmatrixname-6-y.south west);
]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtikzcd
enddocument


enter image description here



Here I was employing Henri Menke's nice answer and added nodes in empty cells and changed some numbers to only use existing nodes.



ADDENDUM: If you want to the lines right in the middle between the cells without having to add all the shifts by fractions of the line width, you could use the calc library.



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
usetikzlibrarycalc
begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20"),nodes in empty cells,
execute at end picture=
foreach x [evaluate=x as xp using int(x+1)] in 1,3

draw ($(tikzcdmatrixname-x-2.south)!0.5!(tikzcdmatrixname-xp-2.north)$)
coordinate (aux)
([xshift=-.1em]tikzcdmatrixname.west
foreach y [evaluate=y as ym using int(y-1)] in 3
aux);
]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtikzcd
enddocument


As for the question what this might be good for: there are certain things that are somewhat harder to achieve with a table like e.g.



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
usetikzlibrarycalc,through,backgrounds
tikzsetcircle through 3 points/.style n args=3%
insert path=let p1=($(#1)!0.5!(#2)$),
p2=($(#1)!0.5!(#3)$),
p3=($(#1)!0.5!(#2)!1!-90:(#2)$),
p4=($(#1)!0.5!(#3)!1!90:(#3)$),
p5=(intersection of p1--p3 and p2--p4)
in ,
at=(p5),
circle through= (#1)

begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20"),nodes in empty cells,
execute at end picture=
foreach x [evaluate=x as xp using int(x+1)] in 1,3

draw ($(tikzcdmatrixname-x-2.south)!0.5!(tikzcdmatrixname-xp-2.north)$)
coordinate (aux)
([xshift=-.1em]tikzcdmatrixname.west
foreach y [evaluate=y as ym using int(y-1)] in 3
aux);

beginscope[on background layer]
node[circle through 3
points=tikzcdmatrixname-2-2tikzcdmatrixname-3-1tikzcdmatrixname-3-3,
fill=blue!20];
endscope
]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtikzcd
enddocument


enter image description here



Yet for many purposes, the table approach suggested by Joule V is just fine or even better. It really depends on what you want to do in the end.






share|improve this answer















Are you looking for this?



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20"),nodes in empty cells,
execute at end picture=
foreach x in 1,3

draw
([yshift=-3,xshift=-.125pgflinewidth]tikzcdmatrixname-x-1.south west) --
([yshift=-3,xshift=-.125pgflinewidth]tikzcdmatrixname-x-12.south east);

foreach y in 3

draw
([yshift=.5pgflinewidth]tikzcdmatrixname-1-y.north west) --
([yshift=.5pgflinewidth]tikzcdmatrixname-6-y.south west);
]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtikzcd
enddocument


enter image description here



Here I was employing Henri Menke's nice answer and added nodes in empty cells and changed some numbers to only use existing nodes.



ADDENDUM: If you want to the lines right in the middle between the cells without having to add all the shifts by fractions of the line width, you could use the calc library.



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
usetikzlibrarycalc
begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20"),nodes in empty cells,
execute at end picture=
foreach x [evaluate=x as xp using int(x+1)] in 1,3

draw ($(tikzcdmatrixname-x-2.south)!0.5!(tikzcdmatrixname-xp-2.north)$)
coordinate (aux)
([xshift=-.1em]tikzcdmatrixname.west
foreach y [evaluate=y as ym using int(y-1)] in 3
aux);
]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtikzcd
enddocument


As for the question what this might be good for: there are certain things that are somewhat harder to achieve with a table like e.g.



documentclassarticle
usepackage[margin=1cm]geometry
usepackagetikz-cd
usetikzlibrarycalc,through,backgrounds
tikzsetcircle through 3 points/.style n args=3%
insert path=let p1=($(#1)!0.5!(#2)$),
p2=($(#1)!0.5!(#3)$),
p3=($(#1)!0.5!(#2)!1!-90:(#2)$),
p4=($(#1)!0.5!(#3)!1!90:(#3)$),
p5=(intersection of p1--p3 and p2--p4)
in ,
at=(p5),
circle through= (#1)

begindocument
begintikzcd[column sep=3pt, row sep=5pt,nodes=inner sep=0pt,align=center,
text width=width("20"),nodes in empty cells,
execute at end picture=
foreach x [evaluate=x as xp using int(x+1)] in 1,3

draw ($(tikzcdmatrixname-x-2.south)!0.5!(tikzcdmatrixname-xp-2.north)$)
coordinate (aux)
([xshift=-.1em]tikzcdmatrixname.west
foreach y [evaluate=y as ym using int(y-1)] in 3
aux);

beginscope[on background layer]
node[circle through 3
points=tikzcdmatrixname-2-2tikzcdmatrixname-3-1tikzcdmatrixname-3-3,
fill=blue!20];
endscope
]
&&0&0&0&0&0&0&0&0&0&0\
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtikzcd
enddocument


enter image description here



Yet for many purposes, the table approach suggested by Joule V is just fine or even better. It really depends on what you want to do in the end.







share|improve this answer














share|improve this answer



share|improve this answer








edited 6 hours ago

























answered 8 hours ago









marmotmarmot

112k5142268




112k5142268












  • Yes, exactly! Thank you so much.

    – Anush
    8 hours ago











  • The calc addition is very educational. Thank you.

    – Anush
    6 hours ago











  • I'm not aiming to make a war but I do think the last figure is still not difficult ;) We just need some help of a remember picture, overlay TikZ picture :)

    – JouleV
    6 hours ago






  • 1





    @JouleV This meant to be really friendly. AFAIK you cannot achieve this with remember picture easily because you cannot draw it on the background after the table is "done" unless you use atbegshi or something like this, or do something with blend mode .

    – marmot
    6 hours ago

















  • Yes, exactly! Thank you so much.

    – Anush
    8 hours ago











  • The calc addition is very educational. Thank you.

    – Anush
    6 hours ago











  • I'm not aiming to make a war but I do think the last figure is still not difficult ;) We just need some help of a remember picture, overlay TikZ picture :)

    – JouleV
    6 hours ago






  • 1





    @JouleV This meant to be really friendly. AFAIK you cannot achieve this with remember picture easily because you cannot draw it on the background after the table is "done" unless you use atbegshi or something like this, or do something with blend mode .

    – marmot
    6 hours ago
















Yes, exactly! Thank you so much.

– Anush
8 hours ago





Yes, exactly! Thank you so much.

– Anush
8 hours ago













The calc addition is very educational. Thank you.

– Anush
6 hours ago





The calc addition is very educational. Thank you.

– Anush
6 hours ago













I'm not aiming to make a war but I do think the last figure is still not difficult ;) We just need some help of a remember picture, overlay TikZ picture :)

– JouleV
6 hours ago





I'm not aiming to make a war but I do think the last figure is still not difficult ;) We just need some help of a remember picture, overlay TikZ picture :)

– JouleV
6 hours ago




1




1





@JouleV This meant to be really friendly. AFAIK you cannot achieve this with remember picture easily because you cannot draw it on the background after the table is "done" unless you use atbegshi or something like this, or do something with blend mode .

– marmot
6 hours ago





@JouleV This meant to be really friendly. AFAIK you cannot achieve this with remember picture easily because you cannot draw it on the background after the table is "done" unless you use atbegshi or something like this, or do something with blend mode .

– marmot
6 hours ago











5














Just for fun: if you want to make that matrix, why don't use a table? The code is much shorter:



documentclassarticle
begindocument
renewcommandarraystretch1.3
begintabularcc
&&0&0&0&0&0&0&0&0&0&0\hline
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular
enddocument


enter image description here



Coloring the text is not difficult, isn't it? If you want to draw some arrows, tikzmark may be an option. Anyway, if I were you, I would use a simple table. :)




Add an arrow



documentclassarticle
usepackagetikz
begindocument
renewcommandarraystretch1.3
begintabularcc
&&0&0&0&0&0&0&0&0&0&0\hline
&0&1&2&3&4&5&6&7&8&9&10\
0&tikz[baseline,remember picture]node[anchor=base,inner sep=0pt] (node1) 1;&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&tikz[baseline,remember picture]node[anchor=base,inner sep=0pt] (node2) 3;&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular

begintikzpicture[remember picture,overlay]
draw[red,very thick,-latex] (node1) -- (node2);
endtikzpicture
enddocument


enter image description here




Color row(s)



documentclassarticle
usepackagetikz
usepackagexcolor,colortbl
begindocument
renewcommandarraystretch1.3
begintabularcc
rowcolorred!20&&0&0&0&0&0&0&0&0&0&0\hline
rowcolorred!20&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular
enddocument


enter image description here




Color column(s)



documentclassarticle
usepackagetikz
usepackagexcolor,colortbl
begindocument
renewcommandarraystretch1.3
begintabularccc>columncoloryellow!50cc>columncolorgreen!20ccccc
&&0&0&0&0&0&0&0&0&0&0\hline
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular
enddocument


enter image description here




It is never impossible to work with tables using table commands :)






share|improve this answer

























  • I will also add arrows in the table and color some of the elements.

    – Anush
    8 hours ago






  • 2





    And: most users load tikz anyway for the tikzlings. ;-)

    – marmot
    8 hours ago











  • Can you color an entire submatrix of a table out of interest? Say rows 1-2 and columns 4-6?

    – Anush
    8 hours ago






  • 3





    @Anush To color, you have cellcolor. To make arrows, you can have a look at this nice answer.

    – JouleV
    8 hours ago






  • 2





    @Anush I edited my answer: I added some ways to add arrows, color columns and rows.

    – JouleV
    7 hours ago















5














Just for fun: if you want to make that matrix, why don't use a table? The code is much shorter:



documentclassarticle
begindocument
renewcommandarraystretch1.3
begintabularcc
&&0&0&0&0&0&0&0&0&0&0\hline
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular
enddocument


enter image description here



Coloring the text is not difficult, isn't it? If you want to draw some arrows, tikzmark may be an option. Anyway, if I were you, I would use a simple table. :)




Add an arrow



documentclassarticle
usepackagetikz
begindocument
renewcommandarraystretch1.3
begintabularcc
&&0&0&0&0&0&0&0&0&0&0\hline
&0&1&2&3&4&5&6&7&8&9&10\
0&tikz[baseline,remember picture]node[anchor=base,inner sep=0pt] (node1) 1;&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&tikz[baseline,remember picture]node[anchor=base,inner sep=0pt] (node2) 3;&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular

begintikzpicture[remember picture,overlay]
draw[red,very thick,-latex] (node1) -- (node2);
endtikzpicture
enddocument


enter image description here




Color row(s)



documentclassarticle
usepackagetikz
usepackagexcolor,colortbl
begindocument
renewcommandarraystretch1.3
begintabularcc
rowcolorred!20&&0&0&0&0&0&0&0&0&0&0\hline
rowcolorred!20&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular
enddocument


enter image description here




Color column(s)



documentclassarticle
usepackagetikz
usepackagexcolor,colortbl
begindocument
renewcommandarraystretch1.3
begintabularccc>columncoloryellow!50cc>columncolorgreen!20ccccc
&&0&0&0&0&0&0&0&0&0&0\hline
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular
enddocument


enter image description here




It is never impossible to work with tables using table commands :)






share|improve this answer

























  • I will also add arrows in the table and color some of the elements.

    – Anush
    8 hours ago






  • 2





    And: most users load tikz anyway for the tikzlings. ;-)

    – marmot
    8 hours ago











  • Can you color an entire submatrix of a table out of interest? Say rows 1-2 and columns 4-6?

    – Anush
    8 hours ago






  • 3





    @Anush To color, you have cellcolor. To make arrows, you can have a look at this nice answer.

    – JouleV
    8 hours ago






  • 2





    @Anush I edited my answer: I added some ways to add arrows, color columns and rows.

    – JouleV
    7 hours ago













5












5








5







Just for fun: if you want to make that matrix, why don't use a table? The code is much shorter:



documentclassarticle
begindocument
renewcommandarraystretch1.3
begintabularcc
&&0&0&0&0&0&0&0&0&0&0\hline
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular
enddocument


enter image description here



Coloring the text is not difficult, isn't it? If you want to draw some arrows, tikzmark may be an option. Anyway, if I were you, I would use a simple table. :)




Add an arrow



documentclassarticle
usepackagetikz
begindocument
renewcommandarraystretch1.3
begintabularcc
&&0&0&0&0&0&0&0&0&0&0\hline
&0&1&2&3&4&5&6&7&8&9&10\
0&tikz[baseline,remember picture]node[anchor=base,inner sep=0pt] (node1) 1;&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&tikz[baseline,remember picture]node[anchor=base,inner sep=0pt] (node2) 3;&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular

begintikzpicture[remember picture,overlay]
draw[red,very thick,-latex] (node1) -- (node2);
endtikzpicture
enddocument


enter image description here




Color row(s)



documentclassarticle
usepackagetikz
usepackagexcolor,colortbl
begindocument
renewcommandarraystretch1.3
begintabularcc
rowcolorred!20&&0&0&0&0&0&0&0&0&0&0\hline
rowcolorred!20&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular
enddocument


enter image description here




Color column(s)



documentclassarticle
usepackagetikz
usepackagexcolor,colortbl
begindocument
renewcommandarraystretch1.3
begintabularccc>columncoloryellow!50cc>columncolorgreen!20ccccc
&&0&0&0&0&0&0&0&0&0&0\hline
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular
enddocument


enter image description here




It is never impossible to work with tables using table commands :)






share|improve this answer















Just for fun: if you want to make that matrix, why don't use a table? The code is much shorter:



documentclassarticle
begindocument
renewcommandarraystretch1.3
begintabularcc
&&0&0&0&0&0&0&0&0&0&0\hline
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular
enddocument


enter image description here



Coloring the text is not difficult, isn't it? If you want to draw some arrows, tikzmark may be an option. Anyway, if I were you, I would use a simple table. :)




Add an arrow



documentclassarticle
usepackagetikz
begindocument
renewcommandarraystretch1.3
begintabularcc
&&0&0&0&0&0&0&0&0&0&0\hline
&0&1&2&3&4&5&6&7&8&9&10\
0&tikz[baseline,remember picture]node[anchor=base,inner sep=0pt] (node1) 1;&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&tikz[baseline,remember picture]node[anchor=base,inner sep=0pt] (node2) 3;&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular

begintikzpicture[remember picture,overlay]
draw[red,very thick,-latex] (node1) -- (node2);
endtikzpicture
enddocument


enter image description here




Color row(s)



documentclassarticle
usepackagetikz
usepackagexcolor,colortbl
begindocument
renewcommandarraystretch1.3
begintabularcc
rowcolorred!20&&0&0&0&0&0&0&0&0&0&0\hline
rowcolorred!20&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular
enddocument


enter image description here




Color column(s)



documentclassarticle
usepackagetikz
usepackagexcolor,colortbl
begindocument
renewcommandarraystretch1.3
begintabularccc>columncoloryellow!50cc>columncolorgreen!20ccccc
&&0&0&0&0&0&0&0&0&0&0\hline
&0&1&2&3&4&5&6&7&8&9&10\
0&1&0&1&2&3&4&5&6&7&8&9\hline
0&2&1&0&1&2&3&4&5&6&7&8\
0&3&2&1&0&1&2&3&4&5&6&7\
0&4&3&2&1&0&1&2&3&4&5&6
endtabular
enddocument


enter image description here




It is never impossible to work with tables using table commands :)







share|improve this answer














share|improve this answer



share|improve this answer








edited 7 hours ago

























answered 8 hours ago









JouleVJouleV

8,38022154




8,38022154












  • I will also add arrows in the table and color some of the elements.

    – Anush
    8 hours ago






  • 2





    And: most users load tikz anyway for the tikzlings. ;-)

    – marmot
    8 hours ago











  • Can you color an entire submatrix of a table out of interest? Say rows 1-2 and columns 4-6?

    – Anush
    8 hours ago






  • 3





    @Anush To color, you have cellcolor. To make arrows, you can have a look at this nice answer.

    – JouleV
    8 hours ago






  • 2





    @Anush I edited my answer: I added some ways to add arrows, color columns and rows.

    – JouleV
    7 hours ago

















  • I will also add arrows in the table and color some of the elements.

    – Anush
    8 hours ago






  • 2





    And: most users load tikz anyway for the tikzlings. ;-)

    – marmot
    8 hours ago











  • Can you color an entire submatrix of a table out of interest? Say rows 1-2 and columns 4-6?

    – Anush
    8 hours ago






  • 3





    @Anush To color, you have cellcolor. To make arrows, you can have a look at this nice answer.

    – JouleV
    8 hours ago






  • 2





    @Anush I edited my answer: I added some ways to add arrows, color columns and rows.

    – JouleV
    7 hours ago
















I will also add arrows in the table and color some of the elements.

– Anush
8 hours ago





I will also add arrows in the table and color some of the elements.

– Anush
8 hours ago




2




2





And: most users load tikz anyway for the tikzlings. ;-)

– marmot
8 hours ago





And: most users load tikz anyway for the tikzlings. ;-)

– marmot
8 hours ago













Can you color an entire submatrix of a table out of interest? Say rows 1-2 and columns 4-6?

– Anush
8 hours ago





Can you color an entire submatrix of a table out of interest? Say rows 1-2 and columns 4-6?

– Anush
8 hours ago




3




3





@Anush To color, you have cellcolor. To make arrows, you can have a look at this nice answer.

– JouleV
8 hours ago





@Anush To color, you have cellcolor. To make arrows, you can have a look at this nice answer.

– JouleV
8 hours ago




2




2





@Anush I edited my answer: I added some ways to add arrows, color columns and rows.

– JouleV
7 hours ago





@Anush I edited my answer: I added some ways to add arrows, color columns and rows.

– JouleV
7 hours ago

















draft saved

draft discarded
















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f481723%2fhow-to-draw-lines-on-a-tikz-cd-diagram%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Isurus Índice Especies | Notas | Véxase tamén | Menú de navegación"A compendium of fossil marine animal genera (Chondrichthyes entry)"o orixinal"A review of the Tertiary fossil Cetacea (Mammalia) localities in wales port taf Museum Victoria"o orixinalThe Vertebrate Fauna of the Selma Formation of Alabama. Part VII. Part VIII. The Mosasaurs The Fishes50419737IDsh85068767Isurus2548834613242066569678159923NHMSYS00210535017845105743

Is 1 ppb equal to 1 μg/kg? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)How to determine the concentration after a dilution with Beer's law?What would be SMILES notation for a compound with delocalized bonding?Amount of substance of a molecule in a solute the same as amount of substance of constituent elements?Interpreting notation format 1.64E-02 from particulate emission dataWhat was the lithium concentration in 1940's 7-Up?Why are osmoles not considered SI units?Why is Ka constant when volume is increased?Should residual sodium be considered in measuring sodium content of sweat?Concentration of mercury in bodyConversion from a PPB value to µg/m3 of Isobutylene

What does “fit” mean in this sentence? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)How does 'jealousy' mean 'suspicion'?What does “not so say” mean?Does “somebody of my caliber” mean the speaker themselves?“accounting for high fasting blood glucose”- help about the meaningWhat does “cloaked by NDA” mean in this context?What does it mean by 'community ownership' in this context?What does “human corroborators” mean in this context?What does “everything but a fire” mean in this context?What does “run” mean here?What does “rabbited” mean/imply in this sentence?