3

I'm following the answer I got here for a previous question about how to control text location within a large node in tikz. I would like a slanted box to surround 4 smaller boxes, and then automatically place the label for the slanted box in the top right. It's not far enough right. I could manually force it over, but I'll be doing this a number of times and the slanted box will change size each time. So it would have to be done repeatedly.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,fit,backgrounds}

\tikzset{box/.style={draw, minimum width = 1.cm, minimum height = 1.cm, text width=1cm, text centered},
slantedbox/.style={draw,trapezium,trapezium left angle=70,trapezium right angle=-70, label={[shift={(9ex,-3ex)}]north east:#1}}
}

\begin{document}
\begin{tikzpicture}
\node [box] (phiQQ) at (0,0) {$\phi_{QQ}$};
\node [box] (phiQA) at (3,0) {$\phi_{QA}$};
\node [box] (phiQ*A) at (6,0) {$\phi_{Q^*A}$};
\node [box] (phiAA) at (4.5,-2) {$\phi_{AA}$};
\node [slantedbox = $\xi$, fit = (phiQQ)(phiQA)(phiQ*A)(phiAA), minimum height = 2cm] at (3,-1) (xi) {};
\end{tikzpicture}

\end{document}

Here's my current output: enter image description here

I want the $\xi$ farther right automatically.

1 Answer 1

2

Use top right corner in

slantedbox/.style={draw,trapezium,trapezium left angle=70,
          trapezium right angle=-70, label={[shift={(0,-3ex)}]top right corner:#1}}

The possible anchors are (from pgfmanual page 705)

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,fit,backgrounds}

\tikzset{box/.style={draw, minimum width = 1.cm, minimum height = 1.cm, text width=1cm, text centered},
slantedbox/.style={draw,trapezium,trapezium left angle=70,
          trapezium right angle=-70, label={[shift={(0,-3ex)}]top right corner:#1}}
}

\begin{document}
\begin{tikzpicture}
\node [box] (phiQQ) at (0,0) {$\phi_{QQ}$};
\node [box] (phiQA) at (3,0) {$\phi_{QA}$};
\node [box] (phiQ*A) at (6,0) {$\phi_{Q^*A}$};
\node [box] (phiAA) at (4.5,-2) {$\phi_{AA}$};
\node [slantedbox = $\xi$, fit = (phiQQ)(phiQA)(phiQ*A)(phiAA), minimum height = 2cm] at (3,-1) (xi) {};
\end{tikzpicture}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .