How to specify variable padding for tikz node text?
up vote
1
down vote
favorite
I have a custom tikz node with a design along the top and left side, and would like to center its text in the bottom-right section of the node. For example, I would like to center the text in section D
of the node, below:
+---+-----------+
| A | C |
+---+-----------+
| | |
| | |
| B | D |
| | |
| | |
+---+-----------+
Using the option, text centered
, causes it to be centered with respect to the whole shape, not just section D
. How may I center it with respect to the bounds of just D
? In HTML I could use the options, padding-left
and padding-top
, but I haven't been able to find comparable options for tikz nodes.
Edit: This is what I have so far:
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
RequirePackage{luatex85}
documentclass[tikz]{standalone}
usepackage{tikz}
usepackage{xcolor}
usepackage{makeshape}
usetikzlibrary{
automata,
shadows.blur,
}
makeatletter
defband{10pt}
definternalstorageAnchorpath{
pgf@xa=ctbnex
pgf@ya=ctbney
advancepgf@xa by band
advancepgf@ya by band
mincorrect{pgf@xa}{pgfshapeminwidth}
advancepgf@xapgfshapeouterxsep
mincorrect{pgf@ya}{pgfshapeminheight}
advancepgf@yapgfshapeouterysep
pgfpathmoveto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathclose
}
definternalstorageBackground{
pgf@xa=ctbnex
pgf@ya=ctbney
advancepgf@xa by band
advancepgf@ya by band
mincorrect{pgf@xa}{pgfshapeminwidth}
mincorrect{pgf@ya}{pgfshapeminheight}
pgfpathmoveto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathclose
advancepgf@xa by -band
pgfpathmoveto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
advancepgf@xa by band
advancepgf@ya by -band
pgfpathmoveto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{pgf@xa}{pgf@ya}}
}
pgfdeclareshape{internalstorage}{
setpaths{internalstorageAnchorpath}{internalstorageBackground}
savedanchor{northeast}{
pgf@x = ctbnex
advancepgf@x by band
mincorrect{pgf@x}{pgfshapeminwidth}
advancepgf@xpgfshapeouterxsep
pgf@y = ctbney
mincorrect{pgf@y}{pgfshapeminheight}
advancepgf@ypgfshapeouterysep
}
anchor{north}{ northeast pgf@x=0pt }
anchor{north east}{ northeast }
anchor{east}{ northeast pgf@y=0pt }
anchor{south east}{ northeast pgf@y=-pgf@y }
anchor{south}{ northeast pgf@x=0pt pgf@y=-pgf@y }
anchor{south west}{ northeast pgf@x=-pgf@x pgf@y=-pgf@y }
anchor{west}{ northeast pgf@x=-pgf@x pgf@y=0pt }
anchor{north west}{ northeast pgf@x=-pgf@x }
}
makeatother
begin{document}
begin{tikzpicture}[
>=stealth,
every state/.style={
font=small,
blur shadow,
thick,
},
internal storage/.style={
state,
internalstorage,
text width=5em,
text centered,
top color=BlueViolet!60,
bottom color=BlueViolet!20,
},
]
node[state, internal storage, text centered] {foo bar baz qux quux quo};
end{tikzpicture}
end{document}
The generated node looks like the following:
As you can see, the alignment of the text looks funny because it isn't centered with respect to the decorations.
tikz-pgf horizontal-alignment vertical-alignment
add a comment |
up vote
1
down vote
favorite
I have a custom tikz node with a design along the top and left side, and would like to center its text in the bottom-right section of the node. For example, I would like to center the text in section D
of the node, below:
+---+-----------+
| A | C |
+---+-----------+
| | |
| | |
| B | D |
| | |
| | |
+---+-----------+
Using the option, text centered
, causes it to be centered with respect to the whole shape, not just section D
. How may I center it with respect to the bounds of just D
? In HTML I could use the options, padding-left
and padding-top
, but I haven't been able to find comparable options for tikz nodes.
Edit: This is what I have so far:
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
RequirePackage{luatex85}
documentclass[tikz]{standalone}
usepackage{tikz}
usepackage{xcolor}
usepackage{makeshape}
usetikzlibrary{
automata,
shadows.blur,
}
makeatletter
defband{10pt}
definternalstorageAnchorpath{
pgf@xa=ctbnex
pgf@ya=ctbney
advancepgf@xa by band
advancepgf@ya by band
mincorrect{pgf@xa}{pgfshapeminwidth}
advancepgf@xapgfshapeouterxsep
mincorrect{pgf@ya}{pgfshapeminheight}
advancepgf@yapgfshapeouterysep
pgfpathmoveto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathclose
}
definternalstorageBackground{
pgf@xa=ctbnex
pgf@ya=ctbney
advancepgf@xa by band
advancepgf@ya by band
mincorrect{pgf@xa}{pgfshapeminwidth}
mincorrect{pgf@ya}{pgfshapeminheight}
pgfpathmoveto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathclose
advancepgf@xa by -band
pgfpathmoveto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
advancepgf@xa by band
advancepgf@ya by -band
pgfpathmoveto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{pgf@xa}{pgf@ya}}
}
pgfdeclareshape{internalstorage}{
setpaths{internalstorageAnchorpath}{internalstorageBackground}
savedanchor{northeast}{
pgf@x = ctbnex
advancepgf@x by band
mincorrect{pgf@x}{pgfshapeminwidth}
advancepgf@xpgfshapeouterxsep
pgf@y = ctbney
mincorrect{pgf@y}{pgfshapeminheight}
advancepgf@ypgfshapeouterysep
}
anchor{north}{ northeast pgf@x=0pt }
anchor{north east}{ northeast }
anchor{east}{ northeast pgf@y=0pt }
anchor{south east}{ northeast pgf@y=-pgf@y }
anchor{south}{ northeast pgf@x=0pt pgf@y=-pgf@y }
anchor{south west}{ northeast pgf@x=-pgf@x pgf@y=-pgf@y }
anchor{west}{ northeast pgf@x=-pgf@x pgf@y=0pt }
anchor{north west}{ northeast pgf@x=-pgf@x }
}
makeatother
begin{document}
begin{tikzpicture}[
>=stealth,
every state/.style={
font=small,
blur shadow,
thick,
},
internal storage/.style={
state,
internalstorage,
text width=5em,
text centered,
top color=BlueViolet!60,
bottom color=BlueViolet!20,
},
]
node[state, internal storage, text centered] {foo bar baz qux quux quo};
end{tikzpicture}
end{document}
The generated node looks like the following:
As you can see, the alignment of the text looks funny because it isn't centered with respect to the decorations.
tikz-pgf horizontal-alignment vertical-alignment
No, I'm trying to center text within a section of a custom node. As far as I know, the matrix library is only useful for aligning nodes with respect to each other.
– Dylon
Dec 3 at 23:51
With node labels, you can specifyshift
offsets. I'm looking for something equivalent for node contents.
– Dylon
Dec 3 at 23:52
1
Welcome to TeX.SX! What have you tried? Can you please post a minimal working example with your "custom code" so that we have something to work from. In additional to making it much easier for people to help you, a MWE will also help to clarify what you want. A MWE should compile and be as small as possible to demonstrate your problem.
– Andrew
Dec 3 at 23:54
Updated. Please review my post again.
– Dylon
Dec 4 at 0:29
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a custom tikz node with a design along the top and left side, and would like to center its text in the bottom-right section of the node. For example, I would like to center the text in section D
of the node, below:
+---+-----------+
| A | C |
+---+-----------+
| | |
| | |
| B | D |
| | |
| | |
+---+-----------+
Using the option, text centered
, causes it to be centered with respect to the whole shape, not just section D
. How may I center it with respect to the bounds of just D
? In HTML I could use the options, padding-left
and padding-top
, but I haven't been able to find comparable options for tikz nodes.
Edit: This is what I have so far:
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
RequirePackage{luatex85}
documentclass[tikz]{standalone}
usepackage{tikz}
usepackage{xcolor}
usepackage{makeshape}
usetikzlibrary{
automata,
shadows.blur,
}
makeatletter
defband{10pt}
definternalstorageAnchorpath{
pgf@xa=ctbnex
pgf@ya=ctbney
advancepgf@xa by band
advancepgf@ya by band
mincorrect{pgf@xa}{pgfshapeminwidth}
advancepgf@xapgfshapeouterxsep
mincorrect{pgf@ya}{pgfshapeminheight}
advancepgf@yapgfshapeouterysep
pgfpathmoveto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathclose
}
definternalstorageBackground{
pgf@xa=ctbnex
pgf@ya=ctbney
advancepgf@xa by band
advancepgf@ya by band
mincorrect{pgf@xa}{pgfshapeminwidth}
mincorrect{pgf@ya}{pgfshapeminheight}
pgfpathmoveto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathclose
advancepgf@xa by -band
pgfpathmoveto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
advancepgf@xa by band
advancepgf@ya by -band
pgfpathmoveto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{pgf@xa}{pgf@ya}}
}
pgfdeclareshape{internalstorage}{
setpaths{internalstorageAnchorpath}{internalstorageBackground}
savedanchor{northeast}{
pgf@x = ctbnex
advancepgf@x by band
mincorrect{pgf@x}{pgfshapeminwidth}
advancepgf@xpgfshapeouterxsep
pgf@y = ctbney
mincorrect{pgf@y}{pgfshapeminheight}
advancepgf@ypgfshapeouterysep
}
anchor{north}{ northeast pgf@x=0pt }
anchor{north east}{ northeast }
anchor{east}{ northeast pgf@y=0pt }
anchor{south east}{ northeast pgf@y=-pgf@y }
anchor{south}{ northeast pgf@x=0pt pgf@y=-pgf@y }
anchor{south west}{ northeast pgf@x=-pgf@x pgf@y=-pgf@y }
anchor{west}{ northeast pgf@x=-pgf@x pgf@y=0pt }
anchor{north west}{ northeast pgf@x=-pgf@x }
}
makeatother
begin{document}
begin{tikzpicture}[
>=stealth,
every state/.style={
font=small,
blur shadow,
thick,
},
internal storage/.style={
state,
internalstorage,
text width=5em,
text centered,
top color=BlueViolet!60,
bottom color=BlueViolet!20,
},
]
node[state, internal storage, text centered] {foo bar baz qux quux quo};
end{tikzpicture}
end{document}
The generated node looks like the following:
As you can see, the alignment of the text looks funny because it isn't centered with respect to the decorations.
tikz-pgf horizontal-alignment vertical-alignment
I have a custom tikz node with a design along the top and left side, and would like to center its text in the bottom-right section of the node. For example, I would like to center the text in section D
of the node, below:
+---+-----------+
| A | C |
+---+-----------+
| | |
| | |
| B | D |
| | |
| | |
+---+-----------+
Using the option, text centered
, causes it to be centered with respect to the whole shape, not just section D
. How may I center it with respect to the bounds of just D
? In HTML I could use the options, padding-left
and padding-top
, but I haven't been able to find comparable options for tikz nodes.
Edit: This is what I have so far:
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
RequirePackage{luatex85}
documentclass[tikz]{standalone}
usepackage{tikz}
usepackage{xcolor}
usepackage{makeshape}
usetikzlibrary{
automata,
shadows.blur,
}
makeatletter
defband{10pt}
definternalstorageAnchorpath{
pgf@xa=ctbnex
pgf@ya=ctbney
advancepgf@xa by band
advancepgf@ya by band
mincorrect{pgf@xa}{pgfshapeminwidth}
advancepgf@xapgfshapeouterxsep
mincorrect{pgf@ya}{pgfshapeminheight}
advancepgf@yapgfshapeouterysep
pgfpathmoveto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathclose
}
definternalstorageBackground{
pgf@xa=ctbnex
pgf@ya=ctbney
advancepgf@xa by band
advancepgf@ya by band
mincorrect{pgf@xa}{pgfshapeminwidth}
mincorrect{pgf@ya}{pgfshapeminheight}
pgfpathmoveto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathclose
advancepgf@xa by -band
pgfpathmoveto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
advancepgf@xa by band
advancepgf@ya by -band
pgfpathmoveto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{pgf@xa}{pgf@ya}}
}
pgfdeclareshape{internalstorage}{
setpaths{internalstorageAnchorpath}{internalstorageBackground}
savedanchor{northeast}{
pgf@x = ctbnex
advancepgf@x by band
mincorrect{pgf@x}{pgfshapeminwidth}
advancepgf@xpgfshapeouterxsep
pgf@y = ctbney
mincorrect{pgf@y}{pgfshapeminheight}
advancepgf@ypgfshapeouterysep
}
anchor{north}{ northeast pgf@x=0pt }
anchor{north east}{ northeast }
anchor{east}{ northeast pgf@y=0pt }
anchor{south east}{ northeast pgf@y=-pgf@y }
anchor{south}{ northeast pgf@x=0pt pgf@y=-pgf@y }
anchor{south west}{ northeast pgf@x=-pgf@x pgf@y=-pgf@y }
anchor{west}{ northeast pgf@x=-pgf@x pgf@y=0pt }
anchor{north west}{ northeast pgf@x=-pgf@x }
}
makeatother
begin{document}
begin{tikzpicture}[
>=stealth,
every state/.style={
font=small,
blur shadow,
thick,
},
internal storage/.style={
state,
internalstorage,
text width=5em,
text centered,
top color=BlueViolet!60,
bottom color=BlueViolet!20,
},
]
node[state, internal storage, text centered] {foo bar baz qux quux quo};
end{tikzpicture}
end{document}
The generated node looks like the following:
As you can see, the alignment of the text looks funny because it isn't centered with respect to the decorations.
tikz-pgf horizontal-alignment vertical-alignment
tikz-pgf horizontal-alignment vertical-alignment
edited Dec 4 at 0:28
asked Dec 3 at 23:41
Dylon
1207
1207
No, I'm trying to center text within a section of a custom node. As far as I know, the matrix library is only useful for aligning nodes with respect to each other.
– Dylon
Dec 3 at 23:51
With node labels, you can specifyshift
offsets. I'm looking for something equivalent for node contents.
– Dylon
Dec 3 at 23:52
1
Welcome to TeX.SX! What have you tried? Can you please post a minimal working example with your "custom code" so that we have something to work from. In additional to making it much easier for people to help you, a MWE will also help to clarify what you want. A MWE should compile and be as small as possible to demonstrate your problem.
– Andrew
Dec 3 at 23:54
Updated. Please review my post again.
– Dylon
Dec 4 at 0:29
add a comment |
No, I'm trying to center text within a section of a custom node. As far as I know, the matrix library is only useful for aligning nodes with respect to each other.
– Dylon
Dec 3 at 23:51
With node labels, you can specifyshift
offsets. I'm looking for something equivalent for node contents.
– Dylon
Dec 3 at 23:52
1
Welcome to TeX.SX! What have you tried? Can you please post a minimal working example with your "custom code" so that we have something to work from. In additional to making it much easier for people to help you, a MWE will also help to clarify what you want. A MWE should compile and be as small as possible to demonstrate your problem.
– Andrew
Dec 3 at 23:54
Updated. Please review my post again.
– Dylon
Dec 4 at 0:29
No, I'm trying to center text within a section of a custom node. As far as I know, the matrix library is only useful for aligning nodes with respect to each other.
– Dylon
Dec 3 at 23:51
No, I'm trying to center text within a section of a custom node. As far as I know, the matrix library is only useful for aligning nodes with respect to each other.
– Dylon
Dec 3 at 23:51
With node labels, you can specify
shift
offsets. I'm looking for something equivalent for node contents.– Dylon
Dec 3 at 23:52
With node labels, you can specify
shift
offsets. I'm looking for something equivalent for node contents.– Dylon
Dec 3 at 23:52
1
1
Welcome to TeX.SX! What have you tried? Can you please post a minimal working example with your "custom code" so that we have something to work from. In additional to making it much easier for people to help you, a MWE will also help to clarify what you want. A MWE should compile and be as small as possible to demonstrate your problem.
– Andrew
Dec 3 at 23:54
Welcome to TeX.SX! What have you tried? Can you please post a minimal working example with your "custom code" so that we have something to work from. In additional to making it much easier for people to help you, a MWE will also help to clarify what you want. A MWE should compile and be as small as possible to demonstrate your problem.
– Andrew
Dec 3 at 23:54
Updated. Please review my post again.
– Dylon
Dec 4 at 0:29
Updated. Please review my post again.
– Dylon
Dec 4 at 0:29
add a comment |
3 Answers
3
active
oldest
votes
up vote
1
down vote
accepted
You could draw internalstorage
node as a regular one, but place its contents using a label
node on its lower right corner. If you fixes label's size and outer node's size and know the difference between them, you can draw internal lines with path picture
options which survives to a fill
option. These nodes are compatible with matrix
.
This is an example:
documentclass[tikz,border=2mm]{standalone}
usetikzlibrary{positioning}
begin{document}
begin{tikzpicture}[%
internalstorage/.style={%
minimum size=2.5cm,
draw,
thick,
text width=5em,
top color=purple!60,
bottom color=purple!20,
label={[minimum size=2cm,
text width=5em,
font=small,
text centered,
anchor=south east]
south east:#1
},
path picture={
draw ([xshift=5mm]path picture bounding box.south west)--([xshift=5mm]path picture bounding box.north west);
draw ([yshift=-5mm]path picture bounding box.north west)--([yshift=-5mm]path picture bounding box.north east);
}
}
]
matrix[row sep=1mm, column sep=1mm] (a) {
node[internalstorage=foo bar baz qux quux quo] {};
&
node[internalstorage=foo] {};
\
node[internalstorage=foo bar baz] {};
&
node[internalstorage=foo bar baz qux quux] {};
\
};
end{tikzpicture}
end{document}
This looks amazing, but I cannot get your example to work. If I remove the styling on the label it works but the label is then placed on the outside of the node to the south east. Do you have a special set up that lets it work?
– Dylon
Dec 4 at 11:02
@Dylon I'm not sure to understand the problem. The styling on the label makes it works, you need to place south east anchor of label on south east anchor of main node to obtain the special alignment. What do you want to avoid from label style?
– Ignasi
Dec 4 at 11:17
I figured it out: I placed a newline between the opening square bracket in the label style andminimum size
, which caused the parser to err. Removing it resolved the issue. This is great, thanks!
– Dylon
Dec 4 at 11:21
add a comment |
up vote
1
down vote
Congratulations to your nice example! But I still keep advertizing matrix
.
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix,calc}
begin{document}
begin{tikzpicture}[row 1 column 1/.style={align=left},
row 1 column 2/.style={align=right,text width=4em},
row 2 column 1/.style={align=left},
row 2 column 2/.style={text centered,text width=5em},
every node/.append style={draw},column sep=-pgflinewidth,row
sep=-pgflinewidth,]
matrix[matrix of nodes,draw,top color=BlueViolet!60,
bottom color=BlueViolet!20,inner sep=0pt,nodes={draw=none,inner sep=4pt}] (mat)
{
A & B\
C & foo bar baz qux quux quo\
};
path ($(mat-1-1.east)!0.5!(mat-1-2.west)$) coordinate (aux1)
($(mat-1-1.south)!0.5!(mat-2-1.north)$) coordinate (aux2);
draw (mat.north -| aux1) -- (mat.south -| aux1)
(mat.west |- aux2) -- (mat.east |- aux2) ;
end{tikzpicture}
end{document}
This is a quick attempt to define a style. My first attempt to draw the separator lines with append after command
did not succeed, so I added a command for that (temporarily).
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix,calc}
begin{document}
tikzset{fancy matrix/.style={row 1 column 1/.style={align=left},
row 1 column 2/.style={align=right,text width=4em},
row 2 column 1/.style={align=left},
row 2 column 2/.style={text centered,text width=5em},
matrix of nodes,draw,top color=BlueViolet!60,
bottom color=BlueViolet!20,inner sep=0pt,nodes={draw=none,inner sep=4pt},
append after command={}
}}
newcommand{DrawMatrixSeparators}[2]{
draw[#1] ($(#2-1-1.east)!0.5!(#2-1-2.west)$) coordinate (aux1)
($(#2-1-1.south)!0.5!(#2-2-1.north)$) coordinate (aux2)
(#2.north -| aux1) -- (#2.south -| aux1)
(#2.west |- aux2) -- (#2.east |- aux2);}
begin{tikzpicture}
matrix[fancy matrix] (mat)
{
A & B\
C & foo bar baz qux quux quo\
};
DrawMatrixSeparators{mat}
end{tikzpicture}
end{document}
I don't have a problem with node alignment, but text alignment within a node.
– Dylon
Dec 4 at 0:30
Please review my original post again. I've updated it with more information.
– Dylon
Dec 4 at 0:40
Is thefoo...
text centered in the lower right area? Looks like closer to left margin than right one.
– Sigur
Dec 4 at 0:48
@Sigur Yes, there was an asymmetry cause by theinner sep
of the ambient matrix node. I was actually already fixing this when I saw your comment, but yes, good catch thanks!
– marmot
Dec 4 at 0:50
The "internal storage" node is for a flowchart, is there a way I can draw it using a matrix internally? I'd like to reuse it in other places.
– Dylon
Dec 4 at 0:52
|
show 3 more comments
up vote
0
down vote
This works, but isn't perfect. I'll revise it as I strengthen my tikz fu.
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
RequirePackage{luatex85}
documentclass[tikz]{standalone}
usepackage{tikz}
usepackage{makeshape}
usepackage{xcolor}
usetikzlibrary{
automata,
matrix,
shadows.blur,
}
begin{document}
defpadding{10pt}
makeatletter
definternalStorageAnchorPath{
pgf@xa=ctbnex
pgf@ya=ctbney
mincorrect{pgf@xa}{pgfshapeminwidth}
advancepgf@xapgfshapeouterxsep
mincorrect{pgf@ya}{pgfshapeminheight}
advancepgf@yapgfshapeouterysep
pgfpathmoveto{pgfpoint{pgf@xa}{-pgf@ya}}
advancepgf@xa by padding
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
advancepgf@ya by padding
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
advancepgf@xa by -padding
pgfpathlineto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathclose
}
definternalStorageBackgroundPath{
pgf@xa=ctbnex
pgf@ya=ctbney
mincorrect{pgf@xa}{pgfshapeminwidth}
mincorrect{pgf@ya}{pgfshapeminheight}
pgfpathmoveto{pgfpoint{pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathclose
}
pgfdeclareshape{internalstorage}{
setpaths{internalStorageAnchorPath}{internalStorageBackgroundPath}
savedanchor{northeast}{
pgf@x = ctbnex
mincorrect{pgf@x}{pgfshapeminwidth}
advancepgf@xpgfshapeouterxsep
pgf@y = ctbney
mincorrect{pgf@y}{pgfshapeminheight}
advancepgf@ypgfshapeouterysep
}
anchor{south east}{northeast pgf@y=-pgf@y}
anchor{south}{northeast pgf@x=0pt pgf@y=-pgf@y}
anchor{south west}{northeast pgf@x=-pgf@x pgf@y=-pgf@y}
anchor{west}{northeast pgf@x=-pgf@x pgf@y=0pt}
anchor{north west}{northeast pgf@x=-pgf@x}
anchor{north}{northeast pgf@x=0pt}
anchor{north east}{northeast}
anchor{east}{northeast pgf@y=0pt}
}
makeatother
begin{tikzpicture}[
>=stealth,
every state/.style={
font=small,
blur shadow,
thick,
},
every edge/.append style={
->,
thick,
},
process/.style={
state,
rectangle,
text width=10em,
text centered,
rounded corners,
top color=orange!60,
bottom color=orange!20,
},
internal storage/.style={
state,
internalstorage,
draw=none,
blur shadow={
shadow opacity=0
},
font=small,
text width=5em,
text centered,
append after command={
pgfextra{
draw[
thick,
blur shadow,
top color=BlueViolet!60,
bottom color=BlueViolet!20
] (tikzlastnode.south east)
-- ( $(tikzlastnode.south west) + (-padding, 0)$ )
-- ( $(tikzlastnode.north west) + (-padding, padding)$ )
-- ( $(tikzlastnode.north east) + (0, padding)$ )
-- cycle;
draw[thick] ( $(tikzlastnode.north west) + (-padding, 0)$ )
-- (tikzlastnode.north east);
draw[thick] ( $(tikzlastnode.north west) + (0, padding)$ )
-- (tikzlastnode.south west);
}
},
},
]
matrix (m)[matrix of nodes, column sep=8mm, row sep=6.5mm, align=center, nodes={rectangle, draw, anchor=center}]{
|[process]| {north west} & |[process]| {north } & |[process]| {north east} \
|[process]| {west } & |[internal storage]| {Internal Storage} & |[process]| {east } \
|[process]| {south west} & |[process]| {south } & |[process]| {south east} \
};
draw (m-1-1) edge (m-2-2);
draw (m-1-2) edge (m-2-2);
draw (m-1-3) edge (m-2-2);
draw (m-2-3) edge (m-2-2);
draw (m-3-3) edge (m-2-2);
draw (m-3-2) edge (m-2-2);
draw (m-3-1) edge (m-2-2);
draw (m-2-1) edge (m-2-2);
end{tikzpicture}
end{document}
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You could draw internalstorage
node as a regular one, but place its contents using a label
node on its lower right corner. If you fixes label's size and outer node's size and know the difference between them, you can draw internal lines with path picture
options which survives to a fill
option. These nodes are compatible with matrix
.
This is an example:
documentclass[tikz,border=2mm]{standalone}
usetikzlibrary{positioning}
begin{document}
begin{tikzpicture}[%
internalstorage/.style={%
minimum size=2.5cm,
draw,
thick,
text width=5em,
top color=purple!60,
bottom color=purple!20,
label={[minimum size=2cm,
text width=5em,
font=small,
text centered,
anchor=south east]
south east:#1
},
path picture={
draw ([xshift=5mm]path picture bounding box.south west)--([xshift=5mm]path picture bounding box.north west);
draw ([yshift=-5mm]path picture bounding box.north west)--([yshift=-5mm]path picture bounding box.north east);
}
}
]
matrix[row sep=1mm, column sep=1mm] (a) {
node[internalstorage=foo bar baz qux quux quo] {};
&
node[internalstorage=foo] {};
\
node[internalstorage=foo bar baz] {};
&
node[internalstorage=foo bar baz qux quux] {};
\
};
end{tikzpicture}
end{document}
This looks amazing, but I cannot get your example to work. If I remove the styling on the label it works but the label is then placed on the outside of the node to the south east. Do you have a special set up that lets it work?
– Dylon
Dec 4 at 11:02
@Dylon I'm not sure to understand the problem. The styling on the label makes it works, you need to place south east anchor of label on south east anchor of main node to obtain the special alignment. What do you want to avoid from label style?
– Ignasi
Dec 4 at 11:17
I figured it out: I placed a newline between the opening square bracket in the label style andminimum size
, which caused the parser to err. Removing it resolved the issue. This is great, thanks!
– Dylon
Dec 4 at 11:21
add a comment |
up vote
1
down vote
accepted
You could draw internalstorage
node as a regular one, but place its contents using a label
node on its lower right corner. If you fixes label's size and outer node's size and know the difference between them, you can draw internal lines with path picture
options which survives to a fill
option. These nodes are compatible with matrix
.
This is an example:
documentclass[tikz,border=2mm]{standalone}
usetikzlibrary{positioning}
begin{document}
begin{tikzpicture}[%
internalstorage/.style={%
minimum size=2.5cm,
draw,
thick,
text width=5em,
top color=purple!60,
bottom color=purple!20,
label={[minimum size=2cm,
text width=5em,
font=small,
text centered,
anchor=south east]
south east:#1
},
path picture={
draw ([xshift=5mm]path picture bounding box.south west)--([xshift=5mm]path picture bounding box.north west);
draw ([yshift=-5mm]path picture bounding box.north west)--([yshift=-5mm]path picture bounding box.north east);
}
}
]
matrix[row sep=1mm, column sep=1mm] (a) {
node[internalstorage=foo bar baz qux quux quo] {};
&
node[internalstorage=foo] {};
\
node[internalstorage=foo bar baz] {};
&
node[internalstorage=foo bar baz qux quux] {};
\
};
end{tikzpicture}
end{document}
This looks amazing, but I cannot get your example to work. If I remove the styling on the label it works but the label is then placed on the outside of the node to the south east. Do you have a special set up that lets it work?
– Dylon
Dec 4 at 11:02
@Dylon I'm not sure to understand the problem. The styling on the label makes it works, you need to place south east anchor of label on south east anchor of main node to obtain the special alignment. What do you want to avoid from label style?
– Ignasi
Dec 4 at 11:17
I figured it out: I placed a newline between the opening square bracket in the label style andminimum size
, which caused the parser to err. Removing it resolved the issue. This is great, thanks!
– Dylon
Dec 4 at 11:21
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You could draw internalstorage
node as a regular one, but place its contents using a label
node on its lower right corner. If you fixes label's size and outer node's size and know the difference between them, you can draw internal lines with path picture
options which survives to a fill
option. These nodes are compatible with matrix
.
This is an example:
documentclass[tikz,border=2mm]{standalone}
usetikzlibrary{positioning}
begin{document}
begin{tikzpicture}[%
internalstorage/.style={%
minimum size=2.5cm,
draw,
thick,
text width=5em,
top color=purple!60,
bottom color=purple!20,
label={[minimum size=2cm,
text width=5em,
font=small,
text centered,
anchor=south east]
south east:#1
},
path picture={
draw ([xshift=5mm]path picture bounding box.south west)--([xshift=5mm]path picture bounding box.north west);
draw ([yshift=-5mm]path picture bounding box.north west)--([yshift=-5mm]path picture bounding box.north east);
}
}
]
matrix[row sep=1mm, column sep=1mm] (a) {
node[internalstorage=foo bar baz qux quux quo] {};
&
node[internalstorage=foo] {};
\
node[internalstorage=foo bar baz] {};
&
node[internalstorage=foo bar baz qux quux] {};
\
};
end{tikzpicture}
end{document}
You could draw internalstorage
node as a regular one, but place its contents using a label
node on its lower right corner. If you fixes label's size and outer node's size and know the difference between them, you can draw internal lines with path picture
options which survives to a fill
option. These nodes are compatible with matrix
.
This is an example:
documentclass[tikz,border=2mm]{standalone}
usetikzlibrary{positioning}
begin{document}
begin{tikzpicture}[%
internalstorage/.style={%
minimum size=2.5cm,
draw,
thick,
text width=5em,
top color=purple!60,
bottom color=purple!20,
label={[minimum size=2cm,
text width=5em,
font=small,
text centered,
anchor=south east]
south east:#1
},
path picture={
draw ([xshift=5mm]path picture bounding box.south west)--([xshift=5mm]path picture bounding box.north west);
draw ([yshift=-5mm]path picture bounding box.north west)--([yshift=-5mm]path picture bounding box.north east);
}
}
]
matrix[row sep=1mm, column sep=1mm] (a) {
node[internalstorage=foo bar baz qux quux quo] {};
&
node[internalstorage=foo] {};
\
node[internalstorage=foo bar baz] {};
&
node[internalstorage=foo bar baz qux quux] {};
\
};
end{tikzpicture}
end{document}
answered Dec 4 at 9:50
Ignasi
90.8k4164303
90.8k4164303
This looks amazing, but I cannot get your example to work. If I remove the styling on the label it works but the label is then placed on the outside of the node to the south east. Do you have a special set up that lets it work?
– Dylon
Dec 4 at 11:02
@Dylon I'm not sure to understand the problem. The styling on the label makes it works, you need to place south east anchor of label on south east anchor of main node to obtain the special alignment. What do you want to avoid from label style?
– Ignasi
Dec 4 at 11:17
I figured it out: I placed a newline between the opening square bracket in the label style andminimum size
, which caused the parser to err. Removing it resolved the issue. This is great, thanks!
– Dylon
Dec 4 at 11:21
add a comment |
This looks amazing, but I cannot get your example to work. If I remove the styling on the label it works but the label is then placed on the outside of the node to the south east. Do you have a special set up that lets it work?
– Dylon
Dec 4 at 11:02
@Dylon I'm not sure to understand the problem. The styling on the label makes it works, you need to place south east anchor of label on south east anchor of main node to obtain the special alignment. What do you want to avoid from label style?
– Ignasi
Dec 4 at 11:17
I figured it out: I placed a newline between the opening square bracket in the label style andminimum size
, which caused the parser to err. Removing it resolved the issue. This is great, thanks!
– Dylon
Dec 4 at 11:21
This looks amazing, but I cannot get your example to work. If I remove the styling on the label it works but the label is then placed on the outside of the node to the south east. Do you have a special set up that lets it work?
– Dylon
Dec 4 at 11:02
This looks amazing, but I cannot get your example to work. If I remove the styling on the label it works but the label is then placed on the outside of the node to the south east. Do you have a special set up that lets it work?
– Dylon
Dec 4 at 11:02
@Dylon I'm not sure to understand the problem. The styling on the label makes it works, you need to place south east anchor of label on south east anchor of main node to obtain the special alignment. What do you want to avoid from label style?
– Ignasi
Dec 4 at 11:17
@Dylon I'm not sure to understand the problem. The styling on the label makes it works, you need to place south east anchor of label on south east anchor of main node to obtain the special alignment. What do you want to avoid from label style?
– Ignasi
Dec 4 at 11:17
I figured it out: I placed a newline between the opening square bracket in the label style and
minimum size
, which caused the parser to err. Removing it resolved the issue. This is great, thanks!– Dylon
Dec 4 at 11:21
I figured it out: I placed a newline between the opening square bracket in the label style and
minimum size
, which caused the parser to err. Removing it resolved the issue. This is great, thanks!– Dylon
Dec 4 at 11:21
add a comment |
up vote
1
down vote
Congratulations to your nice example! But I still keep advertizing matrix
.
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix,calc}
begin{document}
begin{tikzpicture}[row 1 column 1/.style={align=left},
row 1 column 2/.style={align=right,text width=4em},
row 2 column 1/.style={align=left},
row 2 column 2/.style={text centered,text width=5em},
every node/.append style={draw},column sep=-pgflinewidth,row
sep=-pgflinewidth,]
matrix[matrix of nodes,draw,top color=BlueViolet!60,
bottom color=BlueViolet!20,inner sep=0pt,nodes={draw=none,inner sep=4pt}] (mat)
{
A & B\
C & foo bar baz qux quux quo\
};
path ($(mat-1-1.east)!0.5!(mat-1-2.west)$) coordinate (aux1)
($(mat-1-1.south)!0.5!(mat-2-1.north)$) coordinate (aux2);
draw (mat.north -| aux1) -- (mat.south -| aux1)
(mat.west |- aux2) -- (mat.east |- aux2) ;
end{tikzpicture}
end{document}
This is a quick attempt to define a style. My first attempt to draw the separator lines with append after command
did not succeed, so I added a command for that (temporarily).
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix,calc}
begin{document}
tikzset{fancy matrix/.style={row 1 column 1/.style={align=left},
row 1 column 2/.style={align=right,text width=4em},
row 2 column 1/.style={align=left},
row 2 column 2/.style={text centered,text width=5em},
matrix of nodes,draw,top color=BlueViolet!60,
bottom color=BlueViolet!20,inner sep=0pt,nodes={draw=none,inner sep=4pt},
append after command={}
}}
newcommand{DrawMatrixSeparators}[2]{
draw[#1] ($(#2-1-1.east)!0.5!(#2-1-2.west)$) coordinate (aux1)
($(#2-1-1.south)!0.5!(#2-2-1.north)$) coordinate (aux2)
(#2.north -| aux1) -- (#2.south -| aux1)
(#2.west |- aux2) -- (#2.east |- aux2);}
begin{tikzpicture}
matrix[fancy matrix] (mat)
{
A & B\
C & foo bar baz qux quux quo\
};
DrawMatrixSeparators{mat}
end{tikzpicture}
end{document}
I don't have a problem with node alignment, but text alignment within a node.
– Dylon
Dec 4 at 0:30
Please review my original post again. I've updated it with more information.
– Dylon
Dec 4 at 0:40
Is thefoo...
text centered in the lower right area? Looks like closer to left margin than right one.
– Sigur
Dec 4 at 0:48
@Sigur Yes, there was an asymmetry cause by theinner sep
of the ambient matrix node. I was actually already fixing this when I saw your comment, but yes, good catch thanks!
– marmot
Dec 4 at 0:50
The "internal storage" node is for a flowchart, is there a way I can draw it using a matrix internally? I'd like to reuse it in other places.
– Dylon
Dec 4 at 0:52
|
show 3 more comments
up vote
1
down vote
Congratulations to your nice example! But I still keep advertizing matrix
.
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix,calc}
begin{document}
begin{tikzpicture}[row 1 column 1/.style={align=left},
row 1 column 2/.style={align=right,text width=4em},
row 2 column 1/.style={align=left},
row 2 column 2/.style={text centered,text width=5em},
every node/.append style={draw},column sep=-pgflinewidth,row
sep=-pgflinewidth,]
matrix[matrix of nodes,draw,top color=BlueViolet!60,
bottom color=BlueViolet!20,inner sep=0pt,nodes={draw=none,inner sep=4pt}] (mat)
{
A & B\
C & foo bar baz qux quux quo\
};
path ($(mat-1-1.east)!0.5!(mat-1-2.west)$) coordinate (aux1)
($(mat-1-1.south)!0.5!(mat-2-1.north)$) coordinate (aux2);
draw (mat.north -| aux1) -- (mat.south -| aux1)
(mat.west |- aux2) -- (mat.east |- aux2) ;
end{tikzpicture}
end{document}
This is a quick attempt to define a style. My first attempt to draw the separator lines with append after command
did not succeed, so I added a command for that (temporarily).
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix,calc}
begin{document}
tikzset{fancy matrix/.style={row 1 column 1/.style={align=left},
row 1 column 2/.style={align=right,text width=4em},
row 2 column 1/.style={align=left},
row 2 column 2/.style={text centered,text width=5em},
matrix of nodes,draw,top color=BlueViolet!60,
bottom color=BlueViolet!20,inner sep=0pt,nodes={draw=none,inner sep=4pt},
append after command={}
}}
newcommand{DrawMatrixSeparators}[2]{
draw[#1] ($(#2-1-1.east)!0.5!(#2-1-2.west)$) coordinate (aux1)
($(#2-1-1.south)!0.5!(#2-2-1.north)$) coordinate (aux2)
(#2.north -| aux1) -- (#2.south -| aux1)
(#2.west |- aux2) -- (#2.east |- aux2);}
begin{tikzpicture}
matrix[fancy matrix] (mat)
{
A & B\
C & foo bar baz qux quux quo\
};
DrawMatrixSeparators{mat}
end{tikzpicture}
end{document}
I don't have a problem with node alignment, but text alignment within a node.
– Dylon
Dec 4 at 0:30
Please review my original post again. I've updated it with more information.
– Dylon
Dec 4 at 0:40
Is thefoo...
text centered in the lower right area? Looks like closer to left margin than right one.
– Sigur
Dec 4 at 0:48
@Sigur Yes, there was an asymmetry cause by theinner sep
of the ambient matrix node. I was actually already fixing this when I saw your comment, but yes, good catch thanks!
– marmot
Dec 4 at 0:50
The "internal storage" node is for a flowchart, is there a way I can draw it using a matrix internally? I'd like to reuse it in other places.
– Dylon
Dec 4 at 0:52
|
show 3 more comments
up vote
1
down vote
up vote
1
down vote
Congratulations to your nice example! But I still keep advertizing matrix
.
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix,calc}
begin{document}
begin{tikzpicture}[row 1 column 1/.style={align=left},
row 1 column 2/.style={align=right,text width=4em},
row 2 column 1/.style={align=left},
row 2 column 2/.style={text centered,text width=5em},
every node/.append style={draw},column sep=-pgflinewidth,row
sep=-pgflinewidth,]
matrix[matrix of nodes,draw,top color=BlueViolet!60,
bottom color=BlueViolet!20,inner sep=0pt,nodes={draw=none,inner sep=4pt}] (mat)
{
A & B\
C & foo bar baz qux quux quo\
};
path ($(mat-1-1.east)!0.5!(mat-1-2.west)$) coordinate (aux1)
($(mat-1-1.south)!0.5!(mat-2-1.north)$) coordinate (aux2);
draw (mat.north -| aux1) -- (mat.south -| aux1)
(mat.west |- aux2) -- (mat.east |- aux2) ;
end{tikzpicture}
end{document}
This is a quick attempt to define a style. My first attempt to draw the separator lines with append after command
did not succeed, so I added a command for that (temporarily).
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix,calc}
begin{document}
tikzset{fancy matrix/.style={row 1 column 1/.style={align=left},
row 1 column 2/.style={align=right,text width=4em},
row 2 column 1/.style={align=left},
row 2 column 2/.style={text centered,text width=5em},
matrix of nodes,draw,top color=BlueViolet!60,
bottom color=BlueViolet!20,inner sep=0pt,nodes={draw=none,inner sep=4pt},
append after command={}
}}
newcommand{DrawMatrixSeparators}[2]{
draw[#1] ($(#2-1-1.east)!0.5!(#2-1-2.west)$) coordinate (aux1)
($(#2-1-1.south)!0.5!(#2-2-1.north)$) coordinate (aux2)
(#2.north -| aux1) -- (#2.south -| aux1)
(#2.west |- aux2) -- (#2.east |- aux2);}
begin{tikzpicture}
matrix[fancy matrix] (mat)
{
A & B\
C & foo bar baz qux quux quo\
};
DrawMatrixSeparators{mat}
end{tikzpicture}
end{document}
Congratulations to your nice example! But I still keep advertizing matrix
.
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix,calc}
begin{document}
begin{tikzpicture}[row 1 column 1/.style={align=left},
row 1 column 2/.style={align=right,text width=4em},
row 2 column 1/.style={align=left},
row 2 column 2/.style={text centered,text width=5em},
every node/.append style={draw},column sep=-pgflinewidth,row
sep=-pgflinewidth,]
matrix[matrix of nodes,draw,top color=BlueViolet!60,
bottom color=BlueViolet!20,inner sep=0pt,nodes={draw=none,inner sep=4pt}] (mat)
{
A & B\
C & foo bar baz qux quux quo\
};
path ($(mat-1-1.east)!0.5!(mat-1-2.west)$) coordinate (aux1)
($(mat-1-1.south)!0.5!(mat-2-1.north)$) coordinate (aux2);
draw (mat.north -| aux1) -- (mat.south -| aux1)
(mat.west |- aux2) -- (mat.east |- aux2) ;
end{tikzpicture}
end{document}
This is a quick attempt to define a style. My first attempt to draw the separator lines with append after command
did not succeed, so I added a command for that (temporarily).
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix,calc}
begin{document}
tikzset{fancy matrix/.style={row 1 column 1/.style={align=left},
row 1 column 2/.style={align=right,text width=4em},
row 2 column 1/.style={align=left},
row 2 column 2/.style={text centered,text width=5em},
matrix of nodes,draw,top color=BlueViolet!60,
bottom color=BlueViolet!20,inner sep=0pt,nodes={draw=none,inner sep=4pt},
append after command={}
}}
newcommand{DrawMatrixSeparators}[2]{
draw[#1] ($(#2-1-1.east)!0.5!(#2-1-2.west)$) coordinate (aux1)
($(#2-1-1.south)!0.5!(#2-2-1.north)$) coordinate (aux2)
(#2.north -| aux1) -- (#2.south -| aux1)
(#2.west |- aux2) -- (#2.east |- aux2);}
begin{tikzpicture}
matrix[fancy matrix] (mat)
{
A & B\
C & foo bar baz qux quux quo\
};
DrawMatrixSeparators{mat}
end{tikzpicture}
end{document}
edited Dec 4 at 1:05
answered Dec 3 at 23:56
marmot
82.3k492175
82.3k492175
I don't have a problem with node alignment, but text alignment within a node.
– Dylon
Dec 4 at 0:30
Please review my original post again. I've updated it with more information.
– Dylon
Dec 4 at 0:40
Is thefoo...
text centered in the lower right area? Looks like closer to left margin than right one.
– Sigur
Dec 4 at 0:48
@Sigur Yes, there was an asymmetry cause by theinner sep
of the ambient matrix node. I was actually already fixing this when I saw your comment, but yes, good catch thanks!
– marmot
Dec 4 at 0:50
The "internal storage" node is for a flowchart, is there a way I can draw it using a matrix internally? I'd like to reuse it in other places.
– Dylon
Dec 4 at 0:52
|
show 3 more comments
I don't have a problem with node alignment, but text alignment within a node.
– Dylon
Dec 4 at 0:30
Please review my original post again. I've updated it with more information.
– Dylon
Dec 4 at 0:40
Is thefoo...
text centered in the lower right area? Looks like closer to left margin than right one.
– Sigur
Dec 4 at 0:48
@Sigur Yes, there was an asymmetry cause by theinner sep
of the ambient matrix node. I was actually already fixing this when I saw your comment, but yes, good catch thanks!
– marmot
Dec 4 at 0:50
The "internal storage" node is for a flowchart, is there a way I can draw it using a matrix internally? I'd like to reuse it in other places.
– Dylon
Dec 4 at 0:52
I don't have a problem with node alignment, but text alignment within a node.
– Dylon
Dec 4 at 0:30
I don't have a problem with node alignment, but text alignment within a node.
– Dylon
Dec 4 at 0:30
Please review my original post again. I've updated it with more information.
– Dylon
Dec 4 at 0:40
Please review my original post again. I've updated it with more information.
– Dylon
Dec 4 at 0:40
Is the
foo...
text centered in the lower right area? Looks like closer to left margin than right one.– Sigur
Dec 4 at 0:48
Is the
foo...
text centered in the lower right area? Looks like closer to left margin than right one.– Sigur
Dec 4 at 0:48
@Sigur Yes, there was an asymmetry cause by the
inner sep
of the ambient matrix node. I was actually already fixing this when I saw your comment, but yes, good catch thanks!– marmot
Dec 4 at 0:50
@Sigur Yes, there was an asymmetry cause by the
inner sep
of the ambient matrix node. I was actually already fixing this when I saw your comment, but yes, good catch thanks!– marmot
Dec 4 at 0:50
The "internal storage" node is for a flowchart, is there a way I can draw it using a matrix internally? I'd like to reuse it in other places.
– Dylon
Dec 4 at 0:52
The "internal storage" node is for a flowchart, is there a way I can draw it using a matrix internally? I'd like to reuse it in other places.
– Dylon
Dec 4 at 0:52
|
show 3 more comments
up vote
0
down vote
This works, but isn't perfect. I'll revise it as I strengthen my tikz fu.
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
RequirePackage{luatex85}
documentclass[tikz]{standalone}
usepackage{tikz}
usepackage{makeshape}
usepackage{xcolor}
usetikzlibrary{
automata,
matrix,
shadows.blur,
}
begin{document}
defpadding{10pt}
makeatletter
definternalStorageAnchorPath{
pgf@xa=ctbnex
pgf@ya=ctbney
mincorrect{pgf@xa}{pgfshapeminwidth}
advancepgf@xapgfshapeouterxsep
mincorrect{pgf@ya}{pgfshapeminheight}
advancepgf@yapgfshapeouterysep
pgfpathmoveto{pgfpoint{pgf@xa}{-pgf@ya}}
advancepgf@xa by padding
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
advancepgf@ya by padding
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
advancepgf@xa by -padding
pgfpathlineto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathclose
}
definternalStorageBackgroundPath{
pgf@xa=ctbnex
pgf@ya=ctbney
mincorrect{pgf@xa}{pgfshapeminwidth}
mincorrect{pgf@ya}{pgfshapeminheight}
pgfpathmoveto{pgfpoint{pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathclose
}
pgfdeclareshape{internalstorage}{
setpaths{internalStorageAnchorPath}{internalStorageBackgroundPath}
savedanchor{northeast}{
pgf@x = ctbnex
mincorrect{pgf@x}{pgfshapeminwidth}
advancepgf@xpgfshapeouterxsep
pgf@y = ctbney
mincorrect{pgf@y}{pgfshapeminheight}
advancepgf@ypgfshapeouterysep
}
anchor{south east}{northeast pgf@y=-pgf@y}
anchor{south}{northeast pgf@x=0pt pgf@y=-pgf@y}
anchor{south west}{northeast pgf@x=-pgf@x pgf@y=-pgf@y}
anchor{west}{northeast pgf@x=-pgf@x pgf@y=0pt}
anchor{north west}{northeast pgf@x=-pgf@x}
anchor{north}{northeast pgf@x=0pt}
anchor{north east}{northeast}
anchor{east}{northeast pgf@y=0pt}
}
makeatother
begin{tikzpicture}[
>=stealth,
every state/.style={
font=small,
blur shadow,
thick,
},
every edge/.append style={
->,
thick,
},
process/.style={
state,
rectangle,
text width=10em,
text centered,
rounded corners,
top color=orange!60,
bottom color=orange!20,
},
internal storage/.style={
state,
internalstorage,
draw=none,
blur shadow={
shadow opacity=0
},
font=small,
text width=5em,
text centered,
append after command={
pgfextra{
draw[
thick,
blur shadow,
top color=BlueViolet!60,
bottom color=BlueViolet!20
] (tikzlastnode.south east)
-- ( $(tikzlastnode.south west) + (-padding, 0)$ )
-- ( $(tikzlastnode.north west) + (-padding, padding)$ )
-- ( $(tikzlastnode.north east) + (0, padding)$ )
-- cycle;
draw[thick] ( $(tikzlastnode.north west) + (-padding, 0)$ )
-- (tikzlastnode.north east);
draw[thick] ( $(tikzlastnode.north west) + (0, padding)$ )
-- (tikzlastnode.south west);
}
},
},
]
matrix (m)[matrix of nodes, column sep=8mm, row sep=6.5mm, align=center, nodes={rectangle, draw, anchor=center}]{
|[process]| {north west} & |[process]| {north } & |[process]| {north east} \
|[process]| {west } & |[internal storage]| {Internal Storage} & |[process]| {east } \
|[process]| {south west} & |[process]| {south } & |[process]| {south east} \
};
draw (m-1-1) edge (m-2-2);
draw (m-1-2) edge (m-2-2);
draw (m-1-3) edge (m-2-2);
draw (m-2-3) edge (m-2-2);
draw (m-3-3) edge (m-2-2);
draw (m-3-2) edge (m-2-2);
draw (m-3-1) edge (m-2-2);
draw (m-2-1) edge (m-2-2);
end{tikzpicture}
end{document}
add a comment |
up vote
0
down vote
This works, but isn't perfect. I'll revise it as I strengthen my tikz fu.
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
RequirePackage{luatex85}
documentclass[tikz]{standalone}
usepackage{tikz}
usepackage{makeshape}
usepackage{xcolor}
usetikzlibrary{
automata,
matrix,
shadows.blur,
}
begin{document}
defpadding{10pt}
makeatletter
definternalStorageAnchorPath{
pgf@xa=ctbnex
pgf@ya=ctbney
mincorrect{pgf@xa}{pgfshapeminwidth}
advancepgf@xapgfshapeouterxsep
mincorrect{pgf@ya}{pgfshapeminheight}
advancepgf@yapgfshapeouterysep
pgfpathmoveto{pgfpoint{pgf@xa}{-pgf@ya}}
advancepgf@xa by padding
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
advancepgf@ya by padding
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
advancepgf@xa by -padding
pgfpathlineto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathclose
}
definternalStorageBackgroundPath{
pgf@xa=ctbnex
pgf@ya=ctbney
mincorrect{pgf@xa}{pgfshapeminwidth}
mincorrect{pgf@ya}{pgfshapeminheight}
pgfpathmoveto{pgfpoint{pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathclose
}
pgfdeclareshape{internalstorage}{
setpaths{internalStorageAnchorPath}{internalStorageBackgroundPath}
savedanchor{northeast}{
pgf@x = ctbnex
mincorrect{pgf@x}{pgfshapeminwidth}
advancepgf@xpgfshapeouterxsep
pgf@y = ctbney
mincorrect{pgf@y}{pgfshapeminheight}
advancepgf@ypgfshapeouterysep
}
anchor{south east}{northeast pgf@y=-pgf@y}
anchor{south}{northeast pgf@x=0pt pgf@y=-pgf@y}
anchor{south west}{northeast pgf@x=-pgf@x pgf@y=-pgf@y}
anchor{west}{northeast pgf@x=-pgf@x pgf@y=0pt}
anchor{north west}{northeast pgf@x=-pgf@x}
anchor{north}{northeast pgf@x=0pt}
anchor{north east}{northeast}
anchor{east}{northeast pgf@y=0pt}
}
makeatother
begin{tikzpicture}[
>=stealth,
every state/.style={
font=small,
blur shadow,
thick,
},
every edge/.append style={
->,
thick,
},
process/.style={
state,
rectangle,
text width=10em,
text centered,
rounded corners,
top color=orange!60,
bottom color=orange!20,
},
internal storage/.style={
state,
internalstorage,
draw=none,
blur shadow={
shadow opacity=0
},
font=small,
text width=5em,
text centered,
append after command={
pgfextra{
draw[
thick,
blur shadow,
top color=BlueViolet!60,
bottom color=BlueViolet!20
] (tikzlastnode.south east)
-- ( $(tikzlastnode.south west) + (-padding, 0)$ )
-- ( $(tikzlastnode.north west) + (-padding, padding)$ )
-- ( $(tikzlastnode.north east) + (0, padding)$ )
-- cycle;
draw[thick] ( $(tikzlastnode.north west) + (-padding, 0)$ )
-- (tikzlastnode.north east);
draw[thick] ( $(tikzlastnode.north west) + (0, padding)$ )
-- (tikzlastnode.south west);
}
},
},
]
matrix (m)[matrix of nodes, column sep=8mm, row sep=6.5mm, align=center, nodes={rectangle, draw, anchor=center}]{
|[process]| {north west} & |[process]| {north } & |[process]| {north east} \
|[process]| {west } & |[internal storage]| {Internal Storage} & |[process]| {east } \
|[process]| {south west} & |[process]| {south } & |[process]| {south east} \
};
draw (m-1-1) edge (m-2-2);
draw (m-1-2) edge (m-2-2);
draw (m-1-3) edge (m-2-2);
draw (m-2-3) edge (m-2-2);
draw (m-3-3) edge (m-2-2);
draw (m-3-2) edge (m-2-2);
draw (m-3-1) edge (m-2-2);
draw (m-2-1) edge (m-2-2);
end{tikzpicture}
end{document}
add a comment |
up vote
0
down vote
up vote
0
down vote
This works, but isn't perfect. I'll revise it as I strengthen my tikz fu.
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
RequirePackage{luatex85}
documentclass[tikz]{standalone}
usepackage{tikz}
usepackage{makeshape}
usepackage{xcolor}
usetikzlibrary{
automata,
matrix,
shadows.blur,
}
begin{document}
defpadding{10pt}
makeatletter
definternalStorageAnchorPath{
pgf@xa=ctbnex
pgf@ya=ctbney
mincorrect{pgf@xa}{pgfshapeminwidth}
advancepgf@xapgfshapeouterxsep
mincorrect{pgf@ya}{pgfshapeminheight}
advancepgf@yapgfshapeouterysep
pgfpathmoveto{pgfpoint{pgf@xa}{-pgf@ya}}
advancepgf@xa by padding
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
advancepgf@ya by padding
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
advancepgf@xa by -padding
pgfpathlineto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathclose
}
definternalStorageBackgroundPath{
pgf@xa=ctbnex
pgf@ya=ctbney
mincorrect{pgf@xa}{pgfshapeminwidth}
mincorrect{pgf@ya}{pgfshapeminheight}
pgfpathmoveto{pgfpoint{pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathclose
}
pgfdeclareshape{internalstorage}{
setpaths{internalStorageAnchorPath}{internalStorageBackgroundPath}
savedanchor{northeast}{
pgf@x = ctbnex
mincorrect{pgf@x}{pgfshapeminwidth}
advancepgf@xpgfshapeouterxsep
pgf@y = ctbney
mincorrect{pgf@y}{pgfshapeminheight}
advancepgf@ypgfshapeouterysep
}
anchor{south east}{northeast pgf@y=-pgf@y}
anchor{south}{northeast pgf@x=0pt pgf@y=-pgf@y}
anchor{south west}{northeast pgf@x=-pgf@x pgf@y=-pgf@y}
anchor{west}{northeast pgf@x=-pgf@x pgf@y=0pt}
anchor{north west}{northeast pgf@x=-pgf@x}
anchor{north}{northeast pgf@x=0pt}
anchor{north east}{northeast}
anchor{east}{northeast pgf@y=0pt}
}
makeatother
begin{tikzpicture}[
>=stealth,
every state/.style={
font=small,
blur shadow,
thick,
},
every edge/.append style={
->,
thick,
},
process/.style={
state,
rectangle,
text width=10em,
text centered,
rounded corners,
top color=orange!60,
bottom color=orange!20,
},
internal storage/.style={
state,
internalstorage,
draw=none,
blur shadow={
shadow opacity=0
},
font=small,
text width=5em,
text centered,
append after command={
pgfextra{
draw[
thick,
blur shadow,
top color=BlueViolet!60,
bottom color=BlueViolet!20
] (tikzlastnode.south east)
-- ( $(tikzlastnode.south west) + (-padding, 0)$ )
-- ( $(tikzlastnode.north west) + (-padding, padding)$ )
-- ( $(tikzlastnode.north east) + (0, padding)$ )
-- cycle;
draw[thick] ( $(tikzlastnode.north west) + (-padding, 0)$ )
-- (tikzlastnode.north east);
draw[thick] ( $(tikzlastnode.north west) + (0, padding)$ )
-- (tikzlastnode.south west);
}
},
},
]
matrix (m)[matrix of nodes, column sep=8mm, row sep=6.5mm, align=center, nodes={rectangle, draw, anchor=center}]{
|[process]| {north west} & |[process]| {north } & |[process]| {north east} \
|[process]| {west } & |[internal storage]| {Internal Storage} & |[process]| {east } \
|[process]| {south west} & |[process]| {south } & |[process]| {south east} \
};
draw (m-1-1) edge (m-2-2);
draw (m-1-2) edge (m-2-2);
draw (m-1-3) edge (m-2-2);
draw (m-2-3) edge (m-2-2);
draw (m-3-3) edge (m-2-2);
draw (m-3-2) edge (m-2-2);
draw (m-3-1) edge (m-2-2);
draw (m-2-1) edge (m-2-2);
end{tikzpicture}
end{document}
This works, but isn't perfect. I'll revise it as I strengthen my tikz fu.
PassOptionsToPackage{usenames,dvipsnames}{xcolor}
RequirePackage{luatex85}
documentclass[tikz]{standalone}
usepackage{tikz}
usepackage{makeshape}
usepackage{xcolor}
usetikzlibrary{
automata,
matrix,
shadows.blur,
}
begin{document}
defpadding{10pt}
makeatletter
definternalStorageAnchorPath{
pgf@xa=ctbnex
pgf@ya=ctbney
mincorrect{pgf@xa}{pgfshapeminwidth}
advancepgf@xapgfshapeouterxsep
mincorrect{pgf@ya}{pgfshapeminheight}
advancepgf@yapgfshapeouterysep
pgfpathmoveto{pgfpoint{pgf@xa}{-pgf@ya}}
advancepgf@xa by padding
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
advancepgf@ya by padding
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
advancepgf@xa by -padding
pgfpathlineto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathclose
}
definternalStorageBackgroundPath{
pgf@xa=ctbnex
pgf@ya=ctbney
mincorrect{pgf@xa}{pgfshapeminwidth}
mincorrect{pgf@ya}{pgfshapeminheight}
pgfpathmoveto{pgfpoint{pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{-pgf@ya}}
pgfpathlineto{pgfpoint{-pgf@xa}{pgf@ya}}
pgfpathlineto{pgfpoint{pgf@xa}{pgf@ya}}
pgfpathclose
}
pgfdeclareshape{internalstorage}{
setpaths{internalStorageAnchorPath}{internalStorageBackgroundPath}
savedanchor{northeast}{
pgf@x = ctbnex
mincorrect{pgf@x}{pgfshapeminwidth}
advancepgf@xpgfshapeouterxsep
pgf@y = ctbney
mincorrect{pgf@y}{pgfshapeminheight}
advancepgf@ypgfshapeouterysep
}
anchor{south east}{northeast pgf@y=-pgf@y}
anchor{south}{northeast pgf@x=0pt pgf@y=-pgf@y}
anchor{south west}{northeast pgf@x=-pgf@x pgf@y=-pgf@y}
anchor{west}{northeast pgf@x=-pgf@x pgf@y=0pt}
anchor{north west}{northeast pgf@x=-pgf@x}
anchor{north}{northeast pgf@x=0pt}
anchor{north east}{northeast}
anchor{east}{northeast pgf@y=0pt}
}
makeatother
begin{tikzpicture}[
>=stealth,
every state/.style={
font=small,
blur shadow,
thick,
},
every edge/.append style={
->,
thick,
},
process/.style={
state,
rectangle,
text width=10em,
text centered,
rounded corners,
top color=orange!60,
bottom color=orange!20,
},
internal storage/.style={
state,
internalstorage,
draw=none,
blur shadow={
shadow opacity=0
},
font=small,
text width=5em,
text centered,
append after command={
pgfextra{
draw[
thick,
blur shadow,
top color=BlueViolet!60,
bottom color=BlueViolet!20
] (tikzlastnode.south east)
-- ( $(tikzlastnode.south west) + (-padding, 0)$ )
-- ( $(tikzlastnode.north west) + (-padding, padding)$ )
-- ( $(tikzlastnode.north east) + (0, padding)$ )
-- cycle;
draw[thick] ( $(tikzlastnode.north west) + (-padding, 0)$ )
-- (tikzlastnode.north east);
draw[thick] ( $(tikzlastnode.north west) + (0, padding)$ )
-- (tikzlastnode.south west);
}
},
},
]
matrix (m)[matrix of nodes, column sep=8mm, row sep=6.5mm, align=center, nodes={rectangle, draw, anchor=center}]{
|[process]| {north west} & |[process]| {north } & |[process]| {north east} \
|[process]| {west } & |[internal storage]| {Internal Storage} & |[process]| {east } \
|[process]| {south west} & |[process]| {south } & |[process]| {south east} \
};
draw (m-1-1) edge (m-2-2);
draw (m-1-2) edge (m-2-2);
draw (m-1-3) edge (m-2-2);
draw (m-2-3) edge (m-2-2);
draw (m-3-3) edge (m-2-2);
draw (m-3-2) edge (m-2-2);
draw (m-3-1) edge (m-2-2);
draw (m-2-1) edge (m-2-2);
end{tikzpicture}
end{document}
answered Dec 4 at 9:12
Dylon
1207
1207
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f463065%2fhow-to-specify-variable-padding-for-tikz-node-text%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
No, I'm trying to center text within a section of a custom node. As far as I know, the matrix library is only useful for aligning nodes with respect to each other.
– Dylon
Dec 3 at 23:51
With node labels, you can specify
shift
offsets. I'm looking for something equivalent for node contents.– Dylon
Dec 3 at 23:52
1
Welcome to TeX.SX! What have you tried? Can you please post a minimal working example with your "custom code" so that we have something to work from. In additional to making it much easier for people to help you, a MWE will also help to clarify what you want. A MWE should compile and be as small as possible to demonstrate your problem.
– Andrew
Dec 3 at 23:54
Updated. Please review my post again.
– Dylon
Dec 4 at 0:29