How to draw lines on a tikz-cd diagram The Next CEO of Stack OverflowDrawing 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

Why do professional authors make "consistency" mistakes? And how to avoid them?

Is it professional to write unrelated content in an almost-empty email?

If the heap is initialized for security, then why is the stack uninitialized?

Has this building technique been used in an official set?

Are there any limitations on attacking while grappling?

What does "Its cash flow is deeply negative" mean?

What happened in Rome, when the western empire "fell"?

Would a galaxy be visible from outside, but nearby?

What is "(CFMCC)" on an ILS approach chart?

What's the best way to handle refactoring a big file?

What connection does MS Office have to Netscape Navigator?

Can you replace a racial trait cantrip when leveling up?

sp_blitzCache results Memory grants

How do I avoid eval and parse?

Is it ever safe to open a suspicious html file (e.g. email attachment)?

Received an invoice from my ex-employer billing me for training; how to handle?

How did the Bene Gesserit know how to make a Kwisatz Haderach?

Sending manuscript to multiple publishers

Novel about a guy who is possessed by the divine essence and the world ends?

How to invert MapIndexed on a ragged structure? How to construct a tree from rules?

Non-deterministic sum of floats

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

What exact does MIB represent in SNMP? How is it different from OID?

Can I run my washing machine drain line into a condensate pump so it drains better?



How to draw lines on a tikz-cd diagram



The Next CEO of Stack OverflowDrawing 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
    2 days 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
    2 days ago












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

    – marmot
    2 days 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
    2 days 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
    2 days 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
    2 days ago












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

    – marmot
    2 days 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
    2 days 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 2 days ago







Anush

















asked 2 days 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
    2 days 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
    2 days ago












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

    – marmot
    2 days 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
    2 days 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
    2 days 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
    2 days ago












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

    – marmot
    2 days 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
    2 days 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
2 days 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
2 days 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
2 days 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
2 days ago














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

– marmot
2 days ago





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

