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
\def\band{10pt}
\def\internalstorageAnchorpath{
\pgf@xa=\ctbnex
\pgf@ya=\ctbney
\advance\pgf@xa by \band
\advance\pgf@ya by \band
\mincorrect{\pgf@xa}{\pgfshapeminwidth}
\advance\pgf@xa\pgfshapeouterxsep
\mincorrect{\pgf@ya}{\pgfshapeminheight}
\advance\pgf@ya\pgfshapeouterysep
\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
}
\def\internalstorageBackground{
\pgf@xa=\ctbnex
\pgf@ya=\ctbney
\advance\pgf@xa by \band
\advance\pgf@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
\advance\pgf@xa by -\band
\pgfpathmoveto{\pgfpoint{-\pgf@xa}{\pgf@ya}}
\pgfpathlineto{\pgfpoint{-\pgf@xa}{-\pgf@ya}}
\advance\pgf@xa by \band
\advance\pgf@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
\advance\pgf@x by \band
\mincorrect{\pgf@x}{\pgfshapeminwidth}
\advance\pgf@x\pgfshapeouterxsep
\pgf@y = \ctbney
\mincorrect{\pgf@y}{\pgfshapeminheight}
\advance\pgf@y\pgfshapeouterysep
}
\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.
shift
offsets. I'm looking for something equivalent for node contents.