TikZ: Align array of matrices
The following code:
documentclass[tikz,border=1mm]{standalone}
usepackage{tikz}
usetikzlibrary{matrix, positioning}
tikzset{
matrixstyle/.style={
matrix of nodes,
nodes={
draw
}
}}
begin{document}
begin{tikzpicture}
matrix (M) [matrixstyle]{
.1 & .1 \
.1 & .1 \
};
begin{scope} [local bounding box=MA, shift={(M.west)}, left = 0cm of M.west]
matrix (M11) [matrixstyle]{
.1 & .0 \
.5 & .0 \
};
matrix (M12) [matrixstyle, right = 0cm of M11]{
.2 & .0 \
.3 & .9 \
};
matrix (M21) [matrixstyle, below = 0cm of M11]{
.0 & .0 \
.0 & .2 \
};
matrix (M22) [matrixstyle, right = 0cm of M21]{
.3 & .0 \
.3 & .9 \
};
end{scope}
matrix (N) [matrixstyle, left = 1cm of MA.west]{
.2 & .2 \
.2 & .2 \
};
end{tikzpicture}
end{document}
produces the following output:
The output should show six matrices. Four in the middle. And one matrix each on the right and left side of the matrix array. However, I did not manage to place the matrix M to the right of the matrix array MA. The error is probably in the following line
begin{scope} [local bounding box=MA, shift={(M.west)}, left = 0cm of M.west]
What is the right way to do it? Why does my approach not work?
tikz-pgf
add a comment |
The following code:
documentclass[tikz,border=1mm]{standalone}
usepackage{tikz}
usetikzlibrary{matrix, positioning}
tikzset{
matrixstyle/.style={
matrix of nodes,
nodes={
draw
}
}}
begin{document}
begin{tikzpicture}
matrix (M) [matrixstyle]{
.1 & .1 \
.1 & .1 \
};
begin{scope} [local bounding box=MA, shift={(M.west)}, left = 0cm of M.west]
matrix (M11) [matrixstyle]{
.1 & .0 \
.5 & .0 \
};
matrix (M12) [matrixstyle, right = 0cm of M11]{
.2 & .0 \
.3 & .9 \
};
matrix (M21) [matrixstyle, below = 0cm of M11]{
.0 & .0 \
.0 & .2 \
};
matrix (M22) [matrixstyle, right = 0cm of M21]{
.3 & .0 \
.3 & .9 \
};
end{scope}
matrix (N) [matrixstyle, left = 1cm of MA.west]{
.2 & .2 \
.2 & .2 \
};
end{tikzpicture}
end{document}
produces the following output:
The output should show six matrices. Four in the middle. And one matrix each on the right and left side of the matrix array. However, I did not manage to place the matrix M to the right of the matrix array MA. The error is probably in the following line
begin{scope} [local bounding box=MA, shift={(M.west)}, left = 0cm of M.west]
What is the right way to do it? Why does my approach not work?
tikz-pgf
add a comment |
The following code:
documentclass[tikz,border=1mm]{standalone}
usepackage{tikz}
usetikzlibrary{matrix, positioning}
tikzset{
matrixstyle/.style={
matrix of nodes,
nodes={
draw
}
}}
begin{document}
begin{tikzpicture}
matrix (M) [matrixstyle]{
.1 & .1 \
.1 & .1 \
};
begin{scope} [local bounding box=MA, shift={(M.west)}, left = 0cm of M.west]
matrix (M11) [matrixstyle]{
.1 & .0 \
.5 & .0 \
};
matrix (M12) [matrixstyle, right = 0cm of M11]{
.2 & .0 \
.3 & .9 \
};
matrix (M21) [matrixstyle, below = 0cm of M11]{
.0 & .0 \
.0 & .2 \
};
matrix (M22) [matrixstyle, right = 0cm of M21]{
.3 & .0 \
.3 & .9 \
};
end{scope}
matrix (N) [matrixstyle, left = 1cm of MA.west]{
.2 & .2 \
.2 & .2 \
};
end{tikzpicture}
end{document}
produces the following output:
The output should show six matrices. Four in the middle. And one matrix each on the right and left side of the matrix array. However, I did not manage to place the matrix M to the right of the matrix array MA. The error is probably in the following line
begin{scope} [local bounding box=MA, shift={(M.west)}, left = 0cm of M.west]
What is the right way to do it? Why does my approach not work?
tikz-pgf
The following code:
documentclass[tikz,border=1mm]{standalone}
usepackage{tikz}
usetikzlibrary{matrix, positioning}
tikzset{
matrixstyle/.style={
matrix of nodes,
nodes={
draw
}
}}
begin{document}
begin{tikzpicture}
matrix (M) [matrixstyle]{
.1 & .1 \
.1 & .1 \
};
begin{scope} [local bounding box=MA, shift={(M.west)}, left = 0cm of M.west]
matrix (M11) [matrixstyle]{
.1 & .0 \
.5 & .0 \
};
matrix (M12) [matrixstyle, right = 0cm of M11]{
.2 & .0 \
.3 & .9 \
};
matrix (M21) [matrixstyle, below = 0cm of M11]{
.0 & .0 \
.0 & .2 \
};
matrix (M22) [matrixstyle, right = 0cm of M21]{
.3 & .0 \
.3 & .9 \
};
end{scope}
matrix (N) [matrixstyle, left = 1cm of MA.west]{
.2 & .2 \
.2 & .2 \
};
end{tikzpicture}
end{document}
produces the following output:
The output should show six matrices. Four in the middle. And one matrix each on the right and left side of the matrix array. However, I did not manage to place the matrix M to the right of the matrix array MA. The error is probably in the following line
begin{scope} [local bounding box=MA, shift={(M.west)}, left = 0cm of M.west]
What is the right way to do it? Why does my approach not work?
tikz-pgf
tikz-pgf
edited 2 hours ago
Bernard
167k769194
167k769194
asked 2 hours ago
SamuelSamuel
521211
521211
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Although not exactly the same, something very similar can be done with some tabular
and without TiKZ
.
documentclass{article}
newcommand{mytab}[4]{%
begin{tabular}[c]{|c|c|}
hline
#1\hline
#3\hline
end{tabular}}
begin{document}
mytab{.2}{.2}{.2}{.2}
begin{tabular}[c]{cccc}
mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
\[.5cm]
mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
end{tabular}
mytab{.2}{.0}{.3}{.9}
end{document}
EDIT: or even better with ytableau
package
documentclass{article}
usepackage{ytableau}
newcommand{mytab}[4]{%
begin{ytableau}
#1\
#3\
end{ytableau}}
begin{document}
ytableausetup{centertableaux}
mytab{.2}{.2}{.2}{.2}
begin{tabular}[c]{cccc}
mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
\[.5cm]
mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
end{tabular}
mytab{.2}{.0}{.3}{.9}
end{document}
add a comment |
like this?
matrices you can consider as nodes, so their positioning is with positioning
library is straightforward:
documentclass[tikz,border=1mm]{standalone}
usetikzlibrary{matrix, positioning}
begin{document}
begin{tikzpicture}[
node distance = 1mm and 2mm,
every matrix/.style = {matrix of nodes,
nodes={draw},
column sep=-pgflinewidth,
row sep=-pgflinewidth}
]
matrix (m1)
{
.2 & .2 \
.2 & .2 \
};
matrix (m11) [above right=of m1.east]
{
.1 & .0 \
.5 & .0 \
};
matrix (m12) [right=of m11]
{
.1 & .1 \
.1 & .1 \
};
matrix (m21) [below right= of m1.east]
{
.0 & .0 \
.0 & .2 \
};
matrix (m22) [right = of m21]{
.3 & .0 \
.3 & .9 \
};
matrix (m2) [right = of m1 -| m12.east]
{
.2 & .0 \
.3 & .9 \
};
end{tikzpicture}
end{document}
add a comment |
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
});
}
});
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%2f469745%2ftikz-align-array-of-matrices%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
Although not exactly the same, something very similar can be done with some tabular
and without TiKZ
.
documentclass{article}
newcommand{mytab}[4]{%
begin{tabular}[c]{|c|c|}
hline
#1\hline
#3\hline
end{tabular}}
begin{document}
mytab{.2}{.2}{.2}{.2}
begin{tabular}[c]{cccc}
mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
\[.5cm]
mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
end{tabular}
mytab{.2}{.0}{.3}{.9}
end{document}
EDIT: or even better with ytableau
package
documentclass{article}
usepackage{ytableau}
newcommand{mytab}[4]{%
begin{ytableau}
#1\
#3\
end{ytableau}}
begin{document}
ytableausetup{centertableaux}
mytab{.2}{.2}{.2}{.2}
begin{tabular}[c]{cccc}
mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
\[.5cm]
mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
end{tabular}
mytab{.2}{.0}{.3}{.9}
end{document}
add a comment |
Although not exactly the same, something very similar can be done with some tabular
and without TiKZ
.
documentclass{article}
newcommand{mytab}[4]{%
begin{tabular}[c]{|c|c|}
hline
#1\hline
#3\hline
end{tabular}}
begin{document}
mytab{.2}{.2}{.2}{.2}
begin{tabular}[c]{cccc}
mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
\[.5cm]
mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
end{tabular}
mytab{.2}{.0}{.3}{.9}
end{document}
EDIT: or even better with ytableau
package
documentclass{article}
usepackage{ytableau}
newcommand{mytab}[4]{%
begin{ytableau}
#1\
#3\
end{ytableau}}
begin{document}
ytableausetup{centertableaux}
mytab{.2}{.2}{.2}{.2}
begin{tabular}[c]{cccc}
mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
\[.5cm]
mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
end{tabular}
mytab{.2}{.0}{.3}{.9}
end{document}
add a comment |
Although not exactly the same, something very similar can be done with some tabular
and without TiKZ
.
documentclass{article}
newcommand{mytab}[4]{%
begin{tabular}[c]{|c|c|}
hline
#1\hline
#3\hline
end{tabular}}
begin{document}
mytab{.2}{.2}{.2}{.2}
begin{tabular}[c]{cccc}
mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
\[.5cm]
mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
end{tabular}
mytab{.2}{.0}{.3}{.9}
end{document}
EDIT: or even better with ytableau
package
documentclass{article}
usepackage{ytableau}
newcommand{mytab}[4]{%
begin{ytableau}
#1\
#3\
end{ytableau}}
begin{document}
ytableausetup{centertableaux}
mytab{.2}{.2}{.2}{.2}
begin{tabular}[c]{cccc}
mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
\[.5cm]
mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
end{tabular}
mytab{.2}{.0}{.3}{.9}
end{document}
Although not exactly the same, something very similar can be done with some tabular
and without TiKZ
.
documentclass{article}
newcommand{mytab}[4]{%
begin{tabular}[c]{|c|c|}
hline
#1\hline
#3\hline
end{tabular}}
begin{document}
mytab{.2}{.2}{.2}{.2}
begin{tabular}[c]{cccc}
mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
\[.5cm]
mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
end{tabular}
mytab{.2}{.0}{.3}{.9}
end{document}
EDIT: or even better with ytableau
package
documentclass{article}
usepackage{ytableau}
newcommand{mytab}[4]{%
begin{ytableau}
#1\
#3\
end{ytableau}}
begin{document}
ytableausetup{centertableaux}
mytab{.2}{.2}{.2}{.2}
begin{tabular}[c]{cccc}
mytab{.1}{.0}{.5}{.2} & mytab{.1}{.1}{.1}{.1}
\[.5cm]
mytab{.0}{.0}{.0}{.2} & mytab{.3}{.0}{.3}{.9}
end{tabular}
mytab{.2}{.0}{.3}{.9}
end{document}
edited 51 mins ago
answered 1 hour ago
IgnasiIgnasi
91.9k4166305
91.9k4166305
add a comment |
add a comment |
like this?
matrices you can consider as nodes, so their positioning is with positioning
library is straightforward:
documentclass[tikz,border=1mm]{standalone}
usetikzlibrary{matrix, positioning}
begin{document}
begin{tikzpicture}[
node distance = 1mm and 2mm,
every matrix/.style = {matrix of nodes,
nodes={draw},
column sep=-pgflinewidth,
row sep=-pgflinewidth}
]
matrix (m1)
{
.2 & .2 \
.2 & .2 \
};
matrix (m11) [above right=of m1.east]
{
.1 & .0 \
.5 & .0 \
};
matrix (m12) [right=of m11]
{
.1 & .1 \
.1 & .1 \
};
matrix (m21) [below right= of m1.east]
{
.0 & .0 \
.0 & .2 \
};
matrix (m22) [right = of m21]{
.3 & .0 \
.3 & .9 \
};
matrix (m2) [right = of m1 -| m12.east]
{
.2 & .0 \
.3 & .9 \
};
end{tikzpicture}
end{document}
add a comment |
like this?
matrices you can consider as nodes, so their positioning is with positioning
library is straightforward:
documentclass[tikz,border=1mm]{standalone}
usetikzlibrary{matrix, positioning}
begin{document}
begin{tikzpicture}[
node distance = 1mm and 2mm,
every matrix/.style = {matrix of nodes,
nodes={draw},
column sep=-pgflinewidth,
row sep=-pgflinewidth}
]
matrix (m1)
{
.2 & .2 \
.2 & .2 \
};
matrix (m11) [above right=of m1.east]
{
.1 & .0 \
.5 & .0 \
};
matrix (m12) [right=of m11]
{
.1 & .1 \
.1 & .1 \
};
matrix (m21) [below right= of m1.east]
{
.0 & .0 \
.0 & .2 \
};
matrix (m22) [right = of m21]{
.3 & .0 \
.3 & .9 \
};
matrix (m2) [right = of m1 -| m12.east]
{
.2 & .0 \
.3 & .9 \
};
end{tikzpicture}
end{document}
add a comment |
like this?
matrices you can consider as nodes, so their positioning is with positioning
library is straightforward:
documentclass[tikz,border=1mm]{standalone}
usetikzlibrary{matrix, positioning}
begin{document}
begin{tikzpicture}[
node distance = 1mm and 2mm,
every matrix/.style = {matrix of nodes,
nodes={draw},
column sep=-pgflinewidth,
row sep=-pgflinewidth}
]
matrix (m1)
{
.2 & .2 \
.2 & .2 \
};
matrix (m11) [above right=of m1.east]
{
.1 & .0 \
.5 & .0 \
};
matrix (m12) [right=of m11]
{
.1 & .1 \
.1 & .1 \
};
matrix (m21) [below right= of m1.east]
{
.0 & .0 \
.0 & .2 \
};
matrix (m22) [right = of m21]{
.3 & .0 \
.3 & .9 \
};
matrix (m2) [right = of m1 -| m12.east]
{
.2 & .0 \
.3 & .9 \
};
end{tikzpicture}
end{document}
like this?
matrices you can consider as nodes, so their positioning is with positioning
library is straightforward:
documentclass[tikz,border=1mm]{standalone}
usetikzlibrary{matrix, positioning}
begin{document}
begin{tikzpicture}[
node distance = 1mm and 2mm,
every matrix/.style = {matrix of nodes,
nodes={draw},
column sep=-pgflinewidth,
row sep=-pgflinewidth}
]
matrix (m1)
{
.2 & .2 \
.2 & .2 \
};
matrix (m11) [above right=of m1.east]
{
.1 & .0 \
.5 & .0 \
};
matrix (m12) [right=of m11]
{
.1 & .1 \
.1 & .1 \
};
matrix (m21) [below right= of m1.east]
{
.0 & .0 \
.0 & .2 \
};
matrix (m22) [right = of m21]{
.3 & .0 \
.3 & .9 \
};
matrix (m2) [right = of m1 -| m12.east]
{
.2 & .0 \
.3 & .9 \
};
end{tikzpicture}
end{document}
edited 1 hour ago
answered 1 hour ago
ZarkoZarko
122k865158
122k865158
add a comment |
add a comment |
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.
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%2f469745%2ftikz-align-array-of-matrices%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