Problem drawing boxes with arrows in tikZRotate a node but not its content: the case of the ellipse decorationTikZ node placement and arrow drawingHow to define the default vertical distance between nodes?Computing the rectangle encompassing a node and a pointNumerical conditional within tikz keys?TikZ: Drawing an arc from an intersection to an intersectionHow to prevent rounded and duplicated tick labels in pgfplots with fixed precision?Drawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawingLine up nested tikz enviroments or how to get rid of themHow to draw a square and its diagonals with arrows?
What's the correct way to determine turn order in this situation?
Writing about real people - not giving offence
Why is music is taught by reading sheet music?
Bothered by watching coworkers slacking off
How to identify whether a publisher is genuine or not?
What action is recommended if your accommodation refuses to let you leave without paying additional fees?
Anonymous reviewer disclosed his identity. Should I thank him by name?
Why does the Pilatus PC-24 have such a large "Wing Support"?
Is "weekend warrior" derogatory?
Booting Ubuntu from USB drive on MSI motherboard -- EVERYTHING fails
What does a textbook look like while you are writing it?
If I travelled back in time to invest in X company to make a fortune, roughly what is the probability that it would fail?
How can I find places to store/land a private airplane?
Parent asking for money after I moved out
Knights and Knaves: What does C say?
Do jackscrews suffer from blowdown?
Could the Queen overturn the UK Supreme Court ruling regarding prorogation of Parliament?
How to refresh wired service getRecord manually?
Does publication of the phone call ruin the basis for impeachment?
What powers or limits devil promotion?
What are one's options when facing religious discrimination at the airport?
GPLv3 forces us to make code available, but to who?
How to say "respectively" in German when listing (enumerating) things
How dangerous are my worn rims?
Problem drawing boxes with arrows in tikZ
Rotate a node but not its content: the case of the ellipse decorationTikZ node placement and arrow drawingHow to define the default vertical distance between nodes?Computing the rectangle encompassing a node and a pointNumerical conditional within tikz keys?TikZ: Drawing an arc from an intersection to an intersectionHow to prevent rounded and duplicated tick labels in pgfplots with fixed precision?Drawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawingLine up nested tikz enviroments or how to get rid of themHow to draw a square and its diagonals with arrows?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
Could someone, whenever it's possible, post a minimal tikZ example to draw this? I also would like to put an "R" inside the upper box. This is mi code so far (I know, it's a mess):
documentclass[tikz]standalone
begindocument
tikzstylevspecies=[rectangle, minimum size=0.5cm,draw=black,fill=blue]
begintikzpicture
node [vspecies] (I) I ;
node [vspecies, above left of = I] (N) M ;
node [vspecies, below left of = I] (K) K ;
draw [->,thick] (S.south east) -- node small$N$ (M) ; ;
draw [->,thick] (C) -- node [below right] small$M$ (M) ;
endtikzpicture
enddocument

tikz-pgf
add a comment
|
Could someone, whenever it's possible, post a minimal tikZ example to draw this? I also would like to put an "R" inside the upper box. This is mi code so far (I know, it's a mess):
documentclass[tikz]standalone
begindocument
tikzstylevspecies=[rectangle, minimum size=0.5cm,draw=black,fill=blue]
begintikzpicture
node [vspecies] (I) I ;
node [vspecies, above left of = I] (N) M ;
node [vspecies, below left of = I] (K) K ;
draw [->,thick] (S.south east) -- node small$N$ (M) ; ;
draw [->,thick] (C) -- node [below right] small$M$ (M) ;
endtikzpicture
enddocument

tikz-pgf
1
You can uselocal bounding box. Btw, your code is not even compilable
– user156344
Apr 16 at 5:13
add a comment
|
Could someone, whenever it's possible, post a minimal tikZ example to draw this? I also would like to put an "R" inside the upper box. This is mi code so far (I know, it's a mess):
documentclass[tikz]standalone
begindocument
tikzstylevspecies=[rectangle, minimum size=0.5cm,draw=black,fill=blue]
begintikzpicture
node [vspecies] (I) I ;
node [vspecies, above left of = I] (N) M ;
node [vspecies, below left of = I] (K) K ;
draw [->,thick] (S.south east) -- node small$N$ (M) ; ;
draw [->,thick] (C) -- node [below right] small$M$ (M) ;
endtikzpicture
enddocument