– marmot
2 days 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
2 days 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
2 days 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
-aux) --
([xshift=.1em]tikzcdmatrixname.east
foreach y [evaluate=y as ym using int(y-1)] in 3

draw ($(tikzcdmatrixname-1-y.west)!0.5!(tikzcdmatrixname-1-ym.east)$)
coordinate (aux)
([yshift=0.1ex]tikzcdmatrixname.north-]
&&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
-aux) --
([xshift=.1em]tikzcdmatrixname.east
foreach y [evaluate=y as ym using int(y-1)] in 3

draw ($(tikzcdmatrixname-1-y.west)!0.5!(tikzcdmatrixname-1-ym.east)$)
coordinate (aux)
([yshift=0.1ex]tikzcdmatrixname.north-
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
    2 days ago











  • The calc addition is very educational. Thank you.

    – Anush
    2 days 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
    2 days 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
    2 days 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
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




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
    2 days ago






  • 2





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

    – marmot
    2 days ago











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

    – Anush
    2 days ago






  • 3





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

    – JouleV
    2 days ago






  • 2





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

    – JouleV
    2 days 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
-aux) --
([xshift=.1em]tikzcdmatrixname.east
foreach y [evaluate=y as ym using int(y-1)] in 3

draw ($(tikzcdmatrixname-1-y.west)!0.5!(tikzcdmatrixname-1-ym.east)$)
coordinate (aux)
([yshift=0.1ex]tikzcdmatrixname.north-]
&&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
-aux) --
([xshift=.1em]tikzcdmatrixname.east
foreach y [evaluate=y as ym using int(y-1)] in 3

draw ($(tikzcdmatrixname-1-y.west)!0.5!(tikzcdmatrixname-1-ym.east)$)
coordinate (aux)
([yshift=0.1ex]tikzcdmatrixname.north-
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
    2 days ago











  • The calc addition is very educational. Thank you.

    – Anush
    2 days 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
    2 days 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
    2 days 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
-aux) --
([xshift=.1em]tikzcdmatrixname.east
foreach y [evaluate=y as ym using int(y-1)] in 3

draw ($(tikzcdmatrixname-1-y.west)!0.5!(tikzcdmatrixname-1-ym.east)$)
coordinate (aux)
([yshift=0.1ex]tikzcdmatrixname.north-]
&&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
-aux) --
([xshift=.1em]tikzcdmatrixname.east
foreach y [evaluate=y as ym using int(y-1)] in 3

draw ($(tikzcdmatrixname-1-y.west)!0.5!(tikzcdmatrixname-1-ym.east)$)
coordinate (aux)
([yshift=0.1ex]tikzcdmatrixname.north-
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
    2 days ago











  • The calc addition is very educational. Thank you.

    – Anush
    2 days 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
    2 days 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
    2 days 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
-aux) --
([xshift=.1em]tikzcdmatrixname.east
foreach y [evaluate=y as ym using int(y-1)] in 3

draw ($(tikzcdmatrixname-1-y.west)!0.5!(tikzcdmatrixname-1-ym.east)$)
coordinate (aux)
([yshift=0.1ex]tikzcdmatrixname.north-]
&&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
-aux) --
([xshift=.1em]tikzcdmatrixname.east
foreach y [evaluate=y as ym using int(y-1)] in 3

draw ($(tikzcdmatrixname-1-y.west)!0.5!(tikzcdmatrixname-1-ym.east)$)
coordinate (aux)
([yshift=0.1ex]tikzcdmatrixname.north-
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
-aux) --
([xshift=.1em]tikzcdmatrixname.east
foreach y [evaluate=y as ym using int(y-1)] in 3

draw ($(tikzcdmatrixname-1-y.west)!0.5!(tikzcdmatrixname-1-ym.east)$)
coordinate (aux)
([yshift=0.1ex]tikzcdmatrixname.north-]
&&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
-aux) --
([xshift=.1em]tikzcdmatrixname.east
foreach y [evaluate=y as ym using int(y-1)] in 3

draw ($(tikzcdmatrixname-1-y.west)!0.5!(tikzcdmatrixname-1-ym.east)$)
coordinate (aux)
([yshift=0.1ex]tikzcdmatrixname.north-
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 2 days ago

























answered 2 days ago









marmotmarmot

113k5144273




113k5144273












  • Yes, exactly! Thank you so much.

    – Anush
    2 days ago











  • The calc addition is very educational. Thank you.

    – Anush
    2 days 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
    2 days 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
    2 days ago

















  • Yes, exactly! Thank you so much.

    – Anush
    2 days ago











  • The calc addition is very educational. Thank you.

    – Anush
    2 days 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
    2 days 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
    2 days ago
















Yes, exactly! Thank you so much.

– Anush
2 days ago





Yes, exactly! Thank you so much.

– Anush
2 days ago













The calc addition is very educational. Thank you.

– Anush
2 days ago





The calc addition is very educational. Thank you.

– Anush
2 days 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
2 days 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
2 days 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
2 days 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
2 days 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
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




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
    2 days ago






  • 2





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

    – marmot
    2 days ago











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

    – Anush
    2 days ago






  • 3





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

    – JouleV
    2 days ago






  • 2





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

    – JouleV
    2 days 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
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




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
    2 days ago






  • 2





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

    – marmot
    2 days ago











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

    – Anush
    2 days ago






  • 3





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

    – JouleV
    2 days ago






  • 2





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

    – JouleV
    2 days 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
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




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




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







share|improve this answer














share|improve this answer



share|improve this answer








edited 2 days ago

























answered 2 days ago









JouleVJouleV

8,93222155




8,93222155












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

    – Anush
    2 days ago






  • 2





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

    – marmot
    2 days ago











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

    – Anush
    2 days ago






  • 3





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

    – JouleV
    2 days ago






  • 2





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

    – JouleV
    2 days ago

















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

    – Anush
    2 days ago






  • 2





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

    – marmot
    2 days ago











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

    – Anush
    2 days ago






  • 3





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

    – JouleV
    2 days ago






  • 2





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

    – JouleV
    2 days ago
















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

– Anush
2 days ago





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

– Anush
2 days ago




2




2





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

– marmot
2 days ago





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

– marmot
2 days ago













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

– Anush
2 days ago





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

– Anush
2 days ago




3




3





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

– JouleV
2 days ago





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

– JouleV
2 days ago




2




2





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

– JouleV
2 days ago





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

– JouleV
2 days 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

Boston (Lincolnshire) Stedsbyld | Berne yn Boston | NavigaasjemenuBoston Borough CouncilBoston, Lincolnshire

Ballerup Komuun Stääden an saarpen | Futnuuten | Luke uk diar | Nawigatsjuunwww.ballerup.dkwww.statistikbanken.dk: Tabelle BEF44 (Folketal pr. 1. januar fordelt på byer)Commonskategorii: Ballerup Komuun55° 44′ N, 12° 22′ O

Serbia Índice Etimología Historia Geografía Entorno natural División administrativa Política Demografía Economía Cultura Deportes Véase también Notas Referencias Bibliografía Enlaces externos Menú de navegación44°49′00″N 20°28′00″E / 44.816666666667, 20.46666666666744°49′00″N 20°28′00″E / 44.816666666667, 20.466666666667U.S. Department of Commerce (2015)«Informe sobre Desarrollo Humano 2018»Kosovo-Metohija.Neutralna Srbija u NATO okruzenju.The SerbsTheories on the Origin of the Serbs.Serbia.Earls: Webster's Quotations, Facts and Phrases.Egeo y Balcanes.Kalemegdan.Southern Pannonia during the age of the Great Migrations.Culture in Serbia.History.The Serbian Origin of the Montenegrins.Nemanjics' period (1186-1353).Stefan Uros (1355-1371).Serbian medieval history.Habsburg–Ottoman Wars (1525–1718).The Ottoman Empire, 1700-1922.The First Serbian Uprising.Miloš, prince of Serbia.3. Bosnia-Hercegovina and the Congress of Berlin.The Balkan Wars and the Partition of Macedonia.The Falcon and the Eagle: Montenegro and Austria-Hungary, 1908-1914.Typhus fever on the eastern front in World War I.Anniversary of WWI battle marked in Serbia.La derrota austriaca en los Balcanes. Fin del Imperio Austro-Húngaro.Imperio austriaco y Reino de Hungría.Los tiempos modernos: del capitalismo a la globalización, siglos XVII al XXI.The period of Croatia within ex-Yugoslavia.Yugoslavia: Much in a Name.Las dictaduras europeas.Croacia: mito y realidad."Crods ask arms".Prólogo a la invasión.La campaña de los Balcanes.La resistencia en Yugoslavia.Jasenovac Research Institute.Día en memoria de las víctimas del genocidio en la Segunda Guerra Mundial.El infierno estuvo en Jasenovac.Croacia empieza a «desenterrar» a sus muertos de Jasenovac.World fascism: a historical encyclopedia, Volumen 1.Tito. Josip Broz.El nuevo orden y la resistencia.La conquista del poder.Algunos aspectos de la economía yugoslava a mediados de 1962.Albania-Kosovo crisis.De Kosovo a Kosova: una visión demográfica.La crisis de la economía yugoslava y la política de "estabilización".Milosevic: el poder de un absolutista."Serbia under Milošević: politics in the 1990s"Milosevic cavó en Kosovo la tumba de la antigua Yugoslavia.La ONU exculpa a Serbia de genocidio en la guerra de Bosnia.Slobodan Milosevic, el burócrata que supo usar el odio.Es la fuerza contra el sufrimiento de muchos inocentes.Matanza de civiles al bombardear la OTAN un puente mientras pasaba un tren.Las consecuencias negativas de los bombardeos de Yugoslavia se sentirán aún durante largo tiempo.Kostunica advierte que la misión de Europa en Kosovo es ilegal.Las 24 horas más largas en la vida de Slobodan Milosevic.Serbia declara la guerra a la mafia por matar a Djindjic.Tadic presentará "quizás en diciembre" la solicitud de entrada en la UE.Montenegro declara su independencia de Serbia.Serbia se declara estado soberano tras separación de Montenegro.«Accordance with International Law of the Unilateral Declaration of Independence by the Provisional Institutions of Self-Government of Kosovo (Request for Advisory Opinion)»Mladic pasa por el médico antes de la audiencia para extraditarloDatos de Serbia y Kosovo.The Carpathian Mountains.Position, Relief, Climate.Transport.Finding birds in Serbia.U Srbiji do 2010. godine 10% teritorije nacionalni parkovi.Geography.Serbia: Climate.Variability of Climate In Serbia In The Second Half of The 20thc Entury.BASIC CLIMATE CHARACTERISTICS FOR THE TERRITORY OF SERBIA.Fauna y flora: Serbia.Serbia and Montenegro.Información general sobre Serbia.Republic of Serbia Environmental Protection Agency (SEPA).Serbia recycling 15% of waste.Reform process of the Serbian energy sector.20-MW Wind Project Being Developed in Serbia.Las Naciones Unidas. Paz para Kosovo.Aniversario sin fiesta.Population by national or ethnic groups by Census 2002.Article 7. Coat of arms, flag and national anthem.Serbia, flag of.Historia.«Serbia and Montenegro in Pictures»Serbia.Serbia aprueba su nueva Constitución con un apoyo de más del 50%.Serbia. Population.«El nacionalista Nikolic gana las elecciones presidenciales en Serbia»El europeísta Borís Tadic gana la segunda vuelta de las presidenciales serbias.Aleksandar Vucic, de ultranacionalista serbio a fervoroso europeístaKostunica condena la declaración del "falso estado" de Kosovo.Comienza el debate sobre la independencia de Kosovo en el TIJ.La Corte Internacional de Justicia dice que Kosovo no violó el derecho internacional al declarar su independenciaKosovo: Enviado de la ONU advierte tensiones y fragilidad.«Bruselas recomienda negociar la adhesión de Serbia tras el acuerdo sobre Kosovo»Monografía de Serbia.Bez smanjivanja Vojske Srbije.Military statistics Serbia and Montenegro.Šutanovac: Vojni budžet za 2009. godinu 70 milijardi dinara.Serbia-Montenegro shortens obligatory military service to six months.No hay justicia para las víctimas de los bombardeos de la OTAN.Zapatero reitera la negativa de España a reconocer la independencia de Kosovo.Anniversary of the signing of the Stabilisation and Association Agreement.Detenido en Serbia Radovan Karadzic, el criminal de guerra más buscado de Europa."Serbia presentará su candidatura de acceso a la UE antes de fin de año".Serbia solicita la adhesión a la UE.Detenido el exgeneral serbobosnio Ratko Mladic, principal acusado del genocidio en los Balcanes«Lista de todos los Estados Miembros de las Naciones Unidas que son parte o signatarios en los diversos instrumentos de derechos humanos de las Naciones Unidas»versión pdfProtocolo Facultativo de la Convención sobre la Eliminación de todas las Formas de Discriminación contra la MujerConvención contra la tortura y otros tratos o penas crueles, inhumanos o degradantesversión pdfProtocolo Facultativo de la Convención sobre los Derechos de las Personas con DiscapacidadEl ACNUR recibe con beneplácito el envío de tropas de la OTAN a Kosovo y se prepara ante una posible llegada de refugiados a Serbia.Kosovo.- El jefe de la Minuk denuncia que los serbios boicotearon las legislativas por 'presiones'.Bosnia and Herzegovina. Population.Datos básicos de Montenegro, historia y evolución política.Serbia y Montenegro. Indicador: Tasa global de fecundidad (por 1000 habitantes).Serbia y Montenegro. Indicador: Tasa bruta de mortalidad (por 1000 habitantes).Population.Falleció el patriarca de la Iglesia Ortodoxa serbia.Atacan en Kosovo autobuses con peregrinos tras la investidura del patriarca serbio IrinejSerbian in Hungary.Tasas de cambio."Kosovo es de todos sus ciudadanos".Report for Serbia.Country groups by income.GROSS DOMESTIC PRODUCT (GDP) OF THE REPUBLIC OF SERBIA 1997–2007.Economic Trends in the Republic of Serbia 2006.National Accounts Statitics.Саопштења за јавност.GDP per inhabitant varied by one to six across the EU27 Member States.Un pacto de estabilidad para Serbia.Unemployment rate rises in Serbia.Serbia, Belarus agree free trade to woo investors.Serbia, Turkey call investors to Serbia.Success Stories.U.S. Private Investment in Serbia and Montenegro.Positive trend.Banks in Serbia.La Cámara de Comercio acompaña a empresas madrileñas a Serbia y Croacia.Serbia Industries.Energy and mining.Agriculture.Late crops, fruit and grapes output, 2008.Rebranding Serbia: A Hobby Shortly to Become a Full-Time Job.Final data on livestock statistics, 2008.Serbian cell-phone users.U Srbiji sve više računara.Телекомуникације.U Srbiji 27 odsto gradjana koristi Internet.Serbia and Montenegro.Тренд гледаности програма РТС-а у 2008. и 2009.години.Serbian railways.General Terms.El mercado del transporte aéreo en Serbia.Statistics.Vehículos de motor registrados.Planes ambiciosos para el transporte fluvial.Turismo.Turistički promet u Republici Srbiji u periodu januar-novembar 2007. godine.Your Guide to Culture.Novi Sad - city of culture.Nis - european crossroads.Serbia. Properties inscribed on the World Heritage List .Stari Ras and Sopoćani.Studenica Monastery.Medieval Monuments in Kosovo.Gamzigrad-Romuliana, Palace of Galerius.Skiing and snowboarding in Kopaonik.Tara.New7Wonders of Nature Finalists.Pilgrimage of Saint Sava.Exit Festival: Best european festival.Banje u Srbiji.«The Encyclopedia of world history»Culture.Centenario del arte serbio.«Djordje Andrejevic Kun: el único pintor de los brigadistas yugoslavos de la guerra civil española»About the museum.The collections.Miroslav Gospel – Manuscript from 1180.Historicity in the Serbo-Croatian Heroic Epic.Culture and Sport.Conversación con el rector del Seminario San Sava.'Reina Margot' funde drama, historia y gesto con música de Goran Bregovic.Serbia gana Eurovisión y España decepciona de nuevo con un vigésimo puesto.Home.Story.Emir Kusturica.Tercer oro para Paskaljevic.Nikola Tesla Year.Home.Tesla, un genio tomado por loco.Aniversario de la muerte de Nikola Tesla.El Museo Nikola Tesla en Belgrado.El inventor del mundo actual.República de Serbia.University of Belgrade official statistics.University of Novi Sad.University of Kragujevac.University of Nis.Comida. Cocina serbia.Cooking.Montenegro se convertirá en el miembro 204 del movimiento olímpico.España, campeona de Europa de baloncesto.El Partizan de Belgrado se corona campeón por octava vez consecutiva.Serbia se clasifica para el Mundial de 2010 de Sudáfrica.Serbia Name Squad For Northern Ireland And South Korea Tests.Fútbol.- El Partizán de Belgrado se proclama campeón de la Liga serbia.Clasificacion final Mundial de balonmano Croacia 2009.Serbia vence a España y se consagra campeón mundial de waterpolo.Novak Djokovic no convence pero gana en Australia.Gana Ana Ivanovic el Roland Garros.Serena Williams gana el US Open por tercera vez.Biography.Bradt Travel Guide SerbiaThe Encyclopedia of World War IGobierno de SerbiaPortal del Gobierno de SerbiaPresidencia de SerbiaAsamblea Nacional SerbiaMinisterio de Asuntos exteriores de SerbiaBanco Nacional de SerbiaAgencia Serbia para la Promoción de la Inversión y la ExportaciónOficina de Estadísticas de SerbiaCIA. Factbook 2008Organización nacional de turismo de SerbiaDiscover SerbiaConoce SerbiaNoticias de SerbiaSerbiaWorldCat1512028760000 0000 9526 67094054598-2n8519591900570825ge1309191004530741010url17413117006669D055771Serbia