How do I draw the following matrix in LaTeX?
up vote
2
down vote
favorite
I want to draw the following matrix in LaTeX:
I found that I should use the TikZ package, and I have spent a lot of time looking at the package. However, I have no experience of using the package before, and I do not know how to draw it. How can I do it?
tikz-matrix
New contributor
add a comment |
up vote
2
down vote
favorite
I want to draw the following matrix in LaTeX:
I found that I should use the TikZ package, and I have spent a lot of time looking at the package. However, I have no experience of using the package before, and I do not know how to draw it. How can I do it?
tikz-matrix
New contributor
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I want to draw the following matrix in LaTeX:
I found that I should use the TikZ package, and I have spent a lot of time looking at the package. However, I have no experience of using the package before, and I do not know how to draw it. How can I do it?
tikz-matrix
New contributor
I want to draw the following matrix in LaTeX:
I found that I should use the TikZ package, and I have spent a lot of time looking at the package. However, I have no experience of using the package before, and I do not know how to draw it. How can I do it?
tikz-matrix
tikz-matrix
New contributor
New contributor
edited yesterday
Peter Mortensen
52736
52736
New contributor
asked yesterday
Sherry
1225
1225
New contributor
New contributor
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
15
down vote
accepted
Just arrays:
documentclass{article}
usepackage{amsmath,array}
begin{document}
[
newcommand{blocke}{
begin{matrix}
hphantom{0} & hphantom{0} & hphantom{0} & hphantom{0} \
\ \
end{matrix}
}
newcommand{blockr}{
begin{matrix}
hphantom{0} & hphantom{0} & hphantom{0} &
hat{N}smash[b]{vphantom{Big|}} \ &&& vdots \ &&& 2 \ &&& 1
end{matrix}
}
newcommand{blockl}{
begin{matrix}
1 & hphantom{0} & hphantom{0} & hphantom{0} \
2 \ vdots \ hat{N}smash[b]{vphantom{Big|}}
end{matrix}
}
newcommand{dddots}{
begin{matrix}
hphantom{0} & hphantom{0} & ddots \
\
\
ddots
end{matrix}
}
begin{pmatrix}
hspace*{0.3em}
begin{array}{|*{5}{@{,}c@{!}|}}
hline
& blockl & & & blocke \
hline
blockr & & blockl & & \
hline
& blockr & & blockl & \
hline
& & & dddots & \
hline
& & & blockr & \
hline
end{array}
hspace*{0.3em}
end{pmatrix}
]
end{document}
I locally defined a few commands to ease input.
Is it possible to make the parentheses curver/more curve?
– Ooker
yesterday
add a comment |
up vote
9
down vote
Welcome to TeX.SE! Actually, you do not need TikZ for this.
documentclass{article}
usepackage{amsmath}
begin{document}
[left(begin{array}{|*{5}{ccccc|}}
hline
& & & & & 1 & & & & & & & & & & & & & & & & & & & \
& & & & & 2 & & & & & & & & & & & & & & & & & & & \
& & & & & vdots & & & & & & & & & & & & & & & & & & & \
& & & & & vdots & & & & & & & & & & & & & & & & & & & \
& & & & & widehat{N} & & & & & & & & & & & & & & & & & & & \
hline
& & & & widehat{N} & & & & & & 1 & & & & & & & & & & & & & & \
& & & & vdots & & & & & & 2 & & & & & & & & & & & & & & \
& & & & vdots & & & & & & vdots & & & & & & & & & & & & & & \
& & & & 2 & & & & & & vdots & & & & & & & & & & & & & & \
& & & & 1 & & & & & & widehat{N} & & & & & & & & & & & & & & \
hline
& & & & & & & & & widehat{N} & & & & & & 1 & & & & & & & & & \
& & & & & & & & & vdots & & & & & & 2 & & & & & & & & & \
& & & & & & & & & vdots & & & & & & vdots & & & & & & & & & \
& & & & & & & & & 2 & & & & & & vdots & & & & & & & & & \
& & & & & & & & & 1 & & & & & & widehat{N} & & & & & & & & & \
hline
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
& & & & & & & & & & & & & & & & & & bullet & & & & & & \
& & & & & & & & & & & & & & & bullet & & & & bullet & & & & & \
& & & & & & & & & & & & & & & & bullet & & & & & & & & \
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
hline
& & & & & & & & & & & & & & & & & & & widehat{N} & & & & & \
& & & & & & & & & & & & & & & & & & & vdots & & & & & \
& & & & & & & & & & & & & & & & & & & vdots & & & & & \
& & & & & & & & & & & & & & & & & & & 2 & & & & & \
& & & & & & & & & & & & & & & & & & & 1 & & & & & \
hline
end{array}right)]
end{document}
However, you could use TikZ to improve the appearance.
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{tikzmark}
tikzset{% https://tex.stackexchange.com/a/156990/121799
dots/.style args={#1per #2}{%
line cap=round,
dash pattern=on 0 off #2/#1
}
}
begin{document}
[left(begin{array}{|*{5}{ccccc|}}
hline
& & & & & 1 & & & & & & & & & & & & & & & & & & & \
& & & & & tikzmarknode{21}{2} & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & tikzmarknode{N1}{widehat{N}} & & & & & & & & & & & & & & & & & & & \
hline
& & & & tikzmarknode{N2}{widehat{N}} & & & & & & 1 & & & & & & & & & & & & & & \
& & & & & & & & & & tikzmarknode{23}{2} & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & tikzmarknode{22}{2} & & & & & & & & & & & & & & & & & & & & \
& & & & 1 & & & & & & tikzmarknode{N3}{widehat{N}} & & & & & & & & & & & & & & \
hline
& & & & & & & & & tikzmarknode{N4}{widehat{N}} & & & & & & 1 & & & & & & & & & \
& & & & & & & & & & & & & & & tikzmarknode{25}{2} & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & tikzmarknode{24}{2} & & & & & & & & & & & & & & & \
& & & & & & & & & 1 & & & & & & tikzmarknode{N5}{widehat{N}} & & & & & & & & & \
hline
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
& & & & & & & & & & & & & & & & & & bullet & & & & & & \
& & & & & & & & & & & & & & & bullet & & & & bullet & & & & & \
& & & & & & & & & & & & & & & & bullet & & & & & & & & \
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
hline
& & & & & & & & & & & & & & & & & & & tikzmarknode{N6}{widehat{N}} & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & tikzmarknode{26}{2} & & & & & \
& & & & & & & & & & & & & & & & & & & 1 & & & & & \
hline
end{array}right)]
begin{tikzpicture}[overlay,remember picture]
foreach X in {1,...,6}
{draw[very thick, dots=8 per 1cm,shorten >=3pt,shorten <=3pt] (2X) -- (NX);}
end{tikzpicture}
end{document}
ADDENDUM: In an attempt to make Ryan Reich a bit happy, here is a version in which you only have to specify the nonempty entries of this sparse array. These entries are determined by the list {6/1/1,6/2/2,6/5/widehat{N},... }
, where each entry has the structure <X>/<Y>/<entry>
with X
and Y
specifying the position. Notice that one could shorten this further if you really have only one type of columns, but the point here is to allow to build arbitrary sparse matrices of that type. This code uses this answer.
documentclass{article}
usepackage{tikz}
usetikzlibrary{matrix,calc}
usepackage{etoolbox}
tikzset{% https://tex.stackexchange.com/a/156990/121799
dots/.style args={#1per #2}{%
line cap=round,
dash pattern=on 0 off #2/#1
}
}
begin{document}
edefmylist{6/1/1,6/2/2,6/5/widehat{N},%
5/6/widehat{N},5/9/2,5/10/1,%
11/6/1,11/7/2,11/10/widehat{N},%
10/11/widehat{N},10/12/2,10/15/1,%
16/11/1,16/12/2,16/15/widehat{N},%
20/21/widehat{N},20/22/2,20/25/1%
}
begin{tikzpicture}
letmymatrixcontentempty
foreach Y in {1,...,25}{%
foreach X in {1,...,25}
{xdeftmp{{}}
foreach XX/YY/ZZ in mylist
{ifnumXX=X
ifnumYY=Y
xdeftmp{ZZ}
fi
fi}
ifnumX=25
expandaftergapptoexpandaftermymatrixcontentexpandafter{tmpspace\}%
else
expandaftergapptoexpandaftermymatrixcontentexpandafter{tmpspace&space}%
fi
}
}
matrix [matrix of math nodes,ampersand replacement=&,left delimiter=(,
right delimiter=),draw,row sep=3pt] (mat) {
mymatrixcontent
};
foreach X [evaluate=X as Y using {int(X+1)}]in {5,10,...,20}
{coordinate (aux1) at ($(mat-1-Y.west)!0.5!(mat-1-X.east)$);
coordinate (aux2) at (mat-X-1.south);
draw (mat.north -| aux1) -- (mat.south -| aux1)
(mat.west |- aux2) -- (mat.east |- aux2);}
foreach X/Y [evaluate=Y as Z using {int(Y+3)}] in
{6/2,5/6,11/7,10/12,16/12,20/22}
{draw[very thick, dots=8 per 1cm,shorten >=3pt,shorten <=3pt]
(mat-Y-X) -- (mat-Z-X);}
draw[line width=1.2mm, dots=4 per 1cm]
(mat-16-18.center) -- (mat-18-20.center)
(mat-18-16.center) -- (mat-20-18.center);
end{tikzpicture}
end{document}
I don't want to be a jerk, but filling a page with ampersands that require careful counting is not a very helpful answer.
– Ryan Reich
yesterday
@RyanReich Are you really typing them one by one? If so, then I agree. But of course if you just do copy and paste, then it is not that cumbersome. Well, and if you like phantoms better (and make sure that none of the entries exceeds the size of those), I'd say this is a matter of taste, but otherwise it is a bit nontrivial to bet things aligned across different blocks. So that is just to say that I definitely did not have to count here.
– marmot
yesterday
1
What if I make a mistake? What if I need to make a change? There may technically be a programmatic avenue into this gigantic expression but it's fragile and not apparent on the finished product. It doesn't say what it does, it just is.
– Ryan Reich
yesterday
@RyanReich If you make a mistake, you will not get what you want. However, this is not specific to this matrix. You seem not to like this answer, which is fine. However, I do not really see the purpose of your comments. I believe to have told you why I did what I did. If you have a better solution post it. (And yes, I do now how to typeset a matrix programmatically. Do you want me to post such a solution? The OP has already made her choice...) And yes, the matrix is gigantic.
– marmot
yesterday
@RyanReich In an attempt to remove the tension in our exchange of opinions, I added a version in which you only need to specify the nontrivial entries.
– marmot
yesterday
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
15
down vote
accepted
Just arrays:
documentclass{article}
usepackage{amsmath,array}
begin{document}
[
newcommand{blocke}{
begin{matrix}
hphantom{0} & hphantom{0} & hphantom{0} & hphantom{0} \
\ \
end{matrix}
}
newcommand{blockr}{
begin{matrix}
hphantom{0} & hphantom{0} & hphantom{0} &
hat{N}smash[b]{vphantom{Big|}} \ &&& vdots \ &&& 2 \ &&& 1
end{matrix}
}
newcommand{blockl}{
begin{matrix}
1 & hphantom{0} & hphantom{0} & hphantom{0} \
2 \ vdots \ hat{N}smash[b]{vphantom{Big|}}
end{matrix}
}
newcommand{dddots}{
begin{matrix}
hphantom{0} & hphantom{0} & ddots \
\
\
ddots
end{matrix}
}
begin{pmatrix}
hspace*{0.3em}
begin{array}{|*{5}{@{,}c@{!}|}}
hline
& blockl & & & blocke \
hline
blockr & & blockl & & \
hline
& blockr & & blockl & \
hline
& & & dddots & \
hline
& & & blockr & \
hline
end{array}
hspace*{0.3em}
end{pmatrix}
]
end{document}
I locally defined a few commands to ease input.
Is it possible to make the parentheses curver/more curve?
– Ooker
yesterday
add a comment |
up vote
15
down vote
accepted
Just arrays:
documentclass{article}
usepackage{amsmath,array}
begin{document}
[
newcommand{blocke}{
begin{matrix}
hphantom{0} & hphantom{0} & hphantom{0} & hphantom{0} \
\ \
end{matrix}
}
newcommand{blockr}{
begin{matrix}
hphantom{0} & hphantom{0} & hphantom{0} &
hat{N}smash[b]{vphantom{Big|}} \ &&& vdots \ &&& 2 \ &&& 1
end{matrix}
}
newcommand{blockl}{
begin{matrix}
1 & hphantom{0} & hphantom{0} & hphantom{0} \
2 \ vdots \ hat{N}smash[b]{vphantom{Big|}}
end{matrix}
}
newcommand{dddots}{
begin{matrix}
hphantom{0} & hphantom{0} & ddots \
\
\
ddots
end{matrix}
}
begin{pmatrix}
hspace*{0.3em}
begin{array}{|*{5}{@{,}c@{!}|}}
hline
& blockl & & & blocke \
hline
blockr & & blockl & & \
hline
& blockr & & blockl & \
hline
& & & dddots & \
hline
& & & blockr & \
hline
end{array}
hspace*{0.3em}
end{pmatrix}
]
end{document}
I locally defined a few commands to ease input.
Is it possible to make the parentheses curver/more curve?
– Ooker
yesterday
add a comment |
up vote
15
down vote
accepted
up vote
15
down vote
accepted
Just arrays:
documentclass{article}
usepackage{amsmath,array}
begin{document}
[
newcommand{blocke}{
begin{matrix}
hphantom{0} & hphantom{0} & hphantom{0} & hphantom{0} \
\ \
end{matrix}
}
newcommand{blockr}{
begin{matrix}
hphantom{0} & hphantom{0} & hphantom{0} &
hat{N}smash[b]{vphantom{Big|}} \ &&& vdots \ &&& 2 \ &&& 1
end{matrix}
}
newcommand{blockl}{
begin{matrix}
1 & hphantom{0} & hphantom{0} & hphantom{0} \
2 \ vdots \ hat{N}smash[b]{vphantom{Big|}}
end{matrix}
}
newcommand{dddots}{
begin{matrix}
hphantom{0} & hphantom{0} & ddots \
\
\
ddots
end{matrix}
}
begin{pmatrix}
hspace*{0.3em}
begin{array}{|*{5}{@{,}c@{!}|}}
hline
& blockl & & & blocke \
hline
blockr & & blockl & & \
hline
& blockr & & blockl & \
hline
& & & dddots & \
hline
& & & blockr & \
hline
end{array}
hspace*{0.3em}
end{pmatrix}
]
end{document}
I locally defined a few commands to ease input.
Just arrays:
documentclass{article}
usepackage{amsmath,array}
begin{document}
[
newcommand{blocke}{
begin{matrix}
hphantom{0} & hphantom{0} & hphantom{0} & hphantom{0} \
\ \
end{matrix}
}
newcommand{blockr}{
begin{matrix}
hphantom{0} & hphantom{0} & hphantom{0} &
hat{N}smash[b]{vphantom{Big|}} \ &&& vdots \ &&& 2 \ &&& 1
end{matrix}
}
newcommand{blockl}{
begin{matrix}
1 & hphantom{0} & hphantom{0} & hphantom{0} \
2 \ vdots \ hat{N}smash[b]{vphantom{Big|}}
end{matrix}
}
newcommand{dddots}{
begin{matrix}
hphantom{0} & hphantom{0} & ddots \
\
\
ddots
end{matrix}
}
begin{pmatrix}
hspace*{0.3em}
begin{array}{|*{5}{@{,}c@{!}|}}
hline
& blockl & & & blocke \
hline
blockr & & blockl & & \
hline
& blockr & & blockl & \
hline
& & & dddots & \
hline
& & & blockr & \
hline
end{array}
hspace*{0.3em}
end{pmatrix}
]
end{document}
I locally defined a few commands to ease input.
answered yesterday
egreg
698k8518553123
698k8518553123
Is it possible to make the parentheses curver/more curve?
– Ooker
yesterday
add a comment |
Is it possible to make the parentheses curver/more curve?
– Ooker
yesterday
Is it possible to make the parentheses curver/more curve?
– Ooker
yesterday
Is it possible to make the parentheses curver/more curve?
– Ooker
yesterday
add a comment |
up vote
9
down vote
Welcome to TeX.SE! Actually, you do not need TikZ for this.
documentclass{article}
usepackage{amsmath}
begin{document}
[left(begin{array}{|*{5}{ccccc|}}
hline
& & & & & 1 & & & & & & & & & & & & & & & & & & & \
& & & & & 2 & & & & & & & & & & & & & & & & & & & \
& & & & & vdots & & & & & & & & & & & & & & & & & & & \
& & & & & vdots & & & & & & & & & & & & & & & & & & & \
& & & & & widehat{N} & & & & & & & & & & & & & & & & & & & \
hline
& & & & widehat{N} & & & & & & 1 & & & & & & & & & & & & & & \
& & & & vdots & & & & & & 2 & & & & & & & & & & & & & & \
& & & & vdots & & & & & & vdots & & & & & & & & & & & & & & \
& & & & 2 & & & & & & vdots & & & & & & & & & & & & & & \
& & & & 1 & & & & & & widehat{N} & & & & & & & & & & & & & & \
hline
& & & & & & & & & widehat{N} & & & & & & 1 & & & & & & & & & \
& & & & & & & & & vdots & & & & & & 2 & & & & & & & & & \
& & & & & & & & & vdots & & & & & & vdots & & & & & & & & & \
& & & & & & & & & 2 & & & & & & vdots & & & & & & & & & \
& & & & & & & & & 1 & & & & & & widehat{N} & & & & & & & & & \
hline
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
& & & & & & & & & & & & & & & & & & bullet & & & & & & \
& & & & & & & & & & & & & & & bullet & & & & bullet & & & & & \
& & & & & & & & & & & & & & & & bullet & & & & & & & & \
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
hline
& & & & & & & & & & & & & & & & & & & widehat{N} & & & & & \
& & & & & & & & & & & & & & & & & & & vdots & & & & & \
& & & & & & & & & & & & & & & & & & & vdots & & & & & \
& & & & & & & & & & & & & & & & & & & 2 & & & & & \
& & & & & & & & & & & & & & & & & & & 1 & & & & & \
hline
end{array}right)]
end{document}
However, you could use TikZ to improve the appearance.
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{tikzmark}
tikzset{% https://tex.stackexchange.com/a/156990/121799
dots/.style args={#1per #2}{%
line cap=round,
dash pattern=on 0 off #2/#1
}
}
begin{document}
[left(begin{array}{|*{5}{ccccc|}}
hline
& & & & & 1 & & & & & & & & & & & & & & & & & & & \
& & & & & tikzmarknode{21}{2} & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & tikzmarknode{N1}{widehat{N}} & & & & & & & & & & & & & & & & & & & \
hline
& & & & tikzmarknode{N2}{widehat{N}} & & & & & & 1 & & & & & & & & & & & & & & \
& & & & & & & & & & tikzmarknode{23}{2} & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & tikzmarknode{22}{2} & & & & & & & & & & & & & & & & & & & & \
& & & & 1 & & & & & & tikzmarknode{N3}{widehat{N}} & & & & & & & & & & & & & & \
hline
& & & & & & & & & tikzmarknode{N4}{widehat{N}} & & & & & & 1 & & & & & & & & & \
& & & & & & & & & & & & & & & tikzmarknode{25}{2} & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & tikzmarknode{24}{2} & & & & & & & & & & & & & & & \
& & & & & & & & & 1 & & & & & & tikzmarknode{N5}{widehat{N}} & & & & & & & & & \
hline
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
& & & & & & & & & & & & & & & & & & bullet & & & & & & \
& & & & & & & & & & & & & & & bullet & & & & bullet & & & & & \
& & & & & & & & & & & & & & & & bullet & & & & & & & & \
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
hline
& & & & & & & & & & & & & & & & & & & tikzmarknode{N6}{widehat{N}} & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & tikzmarknode{26}{2} & & & & & \
& & & & & & & & & & & & & & & & & & & 1 & & & & & \
hline
end{array}right)]
begin{tikzpicture}[overlay,remember picture]
foreach X in {1,...,6}
{draw[very thick, dots=8 per 1cm,shorten >=3pt,shorten <=3pt] (2X) -- (NX);}
end{tikzpicture}
end{document}
ADDENDUM: In an attempt to make Ryan Reich a bit happy, here is a version in which you only have to specify the nonempty entries of this sparse array. These entries are determined by the list {6/1/1,6/2/2,6/5/widehat{N},... }
, where each entry has the structure <X>/<Y>/<entry>
with X
and Y
specifying the position. Notice that one could shorten this further if you really have only one type of columns, but the point here is to allow to build arbitrary sparse matrices of that type. This code uses this answer.
documentclass{article}
usepackage{tikz}
usetikzlibrary{matrix,calc}
usepackage{etoolbox}
tikzset{% https://tex.stackexchange.com/a/156990/121799
dots/.style args={#1per #2}{%
line cap=round,
dash pattern=on 0 off #2/#1
}
}
begin{document}
edefmylist{6/1/1,6/2/2,6/5/widehat{N},%
5/6/widehat{N},5/9/2,5/10/1,%
11/6/1,11/7/2,11/10/widehat{N},%
10/11/widehat{N},10/12/2,10/15/1,%
16/11/1,16/12/2,16/15/widehat{N},%
20/21/widehat{N},20/22/2,20/25/1%
}
begin{tikzpicture}
letmymatrixcontentempty
foreach Y in {1,...,25}{%
foreach X in {1,...,25}
{xdeftmp{{}}
foreach XX/YY/ZZ in mylist
{ifnumXX=X
ifnumYY=Y
xdeftmp{ZZ}
fi
fi}
ifnumX=25
expandaftergapptoexpandaftermymatrixcontentexpandafter{tmpspace\}%
else
expandaftergapptoexpandaftermymatrixcontentexpandafter{tmpspace&space}%
fi
}
}
matrix [matrix of math nodes,ampersand replacement=&,left delimiter=(,
right delimiter=),draw,row sep=3pt] (mat) {
mymatrixcontent
};
foreach X [evaluate=X as Y using {int(X+1)}]in {5,10,...,20}
{coordinate (aux1) at ($(mat-1-Y.west)!0.5!(mat-1-X.east)$);
coordinate (aux2) at (mat-X-1.south);
draw (mat.north -| aux1) -- (mat.south -| aux1)
(mat.west |- aux2) -- (mat.east |- aux2);}
foreach X/Y [evaluate=Y as Z using {int(Y+3)}] in
{6/2,5/6,11/7,10/12,16/12,20/22}
{draw[very thick, dots=8 per 1cm,shorten >=3pt,shorten <=3pt]
(mat-Y-X) -- (mat-Z-X);}
draw[line width=1.2mm, dots=4 per 1cm]
(mat-16-18.center) -- (mat-18-20.center)
(mat-18-16.center) -- (mat-20-18.center);
end{tikzpicture}
end{document}
I don't want to be a jerk, but filling a page with ampersands that require careful counting is not a very helpful answer.
– Ryan Reich
yesterday
@RyanReich Are you really typing them one by one? If so, then I agree. But of course if you just do copy and paste, then it is not that cumbersome. Well, and if you like phantoms better (and make sure that none of the entries exceeds the size of those), I'd say this is a matter of taste, but otherwise it is a bit nontrivial to bet things aligned across different blocks. So that is just to say that I definitely did not have to count here.
– marmot
yesterday
1
What if I make a mistake? What if I need to make a change? There may technically be a programmatic avenue into this gigantic expression but it's fragile and not apparent on the finished product. It doesn't say what it does, it just is.
– Ryan Reich
yesterday
@RyanReich If you make a mistake, you will not get what you want. However, this is not specific to this matrix. You seem not to like this answer, which is fine. However, I do not really see the purpose of your comments. I believe to have told you why I did what I did. If you have a better solution post it. (And yes, I do now how to typeset a matrix programmatically. Do you want me to post such a solution? The OP has already made her choice...) And yes, the matrix is gigantic.
– marmot
yesterday
@RyanReich In an attempt to remove the tension in our exchange of opinions, I added a version in which you only need to specify the nontrivial entries.
– marmot
yesterday
add a comment |
up vote
9
down vote
Welcome to TeX.SE! Actually, you do not need TikZ for this.
documentclass{article}
usepackage{amsmath}
begin{document}
[left(begin{array}{|*{5}{ccccc|}}
hline
& & & & & 1 & & & & & & & & & & & & & & & & & & & \
& & & & & 2 & & & & & & & & & & & & & & & & & & & \
& & & & & vdots & & & & & & & & & & & & & & & & & & & \
& & & & & vdots & & & & & & & & & & & & & & & & & & & \
& & & & & widehat{N} & & & & & & & & & & & & & & & & & & & \
hline
& & & & widehat{N} & & & & & & 1 & & & & & & & & & & & & & & \
& & & & vdots & & & & & & 2 & & & & & & & & & & & & & & \
& & & & vdots & & & & & & vdots & & & & & & & & & & & & & & \
& & & & 2 & & & & & & vdots & & & & & & & & & & & & & & \
& & & & 1 & & & & & & widehat{N} & & & & & & & & & & & & & & \
hline
& & & & & & & & & widehat{N} & & & & & & 1 & & & & & & & & & \
& & & & & & & & & vdots & & & & & & 2 & & & & & & & & & \
& & & & & & & & & vdots & & & & & & vdots & & & & & & & & & \
& & & & & & & & & 2 & & & & & & vdots & & & & & & & & & \
& & & & & & & & & 1 & & & & & & widehat{N} & & & & & & & & & \
hline
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
& & & & & & & & & & & & & & & & & & bullet & & & & & & \
& & & & & & & & & & & & & & & bullet & & & & bullet & & & & & \
& & & & & & & & & & & & & & & & bullet & & & & & & & & \
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
hline
& & & & & & & & & & & & & & & & & & & widehat{N} & & & & & \
& & & & & & & & & & & & & & & & & & & vdots & & & & & \
& & & & & & & & & & & & & & & & & & & vdots & & & & & \
& & & & & & & & & & & & & & & & & & & 2 & & & & & \
& & & & & & & & & & & & & & & & & & & 1 & & & & & \
hline
end{array}right)]
end{document}
However, you could use TikZ to improve the appearance.
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{tikzmark}
tikzset{% https://tex.stackexchange.com/a/156990/121799
dots/.style args={#1per #2}{%
line cap=round,
dash pattern=on 0 off #2/#1
}
}
begin{document}
[left(begin{array}{|*{5}{ccccc|}}
hline
& & & & & 1 & & & & & & & & & & & & & & & & & & & \
& & & & & tikzmarknode{21}{2} & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & tikzmarknode{N1}{widehat{N}} & & & & & & & & & & & & & & & & & & & \
hline
& & & & tikzmarknode{N2}{widehat{N}} & & & & & & 1 & & & & & & & & & & & & & & \
& & & & & & & & & & tikzmarknode{23}{2} & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & tikzmarknode{22}{2} & & & & & & & & & & & & & & & & & & & & \
& & & & 1 & & & & & & tikzmarknode{N3}{widehat{N}} & & & & & & & & & & & & & & \
hline
& & & & & & & & & tikzmarknode{N4}{widehat{N}} & & & & & & 1 & & & & & & & & & \
& & & & & & & & & & & & & & & tikzmarknode{25}{2} & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & tikzmarknode{24}{2} & & & & & & & & & & & & & & & \
& & & & & & & & & 1 & & & & & & tikzmarknode{N5}{widehat{N}} & & & & & & & & & \
hline
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
& & & & & & & & & & & & & & & & & & bullet & & & & & & \
& & & & & & & & & & & & & & & bullet & & & & bullet & & & & & \
& & & & & & & & & & & & & & & & bullet & & & & & & & & \
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
hline
& & & & & & & & & & & & & & & & & & & tikzmarknode{N6}{widehat{N}} & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & tikzmarknode{26}{2} & & & & & \
& & & & & & & & & & & & & & & & & & & 1 & & & & & \
hline
end{array}right)]
begin{tikzpicture}[overlay,remember picture]
foreach X in {1,...,6}
{draw[very thick, dots=8 per 1cm,shorten >=3pt,shorten <=3pt] (2X) -- (NX);}
end{tikzpicture}
end{document}
ADDENDUM: In an attempt to make Ryan Reich a bit happy, here is a version in which you only have to specify the nonempty entries of this sparse array. These entries are determined by the list {6/1/1,6/2/2,6/5/widehat{N},... }
, where each entry has the structure <X>/<Y>/<entry>
with X
and Y
specifying the position. Notice that one could shorten this further if you really have only one type of columns, but the point here is to allow to build arbitrary sparse matrices of that type. This code uses this answer.
documentclass{article}
usepackage{tikz}
usetikzlibrary{matrix,calc}
usepackage{etoolbox}
tikzset{% https://tex.stackexchange.com/a/156990/121799
dots/.style args={#1per #2}{%
line cap=round,
dash pattern=on 0 off #2/#1
}
}
begin{document}
edefmylist{6/1/1,6/2/2,6/5/widehat{N},%
5/6/widehat{N},5/9/2,5/10/1,%
11/6/1,11/7/2,11/10/widehat{N},%
10/11/widehat{N},10/12/2,10/15/1,%
16/11/1,16/12/2,16/15/widehat{N},%
20/21/widehat{N},20/22/2,20/25/1%
}
begin{tikzpicture}
letmymatrixcontentempty
foreach Y in {1,...,25}{%
foreach X in {1,...,25}
{xdeftmp{{}}
foreach XX/YY/ZZ in mylist
{ifnumXX=X
ifnumYY=Y
xdeftmp{ZZ}
fi
fi}
ifnumX=25
expandaftergapptoexpandaftermymatrixcontentexpandafter{tmpspace\}%
else
expandaftergapptoexpandaftermymatrixcontentexpandafter{tmpspace&space}%
fi
}
}
matrix [matrix of math nodes,ampersand replacement=&,left delimiter=(,
right delimiter=),draw,row sep=3pt] (mat) {
mymatrixcontent
};
foreach X [evaluate=X as Y using {int(X+1)}]in {5,10,...,20}
{coordinate (aux1) at ($(mat-1-Y.west)!0.5!(mat-1-X.east)$);
coordinate (aux2) at (mat-X-1.south);
draw (mat.north -| aux1) -- (mat.south -| aux1)
(mat.west |- aux2) -- (mat.east |- aux2);}
foreach X/Y [evaluate=Y as Z using {int(Y+3)}] in
{6/2,5/6,11/7,10/12,16/12,20/22}
{draw[very thick, dots=8 per 1cm,shorten >=3pt,shorten <=3pt]
(mat-Y-X) -- (mat-Z-X);}
draw[line width=1.2mm, dots=4 per 1cm]
(mat-16-18.center) -- (mat-18-20.center)
(mat-18-16.center) -- (mat-20-18.center);
end{tikzpicture}
end{document}
I don't want to be a jerk, but filling a page with ampersands that require careful counting is not a very helpful answer.
– Ryan Reich
yesterday
@RyanReich Are you really typing them one by one? If so, then I agree. But of course if you just do copy and paste, then it is not that cumbersome. Well, and if you like phantoms better (and make sure that none of the entries exceeds the size of those), I'd say this is a matter of taste, but otherwise it is a bit nontrivial to bet things aligned across different blocks. So that is just to say that I definitely did not have to count here.
– marmot
yesterday
1
What if I make a mistake? What if I need to make a change? There may technically be a programmatic avenue into this gigantic expression but it's fragile and not apparent on the finished product. It doesn't say what it does, it just is.
– Ryan Reich
yesterday
@RyanReich If you make a mistake, you will not get what you want. However, this is not specific to this matrix. You seem not to like this answer, which is fine. However, I do not really see the purpose of your comments. I believe to have told you why I did what I did. If you have a better solution post it. (And yes, I do now how to typeset a matrix programmatically. Do you want me to post such a solution? The OP has already made her choice...) And yes, the matrix is gigantic.
– marmot
yesterday
@RyanReich In an attempt to remove the tension in our exchange of opinions, I added a version in which you only need to specify the nontrivial entries.
– marmot
yesterday
add a comment |
up vote
9
down vote
up vote
9
down vote
Welcome to TeX.SE! Actually, you do not need TikZ for this.
documentclass{article}
usepackage{amsmath}
begin{document}
[left(begin{array}{|*{5}{ccccc|}}
hline
& & & & & 1 & & & & & & & & & & & & & & & & & & & \
& & & & & 2 & & & & & & & & & & & & & & & & & & & \
& & & & & vdots & & & & & & & & & & & & & & & & & & & \
& & & & & vdots & & & & & & & & & & & & & & & & & & & \
& & & & & widehat{N} & & & & & & & & & & & & & & & & & & & \
hline
& & & & widehat{N} & & & & & & 1 & & & & & & & & & & & & & & \
& & & & vdots & & & & & & 2 & & & & & & & & & & & & & & \
& & & & vdots & & & & & & vdots & & & & & & & & & & & & & & \
& & & & 2 & & & & & & vdots & & & & & & & & & & & & & & \
& & & & 1 & & & & & & widehat{N} & & & & & & & & & & & & & & \
hline
& & & & & & & & & widehat{N} & & & & & & 1 & & & & & & & & & \
& & & & & & & & & vdots & & & & & & 2 & & & & & & & & & \
& & & & & & & & & vdots & & & & & & vdots & & & & & & & & & \
& & & & & & & & & 2 & & & & & & vdots & & & & & & & & & \
& & & & & & & & & 1 & & & & & & widehat{N} & & & & & & & & & \
hline
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
& & & & & & & & & & & & & & & & & & bullet & & & & & & \
& & & & & & & & & & & & & & & bullet & & & & bullet & & & & & \
& & & & & & & & & & & & & & & & bullet & & & & & & & & \
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
hline
& & & & & & & & & & & & & & & & & & & widehat{N} & & & & & \
& & & & & & & & & & & & & & & & & & & vdots & & & & & \
& & & & & & & & & & & & & & & & & & & vdots & & & & & \
& & & & & & & & & & & & & & & & & & & 2 & & & & & \
& & & & & & & & & & & & & & & & & & & 1 & & & & & \
hline
end{array}right)]
end{document}
However, you could use TikZ to improve the appearance.
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{tikzmark}
tikzset{% https://tex.stackexchange.com/a/156990/121799
dots/.style args={#1per #2}{%
line cap=round,
dash pattern=on 0 off #2/#1
}
}
begin{document}
[left(begin{array}{|*{5}{ccccc|}}
hline
& & & & & 1 & & & & & & & & & & & & & & & & & & & \
& & & & & tikzmarknode{21}{2} & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & tikzmarknode{N1}{widehat{N}} & & & & & & & & & & & & & & & & & & & \
hline
& & & & tikzmarknode{N2}{widehat{N}} & & & & & & 1 & & & & & & & & & & & & & & \
& & & & & & & & & & tikzmarknode{23}{2} & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & tikzmarknode{22}{2} & & & & & & & & & & & & & & & & & & & & \
& & & & 1 & & & & & & tikzmarknode{N3}{widehat{N}} & & & & & & & & & & & & & & \
hline
& & & & & & & & & tikzmarknode{N4}{widehat{N}} & & & & & & 1 & & & & & & & & & \
& & & & & & & & & & & & & & & tikzmarknode{25}{2} & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & tikzmarknode{24}{2} & & & & & & & & & & & & & & & \
& & & & & & & & & 1 & & & & & & tikzmarknode{N5}{widehat{N}} & & & & & & & & & \
hline
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
& & & & & & & & & & & & & & & & & & bullet & & & & & & \
& & & & & & & & & & & & & & & bullet & & & & bullet & & & & & \
& & & & & & & & & & & & & & & & bullet & & & & & & & & \
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
hline
& & & & & & & & & & & & & & & & & & & tikzmarknode{N6}{widehat{N}} & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & tikzmarknode{26}{2} & & & & & \
& & & & & & & & & & & & & & & & & & & 1 & & & & & \
hline
end{array}right)]
begin{tikzpicture}[overlay,remember picture]
foreach X in {1,...,6}
{draw[very thick, dots=8 per 1cm,shorten >=3pt,shorten <=3pt] (2X) -- (NX);}
end{tikzpicture}
end{document}
ADDENDUM: In an attempt to make Ryan Reich a bit happy, here is a version in which you only have to specify the nonempty entries of this sparse array. These entries are determined by the list {6/1/1,6/2/2,6/5/widehat{N},... }
, where each entry has the structure <X>/<Y>/<entry>
with X
and Y
specifying the position. Notice that one could shorten this further if you really have only one type of columns, but the point here is to allow to build arbitrary sparse matrices of that type. This code uses this answer.
documentclass{article}
usepackage{tikz}
usetikzlibrary{matrix,calc}
usepackage{etoolbox}
tikzset{% https://tex.stackexchange.com/a/156990/121799
dots/.style args={#1per #2}{%
line cap=round,
dash pattern=on 0 off #2/#1
}
}
begin{document}
edefmylist{6/1/1,6/2/2,6/5/widehat{N},%
5/6/widehat{N},5/9/2,5/10/1,%
11/6/1,11/7/2,11/10/widehat{N},%
10/11/widehat{N},10/12/2,10/15/1,%
16/11/1,16/12/2,16/15/widehat{N},%
20/21/widehat{N},20/22/2,20/25/1%
}
begin{tikzpicture}
letmymatrixcontentempty
foreach Y in {1,...,25}{%
foreach X in {1,...,25}
{xdeftmp{{}}
foreach XX/YY/ZZ in mylist
{ifnumXX=X
ifnumYY=Y
xdeftmp{ZZ}
fi
fi}
ifnumX=25
expandaftergapptoexpandaftermymatrixcontentexpandafter{tmpspace\}%
else
expandaftergapptoexpandaftermymatrixcontentexpandafter{tmpspace&space}%
fi
}
}
matrix [matrix of math nodes,ampersand replacement=&,left delimiter=(,
right delimiter=),draw,row sep=3pt] (mat) {
mymatrixcontent
};
foreach X [evaluate=X as Y using {int(X+1)}]in {5,10,...,20}
{coordinate (aux1) at ($(mat-1-Y.west)!0.5!(mat-1-X.east)$);
coordinate (aux2) at (mat-X-1.south);
draw (mat.north -| aux1) -- (mat.south -| aux1)
(mat.west |- aux2) -- (mat.east |- aux2);}
foreach X/Y [evaluate=Y as Z using {int(Y+3)}] in
{6/2,5/6,11/7,10/12,16/12,20/22}
{draw[very thick, dots=8 per 1cm,shorten >=3pt,shorten <=3pt]
(mat-Y-X) -- (mat-Z-X);}
draw[line width=1.2mm, dots=4 per 1cm]
(mat-16-18.center) -- (mat-18-20.center)
(mat-18-16.center) -- (mat-20-18.center);
end{tikzpicture}
end{document}
Welcome to TeX.SE! Actually, you do not need TikZ for this.
documentclass{article}
usepackage{amsmath}
begin{document}
[left(begin{array}{|*{5}{ccccc|}}
hline
& & & & & 1 & & & & & & & & & & & & & & & & & & & \
& & & & & 2 & & & & & & & & & & & & & & & & & & & \
& & & & & vdots & & & & & & & & & & & & & & & & & & & \
& & & & & vdots & & & & & & & & & & & & & & & & & & & \
& & & & & widehat{N} & & & & & & & & & & & & & & & & & & & \
hline
& & & & widehat{N} & & & & & & 1 & & & & & & & & & & & & & & \
& & & & vdots & & & & & & 2 & & & & & & & & & & & & & & \
& & & & vdots & & & & & & vdots & & & & & & & & & & & & & & \
& & & & 2 & & & & & & vdots & & & & & & & & & & & & & & \
& & & & 1 & & & & & & widehat{N} & & & & & & & & & & & & & & \
hline
& & & & & & & & & widehat{N} & & & & & & 1 & & & & & & & & & \
& & & & & & & & & vdots & & & & & & 2 & & & & & & & & & \
& & & & & & & & & vdots & & & & & & vdots & & & & & & & & & \
& & & & & & & & & 2 & & & & & & vdots & & & & & & & & & \
& & & & & & & & & 1 & & & & & & widehat{N} & & & & & & & & & \
hline
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
& & & & & & & & & & & & & & & & & & bullet & & & & & & \
& & & & & & & & & & & & & & & bullet & & & & bullet & & & & & \
& & & & & & & & & & & & & & & & bullet & & & & & & & & \
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
hline
& & & & & & & & & & & & & & & & & & & widehat{N} & & & & & \
& & & & & & & & & & & & & & & & & & & vdots & & & & & \
& & & & & & & & & & & & & & & & & & & vdots & & & & & \
& & & & & & & & & & & & & & & & & & & 2 & & & & & \
& & & & & & & & & & & & & & & & & & & 1 & & & & & \
hline
end{array}right)]
end{document}
However, you could use TikZ to improve the appearance.
documentclass{article}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{tikzmark}
tikzset{% https://tex.stackexchange.com/a/156990/121799
dots/.style args={#1per #2}{%
line cap=round,
dash pattern=on 0 off #2/#1
}
}
begin{document}
[left(begin{array}{|*{5}{ccccc|}}
hline
& & & & & 1 & & & & & & & & & & & & & & & & & & & \
& & & & & tikzmarknode{21}{2} & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & tikzmarknode{N1}{widehat{N}} & & & & & & & & & & & & & & & & & & & \
hline
& & & & tikzmarknode{N2}{widehat{N}} & & & & & & 1 & & & & & & & & & & & & & & \
& & & & & & & & & & tikzmarknode{23}{2} & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & tikzmarknode{22}{2} & & & & & & & & & & & & & & & & & & & & \
& & & & 1 & & & & & & tikzmarknode{N3}{widehat{N}} & & & & & & & & & & & & & & \
hline
& & & & & & & & & tikzmarknode{N4}{widehat{N}} & & & & & & 1 & & & & & & & & & \
& & & & & & & & & & & & & & & tikzmarknode{25}{2} & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & tikzmarknode{24}{2} & & & & & & & & & & & & & & & \
& & & & & & & & & 1 & & & & & & tikzmarknode{N5}{widehat{N}} & & & & & & & & & \
hline
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
& & & & & & & & & & & & & & & & & & bullet & & & & & & \
& & & & & & & & & & & & & & & bullet & & & & bullet & & & & & \
& & & & & & & & & & & & & & & & bullet & & & & & & & & \
& & & & & & & & & & & & & & & & & bullet & & & & & & & \
hline
& & & & & & & & & & & & & & & & & & & tikzmarknode{N6}{widehat{N}} & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & & & & & & \
& & & & & & & & & & & & & & & & & & & tikzmarknode{26}{2} & & & & & \
& & & & & & & & & & & & & & & & & & & 1 & & & & & \
hline
end{array}right)]
begin{tikzpicture}[overlay,remember picture]
foreach X in {1,...,6}
{draw[very thick, dots=8 per 1cm,shorten >=3pt,shorten <=3pt] (2X) -- (NX);}
end{tikzpicture}
end{document}
ADDENDUM: In an attempt to make Ryan Reich a bit happy, here is a version in which you only have to specify the nonempty entries of this sparse array. These entries are determined by the list {6/1/1,6/2/2,6/5/widehat{N},... }
, where each entry has the structure <X>/<Y>/<entry>
with X
and Y
specifying the position. Notice that one could shorten this further if you really have only one type of columns, but the point here is to allow to build arbitrary sparse matrices of that type. This code uses this answer.
documentclass{article}
usepackage{tikz}
usetikzlibrary{matrix,calc}
usepackage{etoolbox}
tikzset{% https://tex.stackexchange.com/a/156990/121799
dots/.style args={#1per #2}{%
line cap=round,
dash pattern=on 0 off #2/#1
}
}
begin{document}
edefmylist{6/1/1,6/2/2,6/5/widehat{N},%
5/6/widehat{N},5/9/2,5/10/1,%
11/6/1,11/7/2,11/10/widehat{N},%
10/11/widehat{N},10/12/2,10/15/1,%
16/11/1,16/12/2,16/15/widehat{N},%
20/21/widehat{N},20/22/2,20/25/1%
}
begin{tikzpicture}
letmymatrixcontentempty
foreach Y in {1,...,25}{%
foreach X in {1,...,25}
{xdeftmp{{}}
foreach XX/YY/ZZ in mylist
{ifnumXX=X
ifnumYY=Y
xdeftmp{ZZ}
fi
fi}
ifnumX=25
expandaftergapptoexpandaftermymatrixcontentexpandafter{tmpspace\}%
else
expandaftergapptoexpandaftermymatrixcontentexpandafter{tmpspace&space}%
fi
}
}
matrix [matrix of math nodes,ampersand replacement=&,left delimiter=(,
right delimiter=),draw,row sep=3pt] (mat) {
mymatrixcontent
};
foreach X [evaluate=X as Y using {int(X+1)}]in {5,10,...,20}
{coordinate (aux1) at ($(mat-1-Y.west)!0.5!(mat-1-X.east)$);
coordinate (aux2) at (mat-X-1.south);
draw (mat.north -| aux1) -- (mat.south -| aux1)
(mat.west |- aux2) -- (mat.east |- aux2);}
foreach X/Y [evaluate=Y as Z using {int(Y+3)}] in
{6/2,5/6,11/7,10/12,16/12,20/22}
{draw[very thick, dots=8 per 1cm,shorten >=3pt,shorten <=3pt]
(mat-Y-X) -- (mat-Z-X);}
draw[line width=1.2mm, dots=4 per 1cm]
(mat-16-18.center) -- (mat-18-20.center)
(mat-18-16.center) -- (mat-20-18.center);
end{tikzpicture}
end{document}
edited yesterday
answered yesterday
marmot
76.4k486160
76.4k486160
I don't want to be a jerk, but filling a page with ampersands that require careful counting is not a very helpful answer.
– Ryan Reich
yesterday
@RyanReich Are you really typing them one by one? If so, then I agree. But of course if you just do copy and paste, then it is not that cumbersome. Well, and if you like phantoms better (and make sure that none of the entries exceeds the size of those), I'd say this is a matter of taste, but otherwise it is a bit nontrivial to bet things aligned across different blocks. So that is just to say that I definitely did not have to count here.
– marmot
yesterday
1
What if I make a mistake? What if I need to make a change? There may technically be a programmatic avenue into this gigantic expression but it's fragile and not apparent on the finished product. It doesn't say what it does, it just is.
– Ryan Reich
yesterday
@RyanReich If you make a mistake, you will not get what you want. However, this is not specific to this matrix. You seem not to like this answer, which is fine. However, I do not really see the purpose of your comments. I believe to have told you why I did what I did. If you have a better solution post it. (And yes, I do now how to typeset a matrix programmatically. Do you want me to post such a solution? The OP has already made her choice...) And yes, the matrix is gigantic.
– marmot
yesterday
@RyanReich In an attempt to remove the tension in our exchange of opinions, I added a version in which you only need to specify the nontrivial entries.
– marmot
yesterday
add a comment |
I don't want to be a jerk, but filling a page with ampersands that require careful counting is not a very helpful answer.
– Ryan Reich
yesterday
@RyanReich Are you really typing them one by one? If so, then I agree. But of course if you just do copy and paste, then it is not that cumbersome. Well, and if you like phantoms better (and make sure that none of the entries exceeds the size of those), I'd say this is a matter of taste, but otherwise it is a bit nontrivial to bet things aligned across different blocks. So that is just to say that I definitely did not have to count here.
– marmot
yesterday
1
What if I make a mistake? What if I need to make a change? There may technically be a programmatic avenue into this gigantic expression but it's fragile and not apparent on the finished product. It doesn't say what it does, it just is.
– Ryan Reich
yesterday
@RyanReich If you make a mistake, you will not get what you want. However, this is not specific to this matrix. You seem not to like this answer, which is fine. However, I do not really see the purpose of your comments. I believe to have told you why I did what I did. If you have a better solution post it. (And yes, I do now how to typeset a matrix programmatically. Do you want me to post such a solution? The OP has already made her choice...) And yes, the matrix is gigantic.
– marmot
yesterday
@RyanReich In an attempt to remove the tension in our exchange of opinions, I added a version in which you only need to specify the nontrivial entries.
– marmot
yesterday
I don't want to be a jerk, but filling a page with ampersands that require careful counting is not a very helpful answer.
– Ryan Reich
yesterday
I don't want to be a jerk, but filling a page with ampersands that require careful counting is not a very helpful answer.
– Ryan Reich
yesterday
@RyanReich Are you really typing them one by one? If so, then I agree. But of course if you just do copy and paste, then it is not that cumbersome. Well, and if you like phantoms better (and make sure that none of the entries exceeds the size of those), I'd say this is a matter of taste, but otherwise it is a bit nontrivial to bet things aligned across different blocks. So that is just to say that I definitely did not have to count here.
– marmot
yesterday
@RyanReich Are you really typing them one by one? If so, then I agree. But of course if you just do copy and paste, then it is not that cumbersome. Well, and if you like phantoms better (and make sure that none of the entries exceeds the size of those), I'd say this is a matter of taste, but otherwise it is a bit nontrivial to bet things aligned across different blocks. So that is just to say that I definitely did not have to count here.
– marmot
yesterday
1
1
What if I make a mistake? What if I need to make a change? There may technically be a programmatic avenue into this gigantic expression but it's fragile and not apparent on the finished product. It doesn't say what it does, it just is.
– Ryan Reich
yesterday
What if I make a mistake? What if I need to make a change? There may technically be a programmatic avenue into this gigantic expression but it's fragile and not apparent on the finished product. It doesn't say what it does, it just is.
– Ryan Reich
yesterday
@RyanReich If you make a mistake, you will not get what you want. However, this is not specific to this matrix. You seem not to like this answer, which is fine. However, I do not really see the purpose of your comments. I believe to have told you why I did what I did. If you have a better solution post it. (And yes, I do now how to typeset a matrix programmatically. Do you want me to post such a solution? The OP has already made her choice...) And yes, the matrix is gigantic.
– marmot
yesterday
@RyanReich If you make a mistake, you will not get what you want. However, this is not specific to this matrix. You seem not to like this answer, which is fine. However, I do not really see the purpose of your comments. I believe to have told you why I did what I did. If you have a better solution post it. (And yes, I do now how to typeset a matrix programmatically. Do you want me to post such a solution? The OP has already made her choice...) And yes, the matrix is gigantic.
– marmot
yesterday
@RyanReich In an attempt to remove the tension in our exchange of opinions, I added a version in which you only need to specify the nontrivial entries.
– marmot
yesterday
@RyanReich In an attempt to remove the tension in our exchange of opinions, I added a version in which you only need to specify the nontrivial entries.
– marmot
yesterday
add a comment |
Sherry is a new contributor. Be nice, and check out our Code of Conduct.
Sherry is a new contributor. Be nice, and check out our Code of Conduct.
Sherry is a new contributor. Be nice, and check out our Code of Conduct.
Sherry is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f460659%2fhow-do-i-draw-the-following-matrix-in-latex%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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