5

I am trying to make a rectangular node fit around two other nodes. This works fine as long as I do not set xslantand yscale in the enclosing scope. In the example below, the enclosing node does not fit (n1) and (n2).

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{scopes,fit,backgrounds}

\begin{document}
\begin{tikzpicture}[scale=1,transform shape]

  \tikzstyle{tA}=[draw,fill=red!10!yellow]
  \tikzstyle{tB}=[draw,fill=red!30!yellow]
  \tikzstyle{geom}=[xslant=1.5,yscale=0.5,rotate=0]

  \begin{scope}[geom]
    \node[tA] (n1) at (0,0) {A};
    \node[tB] (n2) at (0,1) {A};
    \node[tA] (n3) at (1,0) {A};
    \node[tB] (n4) at (1,1) {A};

    \node[fit=(n1) (n2), draw] {x};   
    \draw[blue,->] (n1.south) -- (n1.north); \draw[blue,->] (n2.south) -- (n2.north);     
  \end{scope}

\end{tikzpicture}
\end{document}

This is what I get (black line):

enter image description here

5
  • I really am not sure. The north and south look right. I added the output I get.
    – user52366
    May 24, 2018 at 17:03
  • @marmot: even then the enclosing node is too small. And it depends whether the fitting is done in the original coordinate space or after transformation. If it is done in the original space then things should work smoothly.
    – user52366
    May 24, 2018 at 17:17
  • Well, I actually want a rectangle in the original plane, i.e. a diamond in the final image. The diamond shape is therefore right, but it should not not intersect the smaller nodes.
    – user52366
    May 24, 2018 at 18:30
  • Let us continue this discussion in chat.
    – user52366
    May 24, 2018 at 18:39
  • I have to deal with the same problem. An old picture has to be recompiled and does not.
    – user61383
    Jan 7, 2020 at 10:25

1 Answer 1

2

Interestingly, the very same code produces what I expect (see below) on a Xubuntu 10.10 system I installed to test this (pgf version is 2.00). So to me this seems to be a regression in Tikz/PGF... (pgf version 3.0.1a in my current Kubuntu installation)

enter image description here

2
  • Nice answer, +1. It might be interesting to know what has changed. Any chance you can provide a link to the old code?
    – user121799
    May 24, 2018 at 21:55
  • I did a diff. There are mainly two larger blocks of code that changed... Too much to post here. V2.0 is here but the code is only there as an archive: sourceforge.net/projects/pgf/files/pgf/version%202.00/…
    – user52366
    May 25, 2018 at 5:13

You must log in to answer this question.

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