How to write the block matrix in LaTex? [duplicate]
This question already has an answer here:
Highlight elements in the matrix
11 answers
I wish to write the following block matrix in LaTex.
I have been trying a bunch of stuff, but none of it seems to work. In particular, I tried the following:
begin{bmatrix}
0 & -1& & & & & 0 & & & &\
1 & 0 & & & & & & & & &\
& & cdot & & & & & & & &\
& & & cdot & & & & & & &\
& & & & cdot & & & & & &\
& & & & & 0 & 1 & & & &\
& & & & &-1 & 0 & & & &\
& & & & & & & cdot & & &\
& & & & & & & & cdot & & \
& & & & & & & & & cdot & \
0 & & & & & & & & & & 0\
end{bmatrix}
But this is pretty ugly and so any suggestions will be much appreciated.
amsmath
marked as duplicate by Werner, Raaja, Kurt, Sebastiano, siracusa 2 days ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Highlight elements in the matrix
11 answers
I wish to write the following block matrix in LaTex.
I have been trying a bunch of stuff, but none of it seems to work. In particular, I tried the following:
begin{bmatrix}
0 & -1& & & & & 0 & & & &\
1 & 0 & & & & & & & & &\
& & cdot & & & & & & & &\
& & & cdot & & & & & & &\
& & & & cdot & & & & & &\
& & & & & 0 & 1 & & & &\
& & & & &-1 & 0 & & & &\
& & & & & & & cdot & & &\
& & & & & & & & cdot & & \
& & & & & & & & & cdot & \
0 & & & & & & & & & & 0\
end{bmatrix}
But this is pretty ugly and so any suggestions will be much appreciated.
amsmath
marked as duplicate by Werner, Raaja, Kurt, Sebastiano, siracusa 2 days ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Highlight elements in the matrix
11 answers
I wish to write the following block matrix in LaTex.
I have been trying a bunch of stuff, but none of it seems to work. In particular, I tried the following:
begin{bmatrix}
0 & -1& & & & & 0 & & & &\
1 & 0 & & & & & & & & &\
& & cdot & & & & & & & &\
& & & cdot & & & & & & &\
& & & & cdot & & & & & &\
& & & & & 0 & 1 & & & &\
& & & & &-1 & 0 & & & &\
& & & & & & & cdot & & &\
& & & & & & & & cdot & & \
& & & & & & & & & cdot & \
0 & & & & & & & & & & 0\
end{bmatrix}
But this is pretty ugly and so any suggestions will be much appreciated.
amsmath
This question already has an answer here:
Highlight elements in the matrix
11 answers
I wish to write the following block matrix in LaTex.
I have been trying a bunch of stuff, but none of it seems to work. In particular, I tried the following:
begin{bmatrix}
0 & -1& & & & & 0 & & & &\
1 & 0 & & & & & & & & &\
& & cdot & & & & & & & &\
& & & cdot & & & & & & &\
& & & & cdot & & & & & &\
& & & & & 0 & 1 & & & &\
& & & & &-1 & 0 & & & &\
& & & & & & & cdot & & &\
& & & & & & & & cdot & & \
& & & & & & & & & cdot & \
0 & & & & & & & & & & 0\
end{bmatrix}
But this is pretty ugly and so any suggestions will be much appreciated.
This question already has an answer here:
Highlight elements in the matrix
11 answers
amsmath
amsmath
edited Mar 28 at 20:33
model_checker
asked Mar 28 at 20:19
model_checkermodel_checker
2551310
2551310
marked as duplicate by Werner, Raaja, Kurt, Sebastiano, siracusa 2 days ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Werner, Raaja, Kurt, Sebastiano, siracusa 2 days ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
5 Answers
5
active
oldest
votes
Perhaps
$left(begin{array}{cccccc}
left[begin{array}{cc}
0 & 1\
-1 & 0
end{array}right] & & & & & 0\
& ddots\
& & left[begin{array}{cc}
0 & 1\
-1 & 0
end{array}right]\
& & & 0\
& & & & ddots\
0 & & & & & 0
end{array}right)$
2
Thank you so much!
– model_checker
Mar 28 at 20:45
add a comment |
Just for the fun of it! :-)
documentclass{article}
usepackage{amsmath,array}
begin{document}
[
begin{pmatrix}
newcommand{lr}[1]{multicolumn{1}{|c}{#1}}
newcommand{rr}[1]{multicolumn{1}{c|}{#1}}
;
begin{array}{@{}*{10}{c}@{}}
cline{1-2}
lr{0} & rr{1} &&&&&&&& raisebox{-1em}[0pt][0pt]{$0$}\
lr{-1} & rr{0} \
cline{1-2}
&& ddots \
cline{4-5}
&&& lr{0} & rr{1} \
&&& lr{-1} & rr{0} \
cline{4-5}
&&&&& 0 \[-1ex]
&&&&&& ddots \
&&&&&&& 0 \[-1ex]
&&&&&&&& ddots \
multicolumn{2}{c}{0} &&&&&&&& 0
end{array}
;;
end{pmatrix}
]
end{document}
2
You guys are the best!
– model_checker
Mar 28 at 22:40
1
@model_checker I'm certainly not the best. Here is world excellence.
– Sebastiano
Mar 28 at 22:50
2
I am sorry! Last I checked there was an objection to your answer. But it's also great!
– model_checker
Mar 28 at 22:53
2
@model_checker Don't worry. I have put two&
in addition. :-) but now it is correct.
– Sebastiano
Mar 28 at 23:02
add a comment |
Here there is my proposal as the original picture using bmatx
command that replace a boxed matrix.
documentclass{article}
usepackage{mathtools}
newcommand{bmatx}{boxed{begin{matrix} 0& 1 \ -1& 0end{matrix}}}
begin{document}
[
begin{pmatrix}
, bmatx& & & & & & & 0 \
& ddots& & & & \
& & bmatx & & & & \
& & & ddots& & &\
& & & & 0 & &\
& & & & & & ddots\
0 & & & & & & & 0
end{pmatrix}
]
end{document}
The best code is provided thanks to the precious comment of @Bernard.
4
In my opinion, you shouldn't add an empty 3rd column in the definition ofbmatx
– Bernard
Mar 28 at 21:24
2
Your comment not is an opinion :-) ...it is truly correct. :-)
– Sebastiano
Mar 28 at 21:30
add a comment |
Here's another solution. It uses a pmatrix
environment for the overall matrix and a custom macro called blockmat
for the 2x2 inner matrices.
documentclass{article}
usepackage{array,amsmath}
newcommandblockmat{%
begin{array}{|@{,}rr@{,}|}
hline 0 & 1^{mathstrut} \ -1 & 0 \ hline
end{array}}
begin{document}
[
begin{pmatrix}
blockmat & & & & & 0 \
& ddots & & & & \
& & blockmat & & & \
& & & 0 & & \
& & & & ddots & \
0 & & & & & 0 \
end{pmatrix}
]
end{document}
1
Thank you for writing this answer!
– model_checker
Mar 28 at 22:03
add a comment |
Here's a solution using TikZ that will work in all kinds of context, not just matrices, to draw boxes. You just need to put tl
in the point where the top-right corner is supposed to be and br
where the bottom-right will be. You can also use any TikZ feature to modify your box. Obviously this needs to be fine tuned depending on what exactly you're using it for (spacing etc.).
newcounter{textbox}
deftl{stepcounter{textbox}tikzmarknode{athetextbox}{strut}}
defbr{tikzmarknode{bthetextbox}{strut}begin{tikzpicture}[overlay, remember picture]draw (athetextbox.north west) rectangle (bthetextbox.south east);end{tikzpicture}}
The spacing in this version is not optimized for matrices, but you can use
tikzmarknode{bthetextbox}{strut}begin{tikzpicture}[overlay, remember picture]draw ($(athetextbox.north west)+(-0.4arraycolsep,0ex)$) rectangle ($(bthetextbox.south east)+(0.4arraycolsep,0ex)$);end{tikzpicture}
to add extra space.
Full code:
documentclass{article}
usepackage{tikz}
usepackage{amsmath}
usetikzlibrary{tikzmark,calc}
newcounter{textbox}
deftl{stepcounter{textbox}tikzmarknode{athetextbox}{strut}}
defbr{tikzmarknode{bthetextbox}{strut}begin{tikzpicture}[overlay, remember picture]draw (athetextbox.north west) rectangle (bthetextbox.south east);end{tikzpicture}}
begin{document}
[
begin{bmatrix}
tl0 &-1 & & & & & & & & 0 \
1 & 0br & & & & & & & & \
& & cdot & & & & & & & \
& & & cdot & & & & & & \
& & & & cdot & & & & & \
& & & & &tl0 & 1 & & & \
& & & & &-1 & 0br & & & \
& & & & & & & cdot & & \
& & & & & & & & cdot & \
0 & & & & & & & & & cdot \
end{bmatrix}
]
end{document}
add a comment |
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
Perhaps
$left(begin{array}{cccccc}
left[begin{array}{cc}
0 & 1\
-1 & 0
end{array}right] & & & & & 0\
& ddots\
& & left[begin{array}{cc}
0 & 1\
-1 & 0
end{array}right]\
& & & 0\
& & & & ddots\
0 & & & & & 0
end{array}right)$
2
Thank you so much!
– model_checker
Mar 28 at 20:45
add a comment |
Perhaps
$left(begin{array}{cccccc}
left[begin{array}{cc}
0 & 1\
-1 & 0
end{array}right] & & & & & 0\
& ddots\
& & left[begin{array}{cc}
0 & 1\
-1 & 0
end{array}right]\
& & & 0\
& & & & ddots\
0 & & & & & 0
end{array}right)$
2
Thank you so much!
– model_checker
Mar 28 at 20:45
add a comment |
Perhaps
$left(begin{array}{cccccc}
left[begin{array}{cc}
0 & 1\
-1 & 0
end{array}right] & & & & & 0\
& ddots\
& & left[begin{array}{cc}
0 & 1\
-1 & 0
end{array}right]\
& & & 0\
& & & & ddots\
0 & & & & & 0
end{array}right)$
Perhaps
$left(begin{array}{cccccc}
left[begin{array}{cc}
0 & 1\
-1 & 0
end{array}right] & & & & & 0\
& ddots\
& & left[begin{array}{cc}
0 & 1\
-1 & 0
end{array}right]\
& & & 0\
& & & & ddots\
0 & & & & & 0
end{array}right)$
answered Mar 28 at 20:42
riccs_0xriccs_0x
21015
21015
2
Thank you so much!
– model_checker
Mar 28 at 20:45
add a comment |
2
Thank you so much!
– model_checker
Mar 28 at 20:45
2
2
Thank you so much!
– model_checker
Mar 28 at 20:45
Thank you so much!
– model_checker
Mar 28 at 20:45
add a comment |
Just for the fun of it! :-)
documentclass{article}
usepackage{amsmath,array}
begin{document}
[
begin{pmatrix}
newcommand{lr}[1]{multicolumn{1}{|c}{#1}}
newcommand{rr}[1]{multicolumn{1}{c|}{#1}}
;
begin{array}{@{}*{10}{c}@{}}
cline{1-2}
lr{0} & rr{1} &&&&&&&& raisebox{-1em}[0pt][0pt]{$0$}\
lr{-1} & rr{0} \
cline{1-2}
&& ddots \
cline{4-5}
&&& lr{0} & rr{1} \
&&& lr{-1} & rr{0} \
cline{4-5}
&&&&& 0 \[-1ex]
&&&&&& ddots \
&&&&&&& 0 \[-1ex]
&&&&&&&& ddots \
multicolumn{2}{c}{0} &&&&&&&& 0
end{array}
;;
end{pmatrix}
]
end{document}
2
You guys are the best!
– model_checker
Mar 28 at 22:40
1
@model_checker I'm certainly not the best. Here is world excellence.
– Sebastiano
Mar 28 at 22:50
2
I am sorry! Last I checked there was an objection to your answer. But it's also great!
– model_checker
Mar 28 at 22:53
2
@model_checker Don't worry. I have put two&
in addition. :-) but now it is correct.
– Sebastiano
Mar 28 at 23:02
add a comment |
Just for the fun of it! :-)
documentclass{article}
usepackage{amsmath,array}
begin{document}
[
begin{pmatrix}
newcommand{lr}[1]{multicolumn{1}{|c}{#1}}
newcommand{rr}[1]{multicolumn{1}{c|}{#1}}
;
begin{array}{@{}*{10}{c}@{}}
cline{1-2}
lr{0} & rr{1} &&&&&&&& raisebox{-1em}[0pt][0pt]{$0$}\
lr{-1} & rr{0} \
cline{1-2}
&& ddots \
cline{4-5}
&&& lr{0} & rr{1} \
&&& lr{-1} & rr{0} \
cline{4-5}
&&&&& 0 \[-1ex]
&&&&&& ddots \
&&&&&&& 0 \[-1ex]
&&&&&&&& ddots \
multicolumn{2}{c}{0} &&&&&&&& 0
end{array}
;;
end{pmatrix}
]
end{document}
2
You guys are the best!
– model_checker
Mar 28 at 22:40
1
@model_checker I'm certainly not the best. Here is world excellence.
– Sebastiano
Mar 28 at 22:50
2
I am sorry! Last I checked there was an objection to your answer. But it's also great!
– model_checker
Mar 28 at 22:53
2
@model_checker Don't worry. I have put two&
in addition. :-) but now it is correct.
– Sebastiano
Mar 28 at 23:02
add a comment |
Just for the fun of it! :-)
documentclass{article}
usepackage{amsmath,array}
begin{document}
[
begin{pmatrix}
newcommand{lr}[1]{multicolumn{1}{|c}{#1}}
newcommand{rr}[1]{multicolumn{1}{c|}{#1}}
;
begin{array}{@{}*{10}{c}@{}}
cline{1-2}
lr{0} & rr{1} &&&&&&&& raisebox{-1em}[0pt][0pt]{$0$}\
lr{-1} & rr{0} \
cline{1-2}
&& ddots \
cline{4-5}
&&& lr{0} & rr{1} \
&&& lr{-1} & rr{0} \
cline{4-5}
&&&&& 0 \[-1ex]
&&&&&& ddots \
&&&&&&& 0 \[-1ex]
&&&&&&&& ddots \
multicolumn{2}{c}{0} &&&&&&&& 0
end{array}
;;
end{pmatrix}
]
end{document}
Just for the fun of it! :-)
documentclass{article}
usepackage{amsmath,array}
begin{document}
[
begin{pmatrix}
newcommand{lr}[1]{multicolumn{1}{|c}{#1}}
newcommand{rr}[1]{multicolumn{1}{c|}{#1}}
;
begin{array}{@{}*{10}{c}@{}}
cline{1-2}
lr{0} & rr{1} &&&&&&&& raisebox{-1em}[0pt][0pt]{$0$}\
lr{-1} & rr{0} \
cline{1-2}
&& ddots \
cline{4-5}
&&& lr{0} & rr{1} \
&&& lr{-1} & rr{0} \
cline{4-5}
&&&&& 0 \[-1ex]
&&&&&& ddots \
&&&&&&& 0 \[-1ex]
&&&&&&&& ddots \
multicolumn{2}{c}{0} &&&&&&&& 0
end{array}
;;
end{pmatrix}
]
end{document}
answered Mar 28 at 22:27
egregegreg
731k8919303250
731k8919303250
2
You guys are the best!
– model_checker
Mar 28 at 22:40
1
@model_checker I'm certainly not the best. Here is world excellence.
– Sebastiano
Mar 28 at 22:50
2
I am sorry! Last I checked there was an objection to your answer. But it's also great!
– model_checker
Mar 28 at 22:53
2
@model_checker Don't worry. I have put two&
in addition. :-) but now it is correct.
– Sebastiano
Mar 28 at 23:02
add a comment |
2
You guys are the best!
– model_checker
Mar 28 at 22:40
1
@model_checker I'm certainly not the best. Here is world excellence.
– Sebastiano
Mar 28 at 22:50
2
I am sorry! Last I checked there was an objection to your answer. But it's also great!
– model_checker
Mar 28 at 22:53
2
@model_checker Don't worry. I have put two&
in addition. :-) but now it is correct.
– Sebastiano
Mar 28 at 23:02
2
2
You guys are the best!
– model_checker
Mar 28 at 22:40
You guys are the best!
– model_checker
Mar 28 at 22:40
1
1
@model_checker I'm certainly not the best. Here is world excellence.
– Sebastiano
Mar 28 at 22:50
@model_checker I'm certainly not the best. Here is world excellence.
– Sebastiano
Mar 28 at 22:50
2
2
I am sorry! Last I checked there was an objection to your answer. But it's also great!
– model_checker
Mar 28 at 22:53
I am sorry! Last I checked there was an objection to your answer. But it's also great!
– model_checker
Mar 28 at 22:53
2
2
@model_checker Don't worry. I have put two
&
in addition. :-) but now it is correct.– Sebastiano
Mar 28 at 23:02
@model_checker Don't worry. I have put two
&
in addition. :-) but now it is correct.– Sebastiano
Mar 28 at 23:02
add a comment |
Here there is my proposal as the original picture using bmatx
command that replace a boxed matrix.
documentclass{article}
usepackage{mathtools}
newcommand{bmatx}{boxed{begin{matrix} 0& 1 \ -1& 0end{matrix}}}
begin{document}
[
begin{pmatrix}
, bmatx& & & & & & & 0 \
& ddots& & & & \
& & bmatx & & & & \
& & & ddots& & &\
& & & & 0 & &\
& & & & & & ddots\
0 & & & & & & & 0
end{pmatrix}
]
end{document}
The best code is provided thanks to the precious comment of @Bernard.
4
In my opinion, you shouldn't add an empty 3rd column in the definition ofbmatx
– Bernard
Mar 28 at 21:24
2
Your comment not is an opinion :-) ...it is truly correct. :-)
– Sebastiano
Mar 28 at 21:30
add a comment |
Here there is my proposal as the original picture using bmatx
command that replace a boxed matrix.
documentclass{article}
usepackage{mathtools}
newcommand{bmatx}{boxed{begin{matrix} 0& 1 \ -1& 0end{matrix}}}
begin{document}
[
begin{pmatrix}
, bmatx& & & & & & & 0 \
& ddots& & & & \
& & bmatx & & & & \
& & & ddots& & &\
& & & & 0 & &\
& & & & & & ddots\
0 & & & & & & & 0
end{pmatrix}
]
end{document}
The best code is provided thanks to the precious comment of @Bernard.
4
In my opinion, you shouldn't add an empty 3rd column in the definition ofbmatx
– Bernard
Mar 28 at 21:24
2
Your comment not is an opinion :-) ...it is truly correct. :-)
– Sebastiano
Mar 28 at 21:30
add a comment |
Here there is my proposal as the original picture using bmatx
command that replace a boxed matrix.
documentclass{article}
usepackage{mathtools}
newcommand{bmatx}{boxed{begin{matrix} 0& 1 \ -1& 0end{matrix}}}
begin{document}
[
begin{pmatrix}
, bmatx& & & & & & & 0 \
& ddots& & & & \
& & bmatx & & & & \
& & & ddots& & &\
& & & & 0 & &\
& & & & & & ddots\
0 & & & & & & & 0
end{pmatrix}
]
end{document}
The best code is provided thanks to the precious comment of @Bernard.
Here there is my proposal as the original picture using bmatx
command that replace a boxed matrix.
documentclass{article}
usepackage{mathtools}
newcommand{bmatx}{boxed{begin{matrix} 0& 1 \ -1& 0end{matrix}}}
begin{document}
[
begin{pmatrix}
, bmatx& & & & & & & 0 \
& ddots& & & & \
& & bmatx & & & & \
& & & ddots& & &\
& & & & 0 & &\
& & & & & & ddots\
0 & & & & & & & 0
end{pmatrix}
]
end{document}
The best code is provided thanks to the precious comment of @Bernard.
edited Mar 28 at 21:30
answered Mar 28 at 20:56
SebastianoSebastiano
11.5k42164
11.5k42164
4
In my opinion, you shouldn't add an empty 3rd column in the definition ofbmatx
– Bernard
Mar 28 at 21:24
2
Your comment not is an opinion :-) ...it is truly correct. :-)
– Sebastiano
Mar 28 at 21:30
add a comment |
4
In my opinion, you shouldn't add an empty 3rd column in the definition ofbmatx
– Bernard
Mar 28 at 21:24
2
Your comment not is an opinion :-) ...it is truly correct. :-)
– Sebastiano
Mar 28 at 21:30
4
4
In my opinion, you shouldn't add an empty 3rd column in the definition of
bmatx
– Bernard
Mar 28 at 21:24
In my opinion, you shouldn't add an empty 3rd column in the definition of
bmatx
– Bernard
Mar 28 at 21:24
2
2
Your comment not is an opinion :-) ...it is truly correct. :-)
– Sebastiano
Mar 28 at 21:30
Your comment not is an opinion :-) ...it is truly correct. :-)
– Sebastiano
Mar 28 at 21:30
add a comment |
Here's another solution. It uses a pmatrix
environment for the overall matrix and a custom macro called blockmat
for the 2x2 inner matrices.
documentclass{article}
usepackage{array,amsmath}
newcommandblockmat{%
begin{array}{|@{,}rr@{,}|}
hline 0 & 1^{mathstrut} \ -1 & 0 \ hline
end{array}}
begin{document}
[
begin{pmatrix}
blockmat & & & & & 0 \
& ddots & & & & \
& & blockmat & & & \
& & & 0 & & \
& & & & ddots & \
0 & & & & & 0 \
end{pmatrix}
]
end{document}
1
Thank you for writing this answer!
– model_checker
Mar 28 at 22:03
add a comment |
Here's another solution. It uses a pmatrix
environment for the overall matrix and a custom macro called blockmat
for the 2x2 inner matrices.
documentclass{article}
usepackage{array,amsmath}
newcommandblockmat{%
begin{array}{|@{,}rr@{,}|}
hline 0 & 1^{mathstrut} \ -1 & 0 \ hline
end{array}}
begin{document}
[
begin{pmatrix}
blockmat & & & & & 0 \
& ddots & & & & \
& & blockmat & & & \
& & & 0 & & \
& & & & ddots & \
0 & & & & & 0 \
end{pmatrix}
]
end{document}
1
Thank you for writing this answer!
– model_checker
Mar 28 at 22:03
add a comment |
Here's another solution. It uses a pmatrix
environment for the overall matrix and a custom macro called blockmat
for the 2x2 inner matrices.
documentclass{article}
usepackage{array,amsmath}
newcommandblockmat{%
begin{array}{|@{,}rr@{,}|}
hline 0 & 1^{mathstrut} \ -1 & 0 \ hline
end{array}}
begin{document}
[
begin{pmatrix}
blockmat & & & & & 0 \
& ddots & & & & \
& & blockmat & & & \
& & & 0 & & \
& & & & ddots & \
0 & & & & & 0 \
end{pmatrix}
]
end{document}
Here's another solution. It uses a pmatrix
environment for the overall matrix and a custom macro called blockmat
for the 2x2 inner matrices.
documentclass{article}
usepackage{array,amsmath}
newcommandblockmat{%
begin{array}{|@{,}rr@{,}|}
hline 0 & 1^{mathstrut} \ -1 & 0 \ hline
end{array}}
begin{document}
[
begin{pmatrix}
blockmat & & & & & 0 \
& ddots & & & & \
& & blockmat & & & \
& & & 0 & & \
& & & & ddots & \
0 & & & & & 0 \
end{pmatrix}
]
end{document}
edited Mar 28 at 20:57
samcarter
93.5k7105303
93.5k7105303
answered Mar 28 at 20:55
MicoMico
285k31388778
285k31388778
1
Thank you for writing this answer!
– model_checker
Mar 28 at 22:03
add a comment |
1
Thank you for writing this answer!
– model_checker
Mar 28 at 22:03
1
1
Thank you for writing this answer!
– model_checker
Mar 28 at 22:03
Thank you for writing this answer!
– model_checker
Mar 28 at 22:03
add a comment |
Here's a solution using TikZ that will work in all kinds of context, not just matrices, to draw boxes. You just need to put tl
in the point where the top-right corner is supposed to be and br
where the bottom-right will be. You can also use any TikZ feature to modify your box. Obviously this needs to be fine tuned depending on what exactly you're using it for (spacing etc.).
newcounter{textbox}
deftl{stepcounter{textbox}tikzmarknode{athetextbox}{strut}}
defbr{tikzmarknode{bthetextbox}{strut}begin{tikzpicture}[overlay, remember picture]draw (athetextbox.north west) rectangle (bthetextbox.south east);end{tikzpicture}}
The spacing in this version is not optimized for matrices, but you can use
tikzmarknode{bthetextbox}{strut}begin{tikzpicture}[overlay, remember picture]draw ($(athetextbox.north west)+(-0.4arraycolsep,0ex)$) rectangle ($(bthetextbox.south east)+(0.4arraycolsep,0ex)$);end{tikzpicture}
to add extra space.
Full code:
documentclass{article}
usepackage{tikz}
usepackage{amsmath}
usetikzlibrary{tikzmark,calc}
newcounter{textbox}
deftl{stepcounter{textbox}tikzmarknode{athetextbox}{strut}}
defbr{tikzmarknode{bthetextbox}{strut}begin{tikzpicture}[overlay, remember picture]draw (athetextbox.north west) rectangle (bthetextbox.south east);end{tikzpicture}}
begin{document}
[
begin{bmatrix}
tl0 &-1 & & & & & & & & 0 \
1 & 0br & & & & & & & & \
& & cdot & & & & & & & \
& & & cdot & & & & & & \
& & & & cdot & & & & & \
& & & & &tl0 & 1 & & & \
& & & & &-1 & 0br & & & \
& & & & & & & cdot & & \
& & & & & & & & cdot & \
0 & & & & & & & & & cdot \
end{bmatrix}
]
end{document}
add a comment |
Here's a solution using TikZ that will work in all kinds of context, not just matrices, to draw boxes. You just need to put tl
in the point where the top-right corner is supposed to be and br
where the bottom-right will be. You can also use any TikZ feature to modify your box. Obviously this needs to be fine tuned depending on what exactly you're using it for (spacing etc.).
newcounter{textbox}
deftl{stepcounter{textbox}tikzmarknode{athetextbox}{strut}}
defbr{tikzmarknode{bthetextbox}{strut}begin{tikzpicture}[overlay, remember picture]draw (athetextbox.north west) rectangle (bthetextbox.south east);end{tikzpicture}}
The spacing in this version is not optimized for matrices, but you can use
tikzmarknode{bthetextbox}{strut}begin{tikzpicture}[overlay, remember picture]draw ($(athetextbox.north west)+(-0.4arraycolsep,0ex)$) rectangle ($(bthetextbox.south east)+(0.4arraycolsep,0ex)$);end{tikzpicture}
to add extra space.
Full code:
documentclass{article}
usepackage{tikz}
usepackage{amsmath}
usetikzlibrary{tikzmark,calc}
newcounter{textbox}
deftl{stepcounter{textbox}tikzmarknode{athetextbox}{strut}}
defbr{tikzmarknode{bthetextbox}{strut}begin{tikzpicture}[overlay, remember picture]draw (athetextbox.north west) rectangle (bthetextbox.south east);end{tikzpicture}}
begin{document}
[
begin{bmatrix}
tl0 &-1 & & & & & & & & 0 \
1 & 0br & & & & & & & & \
& & cdot & & & & & & & \
& & & cdot & & & & & & \
& & & & cdot & & & & & \
& & & & &tl0 & 1 & & & \
& & & & &-1 & 0br & & & \
& & & & & & & cdot & & \
& & & & & & & & cdot & \
0 & & & & & & & & & cdot \
end{bmatrix}
]
end{document}
add a comment |
Here's a solution using TikZ that will work in all kinds of context, not just matrices, to draw boxes. You just need to put tl
in the point where the top-right corner is supposed to be and br
where the bottom-right will be. You can also use any TikZ feature to modify your box. Obviously this needs to be fine tuned depending on what exactly you're using it for (spacing etc.).
newcounter{textbox}
deftl{stepcounter{textbox}tikzmarknode{athetextbox}{strut}}
defbr{tikzmarknode{bthetextbox}{strut}begin{tikzpicture}[overlay, remember picture]draw (athetextbox.north west) rectangle (bthetextbox.south east);end{tikzpicture}}
The spacing in this version is not optimized for matrices, but you can use
tikzmarknode{bthetextbox}{strut}begin{tikzpicture}[overlay, remember picture]draw ($(athetextbox.north west)+(-0.4arraycolsep,0ex)$) rectangle ($(bthetextbox.south east)+(0.4arraycolsep,0ex)$);end{tikzpicture}
to add extra space.
Full code:
documentclass{article}
usepackage{tikz}
usepackage{amsmath}
usetikzlibrary{tikzmark,calc}
newcounter{textbox}
deftl{stepcounter{textbox}tikzmarknode{athetextbox}{strut}}
defbr{tikzmarknode{bthetextbox}{strut}begin{tikzpicture}[overlay, remember picture]draw (athetextbox.north west) rectangle (bthetextbox.south east);end{tikzpicture}}
begin{document}
[
begin{bmatrix}
tl0 &-1 & & & & & & & & 0 \
1 & 0br & & & & & & & & \
& & cdot & & & & & & & \
& & & cdot & & & & & & \
& & & & cdot & & & & & \
& & & & &tl0 & 1 & & & \
& & & & &-1 & 0br & & & \
& & & & & & & cdot & & \
& & & & & & & & cdot & \
0 & & & & & & & & & cdot \
end{bmatrix}
]
end{document}
Here's a solution using TikZ that will work in all kinds of context, not just matrices, to draw boxes. You just need to put tl
in the point where the top-right corner is supposed to be and br
where the bottom-right will be. You can also use any TikZ feature to modify your box. Obviously this needs to be fine tuned depending on what exactly you're using it for (spacing etc.).
newcounter{textbox}
deftl{stepcounter{textbox}tikzmarknode{athetextbox}{strut}}
defbr{tikzmarknode{bthetextbox}{strut}begin{tikzpicture}[overlay, remember picture]draw (athetextbox.north west) rectangle (bthetextbox.south east);end{tikzpicture}}
The spacing in this version is not optimized for matrices, but you can use
tikzmarknode{bthetextbox}{strut}begin{tikzpicture}[overlay, remember picture]draw ($(athetextbox.north west)+(-0.4arraycolsep,0ex)$) rectangle ($(bthetextbox.south east)+(0.4arraycolsep,0ex)$);end{tikzpicture}
to add extra space.
Full code:
documentclass{article}
usepackage{tikz}
usepackage{amsmath}
usetikzlibrary{tikzmark,calc}
newcounter{textbox}
deftl{stepcounter{textbox}tikzmarknode{athetextbox}{strut}}
defbr{tikzmarknode{bthetextbox}{strut}begin{tikzpicture}[overlay, remember picture]draw (athetextbox.north west) rectangle (bthetextbox.south east);end{tikzpicture}}
begin{document}
[
begin{bmatrix}
tl0 &-1 & & & & & & & & 0 \
1 & 0br & & & & & & & & \
& & cdot & & & & & & & \
& & & cdot & & & & & & \
& & & & cdot & & & & & \
& & & & &tl0 & 1 & & & \
& & & & &-1 & 0br & & & \
& & & & & & & cdot & & \
& & & & & & & & cdot & \
0 & & & & & & & & & cdot \
end{bmatrix}
]
end{document}
edited 2 days ago
answered 2 days ago
sheßsheß
2,05011436
2,05011436
add a comment |
add a comment |