tikz-pgf
Could someone, whenever it's possible, post a minimal tikZ example to draw this? I also would like to put an "R" inside the upper box. This is mi code so far (I know, it's a mess):
documentclass[tikz]standalone
begindocument
tikzstylevspecies=[rectangle, minimum size=0.5cm,draw=black,fill=blue]
begintikzpicture
node [vspecies] (I) I ;
node [vspecies, above left of = I] (N) M ;
node [vspecies, below left of = I] (K) K ;
draw [->,thick] (S.south east) -- node small$N$ (M) ; ;
draw [->,thick] (C) -- node [below right] small$M$ (M) ;
endtikzpicture
enddocument

tikz-pgf
tikz-pgf
asked Apr 16 at 5:12
NaveganTeXNaveganTeX
1,1192 silver badges13 bronze badges
1,1192 silver badges13 bronze badges
1
You can uselocal bounding box. Btw, your code is not even compilable
– user156344
Apr 16 at 5:13
add a comment
|
1
You can uselocal bounding box. Btw, your code is not even compilable
– user156344
Apr 16 at 5:13
1
1
You can use
local bounding box. Btw, your code is not even compilable– user156344
Apr 16 at 5:13
You can use
local bounding box. Btw, your code is not even compilable– user156344
Apr 16 at 5:13
add a comment
|
4 Answers
4
active
oldest
votes
Just for fun.
documentclass[tikz]standalone
usetikzlibrarypositioning
begindocument
tikzsetvspecies/.style=rectangle, minimum size=0.5cm,draw=blue
begintikzpicture[>=latex]
node[draw,minimum width=1cm,minimum height=2cm,
label=left:$M$,label=above:$N$] (R)$R$;
node [vspecies,below left=1cm and 0.2cm of R,minimum height=1.2cm,
label=left:$M$,label=above:$K$] (R1) ;
node [vspecies,below right=1cm and 0.2cm of R,minimum width=1.2cm,
label=left:$K$,label=above:$N$] (R2) ;
draw [->,thick,shorten >=1mm,shorten <=1mm] (R.south west) -- (R1.north east);
draw [->,thick,shorten >=1mm,shorten <=1mm] (R.south east) -- (R2.north west);
endtikzpicture
enddocument

add a comment
|
Something like this?
documentclass[tikz,margin=1mm]standalone
usetikzlibrarypositioning
begindocument
begintikzpicture
beginscope[local bounding box=a]
node[minimum width=2cm,minimum height=3cm,draw] (main-a) ;
path (main-a.west) node[left] $N$ (main-a.north) node[above] $M$;
endscope
beginscope[local bounding box=b2]
node[minimum width=2cm,minimum height=1cm,draw,below right=of main-a] (main-b2) ;
path (main-b2.east) node[right] $K$ (main-b2.north) node[above] $M$;
endscope
beginscope[local bounding box=b1]
node[minimum width=1cm,minimum height=3cm,draw,below left=of main-a] (main-b1) ;
path (main-b1.west) node[left] $N$ (main-b1.north) node[above] $K$;
endscope
draw[-stealth] (main-a.south) -- (b1.north east);
draw[-stealth] (main-a.south) -- (b2.north west);
endtikzpicture
enddocument

add a comment
|
Here is an overkill solution that defines a new pics "shape" (see section 18.2 of the 3.1.1 tikz manual),together with some custom pgfkeys for styling it. The end result is that you can produce:

using code:
documentclass[tikz, border=5mm]standalone
usetikzlibrarypositioning
begindocument
pgfkeys/vspecies/.is family, /vspecies,
colour/.initial = black, % rectangle colour
fill/.initial = white, % default fill
top label/.initial = M, % label on right
right label/.initial= N, % label on left
bottom label/.initial=, % label on left
left label/.initial=, % label on left
X/.initial = 5mm, % default width
Y/.initial = 5mm, % default height
shape/.initial = rectangle % default shape
tikzset
pics/vspecies/.style args=#1,#2% node name, pgfkeys key-value pairs
code =
pgfkeys/vspecies, #2
node[pgfkeysvalueof/vspecies/shape,
minimum size=pgfkeysvalueof/vspecies/X,
minimum height=pgfkeysvalueof/vspecies/Y,
draw=pgfkeysvalueof/vspecies/colour,
fill=pgfkeysvalueof/vspecies/fill,
label=east:pgfkeysvalueof/vspecies/left label,
label=north:pgfkeysvalueof/vspecies/top label,
label=south:pgfkeysvalueof/vspecies/bottom label,
label=west:pgfkeysvalueof/vspecies/right label,
](#1) at (0,0);
begintikzpicture
pic at (0,0) vspecies=A,colour=red,Y=10mm;
pic[below left=10mm of A] vspecies=B,top label=K,colour=blue,Y=20mm;
pic[below right=10mm of A] vspecies=C,fill=blue!10,X=10mm,shape=circle,left label=N,right label=;
draw[->](A.south west)--(B.north east);
draw[->](A.south east)--(C.north west);
endtikzpicture
enddocument
The vspecies pic command take two arguments: the first is the name of a (normal) tikz node label and the second argunment is a comma separated list of key-value pairs tha specify:
- the
colourof the rectangle (default black) - the
fillcolour (default white) - the
top label(default M) - the
left label(default "") - the
bottom label(default "") - the
left label(default N) - the minimum
Xwidth - the minimum
Yheight - the
shape(default rectangle)
As I said, this is overkill (and I was bored:)
add a comment
|
Final version:
documentclass[tikz,margin=1mm]standalone
usetikzlibrarypositioning
begindocument
sffamily
begintikzpicture
beginscope[local bounding box=a]
node[minimum width=2cm,line width=0.199mm,minimum height=3cm,draw=black] (main-a) R;
path (main-a.west) node[left] N (main-a.north) node[above] M;
endscope
beginscope[local bounding box=b2]
node[minimum width=2cm,line width=0.199mm,minimum height=1cm,draw=blue,below right=of main-a] (main-b2) ;
path (main-b2.east) node[right] K (main-b2.north) node[above] M;
endscope
beginscope[local bounding box=b1]
node[minimum width=1cm,line width=0.199mm,minimum height=3cm,draw=blue,below left=of main-a] (main-b1) ;
path (main-b1.west) node[left] N (main-b1.north) node[above] K;
endscope
draw[-stealth] (main-a.south) -- (b1.north east);
draw[-stealth] (main-a.south) -- (b2.north west);
endtikzpicture
enddocument
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/4.0/"u003ecc by-sa 4.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%2f485078%2fproblem-drawing-boxes-with-arrows-in-tikz%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Just for fun.
documentclass[tikz]standalone
usetikzlibrarypositioning
begindocument
tikzsetvspecies/.style=rectangle, minimum size=0.5cm,draw=blue
begintikzpicture[>=latex]
node[draw,minimum width=1cm,minimum height=2cm,
label=left:$M$,label=above:$N$] (R)$R$;
node [vspecies,below left=1cm and 0.2cm of R,minimum height=1.2cm,
label=left:$M$,label=above:$K$] (R1) ;
node [vspecies,below right=1cm and 0.2cm of R,minimum width=1.2cm,
label=left:$K$,label=above:$N$] (R2) ;
draw [->,thick,shorten >=1mm,shorten <=1mm] (R.south west) -- (R1.north east);
draw [->,thick,shorten >=1mm,shorten <=1mm] (R.south east) -- (R2.north west);
endtikzpicture
enddocument

add a comment
|
Just for fun.
documentclass[tikz]standalone
usetikzlibrarypositioning
begindocument
tikzsetvspecies/.style=rectangle, minimum size=0.5cm,draw=blue
begintikzpicture[>=latex]
node[draw,minimum width=1cm,minimum height=2cm,
label=left:$M$,label=above:$N$] (R)$R$;
node [vspecies,below left=1cm and 0.2cm of R,minimum height=1.2cm,
label=left:$M$,label=above:$K$] (R1) ;
node [vspecies,below right=1cm and 0.2cm of R,minimum width=1.2cm,
label=left:$K$,label=above:$N$] (R2) ;
draw [->,thick,shorten >=1mm,shorten <=1mm] (R.south west) -- (R1.north east);
draw [->,thick,shorten >=1mm,shorten <=1mm] (R.south east) -- (R2.north west);
endtikzpicture
enddocument

add a comment
|
Just for fun.
documentclass[tikz]standalone
usetikzlibrarypositioning
begindocument
tikzsetvspecies/.style=rectangle, minimum size=0.5cm,draw=blue
begintikzpicture[>=latex]
node[draw,minimum width=1cm,minimum height=2cm,
label=left:$M$,label=above:$N$] (R)$R$;
node [vspecies,below left=1cm and 0.2cm of R,minimum height=1.2cm,
label=left:$M$,label=above:$K$] (R1) ;
node [vspecies,below right=1cm and 0.2cm of R,minimum width=1.2cm,
label=left:$K$,label=above:$N$] (R2) ;
draw [->,thick,shorten >=1mm,shorten <=1mm] (R.south west) -- (R1.north east);
draw [->,thick,shorten >=1mm,shorten <=1mm] (R.south east) -- (R2.north west);
endtikzpicture
enddocument

Just for fun.
documentclass[tikz]standalone
usetikzlibrarypositioning
begindocument
tikzsetvspecies/.style=rectangle, minimum size=0.5cm,draw=blue
begintikzpicture[>=latex]
node[draw,minimum width=1cm,minimum height=2cm,
label=left:$M$,label=above:$N$] (R)$R$;
node [vspecies,below left=1cm and 0.2cm of R,minimum height=1.2cm,
label=left:$M$,label=above:$K$] (R1) ;
node [vspecies,below right=1cm and 0.2cm of R,minimum width=1.2cm,
label=left:$K$,label=above:$N$] (R2) ;
draw [->,thick,shorten >=1mm,shorten <=1mm] (R.south west) -- (R1.north east);
draw [->,thick,shorten >=1mm,shorten <=1mm] (R.south east) -- (R2.north west);
endtikzpicture
enddocument

answered Apr 16 at 5:28
user121799
add a comment
|
add a comment
|
Something like this?
documentclass[tikz,margin=1mm]standalone
usetikzlibrarypositioning
begindocument
begintikzpicture
beginscope[local bounding box=a]
node[minimum width=2cm,minimum height=3cm,draw] (main-a) ;
path (main-a.west) node[left] $N$ (main-a.north) node[above] $M$;
endscope
beginscope[local bounding box=b2]
node[minimum width=2cm,minimum height=1cm,draw,below right=of main-a] (main-b2) ;
path (main-b2.east) node[right] $K$ (main-b2.north) node[above] $M$;
endscope
beginscope[local bounding box=b1]
node[minimum width=1cm,minimum height=3cm,draw,below left=of main-a] (main-b1) ;
path (main-b1.west) node[left] $N$ (main-b1.north) node[above] $K$;
endscope
draw[-stealth] (main-a.south) -- (b1.north east);
draw[-stealth] (main-a.south) -- (b2.north west);
endtikzpicture
enddocument

add a comment
|
Something like this?
documentclass[tikz,margin=1mm]standalone
usetikzlibrarypositioning
begindocument
begintikzpicture
beginscope[local bounding box=a]
node[minimum width=2cm,minimum height=3cm,draw] (main-a) ;
path (main-a.west) node[left] $N$ (main-a.north) node[above] $M$;
endscope
beginscope[local bounding box=b2]
node[minimum width=2cm,minimum height=1cm,draw,below right=of main-a] (main-b2) ;
path (main-b2.east) node[right] $K$ (main-b2.north) node[above] $M$;
endscope
beginscope[local bounding box=b1]
node[minimum width=1cm,minimum height=3cm,draw,below left=of main-a] (main-b1) ;
path (main-b1.west) node[left] $N$ (main-b1.north) node[above] $K$;
endscope
draw[-stealth] (main-a.south) -- (b1.north east);
draw[-stealth] (main-a.south) -- (b2.north west);
endtikzpicture
enddocument

add a comment
|
Something like this?
documentclass[tikz,margin=1mm]standalone
usetikzlibrarypositioning
begindocument
begintikzpicture
beginscope[local bounding box=a]
node[minimum width=2cm,minimum height=3cm,draw] (main-a) ;
path (main-a.west) node[left] $N$ (main-a.north) node[above] $M$;
endscope
beginscope[local bounding box=b2]
node[minimum width=2cm,minimum height=1cm,draw,below right=of main-a] (main-b2) ;
path (main-b2.east) node[right] $K$ (main-b2.north) node[above] $M$;
endscope
beginscope[local bounding box=b1]
node[minimum width=1cm,minimum height=3cm,draw,below left=of main-a] (main-b1) ;
path (main-b1.west) node[left] $N$ (main-b1.north) node[above] $K$;
endscope
draw[-stealth] (main-a.south) -- (b1.north east);
draw[-stealth] (main-a.south) -- (b2.north west);
endtikzpicture
enddocument

Something like this?
documentclass[tikz,margin=1mm]standalone
usetikzlibrarypositioning
begindocument
begintikzpicture
beginscope[local bounding box=a]
node[minimum width=2cm,minimum height=3cm,draw] (main-a) ;
path (main-a.west) node[left] $N$ (main-a.north) node[above] $M$;
endscope
beginscope[local bounding box=b2]
node[minimum width=2cm,minimum height=1cm,draw,below right=of main-a] (main-b2) ;
path (main-b2.east) node[right] $K$ (main-b2.north) node[above] $M$;
endscope
beginscope[local bounding box=b1]
node[minimum width=1cm,minimum height=3cm,draw,below left=of main-a] (main-b1) ;
path (main-b1.west) node[left] $N$ (main-b1.north) node[above] $K$;
endscope
draw[-stealth] (main-a.south) -- (b1.north east);
draw[-stealth] (main-a.south) -- (b2.north west);
endtikzpicture
enddocument

answered Apr 16 at 5:22
user156344
add a comment
|
add a comment
|
Here is an overkill solution that defines a new pics "shape" (see section 18.2 of the 3.1.1 tikz manual),together with some custom pgfkeys for styling it. The end result is that you can produce:

using code:
documentclass[tikz, border=5mm]standalone
usetikzlibrarypositioning
begindocument
pgfkeys/vspecies/.is family, /vspecies,
colour/.initial = black, % rectangle colour
fill/.initial = white, % default fill
top label/.initial = M, % label on right
right label/.initial= N, % label on left
bottom label/.initial=, % label on left
left label/.initial=, % label on left
X/.initial = 5mm, % default width
Y/.initial = 5mm, % default height
shape/.initial = rectangle % default shape
tikzset
pics/vspecies/.style args=#1,#2% node name, pgfkeys key-value pairs
code =
pgfkeys/vspecies, #2
node[pgfkeysvalueof/vspecies/shape,
minimum size=pgfkeysvalueof/vspecies/X,
minimum height=pgfkeysvalueof/vspecies/Y,
draw=pgfkeysvalueof/vspecies/colour,
fill=pgfkeysvalueof/vspecies/fill,
label=east:pgfkeysvalueof/vspecies/left label,
label=north:pgfkeysvalueof/vspecies/top label,
label=south:pgfkeysvalueof/vspecies/bottom label,
label=west:pgfkeysvalueof/vspecies/right label,
](#1) at (0,0);
begintikzpicture
pic at (0,0) vspecies=A,colour=red,Y=10mm;
pic[below left=10mm of A] vspecies=B,top label=K,colour=blue,Y=20mm;
pic[below right=10mm of A] vspecies=C,fill=blue!10,X=10mm,shape=circle,left label=N,right label=;
draw[->](A.south west)--(B.north east);
draw[->](A.south east)--(C.north west);
endtikzpicture
enddocument
The vspecies pic command take two arguments: the first is the name of a (normal) tikz node label and the second argunment is a comma separated list of key-value pairs tha specify:
- the
colourof the rectangle (default black) - the
fillcolour (default white) - the
top label(default M) - the
left label(default "") - the
bottom label(default "") - the
left label(default N) - the minimum
Xwidth - the minimum
Yheight - the
shape(default rectangle)
As I said, this is overkill (and I was bored:)
add a comment
|
Here is an overkill solution that defines a new pics "shape" (see section 18.2 of the 3.1.1 tikz manual),together with some custom pgfkeys for styling it. The end result is that you can produce:

using code:
documentclass[tikz, border=5mm]standalone
usetikzlibrarypositioning
begindocument
pgfkeys/vspecies/.is family, /vspecies,
colour/.initial = black, % rectangle colour
fill/.initial = white, % default fill
top label/.initial = M, % label on right
right label/.initial= N, % label on left
bottom label/.initial=, % label on left
left label/.initial=, % label on left
X/.initial = 5mm, % default width
Y/.initial = 5mm, % default height
shape/.initial = rectangle % default shape
tikzset
pics/vspecies/.style args=#1,#2% node name, pgfkeys key-value pairs
code =
pgfkeys/vspecies, #2
node[pgfkeysvalueof/vspecies/shape,
minimum size=pgfkeysvalueof/vspecies/X,
minimum height=pgfkeysvalueof/vspecies/Y,
draw=pgfkeysvalueof/vspecies/colour,
fill=pgfkeysvalueof/vspecies/fill,
label=east:pgfkeysvalueof/vspecies/left label,
label=north:pgfkeysvalueof/vspecies/top label,
label=south:pgfkeysvalueof/vspecies/bottom label,
label=west:pgfkeysvalueof/vspecies/right label,
](#1) at (0,0);
begintikzpicture
pic at (0,0) vspecies=A,colour=red,Y=10mm;
pic[below left=10mm of A] vspecies=B,top label=K,colour=blue,Y=20mm;
pic[below right=10mm of A] vspecies=C,fill=blue!10,X=10mm,shape=circle,left label=N,right label=;
draw[->](A.south west)--(B.north east);
draw[->](A.south east)--(C.north west);
endtikzpicture
enddocument
The vspecies pic command take two arguments: the first is the name of a (normal) tikz node label and the second argunment is a comma separated list of key-value pairs tha specify:
- the
colourof the rectangle (default black) - the
fillcolour (default white) - the
top label(default M) - the
left label(default "") - the
bottom label(default "") - the
left label(default N) - the minimum
Xwidth - the minimum
Yheight - the
shape(default rectangle)
As I said, this is overkill (and I was bored:)
add a comment
|
Here is an overkill solution that defines a new pics "shape" (see section 18.2 of the 3.1.1 tikz manual),together with some custom pgfkeys for styling it. The end result is that you can produce:

using code:
documentclass[tikz, border=5mm]standalone
usetikzlibrarypositioning
begindocument
pgfkeys/vspecies/.is family, /vspecies,
colour/.initial = black, % rectangle colour
fill/.initial = white, % default fill
top label/.initial = M, % label on right
right label/.initial= N, % label on left
bottom label/.initial=, % label on left
left label/.initial=, % label on left
X/.initial = 5mm, % default width
Y/.initial = 5mm, % default height
shape/.initial = rectangle % default shape
tikzset
pics/vspecies/.style args=#1,#2% node name, pgfkeys key-value pairs
code =
pgfkeys/vspecies, #2
node[pgfkeysvalueof/vspecies/shape,
minimum size=pgfkeysvalueof/vspecies/X,
minimum height=pgfkeysvalueof/vspecies/Y,
draw=pgfkeysvalueof/vspecies/colour,
fill=pgfkeysvalueof/vspecies/fill,
label=east:pgfkeysvalueof/vspecies/left label,
label=north:pgfkeysvalueof/vspecies/top label,
label=south:pgfkeysvalueof/vspecies/bottom label,
label=west:pgfkeysvalueof/vspecies/right label,
](#1) at (0,0);
begintikzpicture
pic at (0,0) vspecies=A,colour=red,Y=10mm;
pic[below left=10mm of A] vspecies=B,top label=K,colour=blue,Y=20mm;
pic[below right=10mm of A] vspecies=C,fill=blue!10,X=10mm,shape=circle,left label=N,right label=;
draw[->](A.south west)--(B.north east);
draw[->](A.south east)--(C.north west);
endtikzpicture
enddocument
The vspecies pic command take two arguments: the first is the name of a (normal) tikz node label and the second argunment is a comma separated list of key-value pairs tha specify:
- the
colourof the rectangle (default black) - the
fillcolour (default white) - the
top label(default M) - the
left label(default "") - the
bottom label(default "") - the
left label(default N) - the minimum
Xwidth - the minimum
Yheight - the
shape(default rectangle)
As I said, this is overkill (and I was bored:)
Here is an overkill solution that defines a new pics "shape" (see section 18.2 of the 3.1.1 tikz manual),together with some custom pgfkeys for styling it. The end result is that you can produce:

using code:
documentclass[tikz, border=5mm]standalone
usetikzlibrarypositioning
begindocument
pgfkeys/vspecies/.is family, /vspecies,
colour/.initial = black, % rectangle colour
fill/.initial = white, % default fill
top label/.initial = M, % label on right
right label/.initial= N, % label on left
bottom label/.initial=, % label on left
left label/.initial=, % label on left
X/.initial = 5mm, % default width
Y/.initial = 5mm, % default height
shape/.initial = rectangle % default shape
tikzset
pics/vspecies/.style args=#1,#2% node name, pgfkeys key-value pairs
code =
pgfkeys/vspecies, #2
node[pgfkeysvalueof/vspecies/shape,
minimum size=pgfkeysvalueof/vspecies/X,
minimum height=pgfkeysvalueof/vspecies/Y,
draw=pgfkeysvalueof/vspecies/colour,
fill=pgfkeysvalueof/vspecies/fill,
label=east:pgfkeysvalueof/vspecies/left label,
label=north:pgfkeysvalueof/vspecies/top label,
label=south:pgfkeysvalueof/vspecies/bottom label,
label=west:pgfkeysvalueof/vspecies/right label,
](#1) at (0,0);
begintikzpicture
pic at (0,0) vspecies=A,colour=red,Y=10mm;
pic[below left=10mm of A] vspecies=B,top label=K,colour=blue,Y=20mm;
pic[below right=10mm of A] vspecies=C,fill=blue!10,X=10mm,shape=circle,left label=N,right label=;
draw[->](A.south west)--(B.north east);
draw[->](A.south east)--(C.north west);
endtikzpicture
enddocument
The vspecies pic command take two arguments: the first is the name of a (normal) tikz node label and the second argunment is a comma separated list of key-value pairs tha specify:
- the
colourof the rectangle (default black) - the
fillcolour (default white) - the
top label(default M) - the
left label(default "") - the
bottom label(default "") - the
left label(default N) - the minimum
Xwidth - the minimum
Yheight - the
shape(default rectangle)
As I said, this is overkill (and I was bored:)
answered Apr 16 at 6:07
AndrewAndrew
34.3k3 gold badges50 silver badges88 bronze badges
34.3k3 gold badges50 silver badges88 bronze badges
add a comment
|
add a comment
|
Final version:
documentclass[tikz,margin=1mm]standalone
usetikzlibrarypositioning
begindocument
sffamily
begintikzpicture
beginscope[local bounding box=a]
node[minimum width=2cm,line width=0.199mm,minimum height=3cm,draw=black] (main-a) R;
path (main-a.west) node[left] N (main-a.north) node[above] M;
endscope
beginscope[local bounding box=b2]
node[minimum width=2cm,line width=0.199mm,minimum height=1cm,draw=blue,below right=of main-a] (main-b2) ;
path (main-b2.east) node[right] K (main-b2.north) node[above] M;
endscope
beginscope[local bounding box=b1]
node[minimum width=1cm,line width=0.199mm,minimum height=3cm,draw=blue,below left=of main-a] (main-b1) ;
path (main-b1.west) node[left] N (main-b1.north) node[above] K;
endscope
draw[-stealth] (main-a.south) -- (b1.north east);
draw[-stealth] (main-a.south) -- (b2.north west);
endtikzpicture
enddocument
add a comment
|
Final version:
documentclass[tikz,margin=1mm]standalone
usetikzlibrarypositioning
begindocument
sffamily
begintikzpicture
beginscope[local bounding box=a]
node[minimum width=2cm,line width=0.199mm,minimum height=3cm,draw=black] (main-a) R;
path (main-a.west) node[left] N (main-a.north) node[above] M;
endscope
beginscope[local bounding box=b2]
node[minimum width=2cm,line width=0.199mm,minimum height=1cm,draw=blue,below right=of main-a] (main-b2) ;
path (main-b2.east) node[right] K (main-b2.north) node[above] M;
endscope
beginscope[local bounding box=b1]
node[minimum width=1cm,line width=0.199mm,minimum height=3cm,draw=blue,below left=of main-a] (main-b1) ;
path (main-b1.west) node[left] N (main-b1.north) node[above] K;
endscope
draw[-stealth] (main-a.south) -- (b1.north east);
draw[-stealth] (main-a.south) -- (b2.north west);
endtikzpicture
enddocument
add a comment
|
Final version:
documentclass[tikz,margin=1mm]standalone
usetikzlibrarypositioning
begindocument
sffamily
begintikzpicture
beginscope[local bounding box=a]
node[minimum width=2cm,line width=0.199mm,minimum height=3cm,draw=black] (main-a) R;
path (main-a.west) node[left] N (main-a.north) node[above] M;
endscope
beginscope[local bounding box=b2]
node[minimum width=2cm,line width=0.199mm,minimum height=1cm,draw=blue,below right=of main-a] (main-b2) ;
path (main-b2.east) node[right] K (main-b2.north) node[above] M;
endscope
beginscope[local bounding box=b1]
node[minimum width=1cm,line width=0.199mm,minimum height=3cm,draw=blue,below left=of main-a] (main-b1) ;
path (main-b1.west) node[left] N (main-b1.north) node[above] K;
endscope
draw[-stealth] (main-a.south) -- (b1.north east);
draw[-stealth] (main-a.south) -- (b2.north west);
endtikzpicture
enddocument
Final version:
documentclass[tikz,margin=1mm]standalone
usetikzlibrarypositioning
begindocument
sffamily
begintikzpicture
beginscope[local bounding box=a]
node[minimum width=2cm,line width=0.199mm,minimum height=3cm,draw=black] (main-a) R;
path (main-a.west) node[left] N (main-a.north) node[above] M;
endscope
beginscope[local bounding box=b2]
node[minimum width=2cm,line width=0.199mm,minimum height=1cm,draw=blue,below right=of main-a] (main-b2) ;
path (main-b2.east) node[right] K (main-b2.north) node[above] M;
endscope
beginscope[local bounding box=b1]
node[minimum width=1cm,line width=0.199mm,minimum height=3cm,draw=blue,below left=of main-a] (main-b1) ;
path (main-b1.west) node[left] N (main-b1.north) node[above] K;
endscope
draw[-stealth] (main-a.south) -- (b1.north east);
draw[-stealth] (main-a.south) -- (b2.north west);
endtikzpicture
enddocument
answered Apr 16 at 5:44
NaveganTeXNaveganTeX
1,1192 silver badges13 bronze badges
1,1192 silver badges13 bronze badges
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%2f485078%2fproblem-drawing-boxes-with-arrows-in-tikz%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
1
You can use
local bounding box. Btw, your code is not even compilable– user156344
Apr 16 at 5:13