Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have seen How to allow labels' anchors in TikZ to be affected by rotations without rotating the text itself?; but that question doesn't seem to answer my problem, so here it goes.

With the MWE below, I get this as the node diagram that I want:

test51.png

If I uncomment rotate=180 and anchor=center, I get this below - it is good the text in labels is not rotated, as I want it, but the composition is otherwise a mess:

test52.png

Finally, if I also enable/uncomment the transform shape - the composition is better for some elements, worse for others, but now also text in labels is rotated, which I don't want:

test53.png

So the question is - is there a way to rotate the whole composition correctly, AND not have the text in nodes rotated? My desired output, faked in GIMP:

test54-gimp.png

\documentclass{standalone}

\usepackage{tikz}

\begin{document}

\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}

\makeatletter
% http://tex.stackexchange.com/a/47709/2595
\tikzset{
  fitting node/.style={
    inner sep=0pt,
    fill=none,
    draw=none,
    reset transform,
    fit={(\pgf@pathminx,\pgf@pathminy) (\pgf@pathmaxx,\pgf@pathmaxy)}
  },
  reset transform/.code={\pgftransformreset},
}
\makeatother

\begin{tikzpicture}

\tikzstyle{drc} = [draw, rectangle, line width=1pt, align=center]
\tikzstyle{arr_edge} = [>=latex,->, line width=1pt]

\node[] (tdrag3) at (27.5,1.5) {};
\begin{scope}[shift={(tdrag3)},
%rotate=180,
%anchor=center,
%transform shape,
]
\node[drc,anchor=south west] (nd01) at (0,0) {Some \\ Words};

\node[drc,anchor=south] (nd02) at (3.5,2) {Some Terms};
\node[drc] (nd03) [above=0pt of nd02] {Something};
\node[drc] (nd04) [above=0pt of nd03] {Some Notions \\ Emulation \\ (Next)};

\draw[drc] (5.5,1.5) rectangle (12,5.5) node[fitting node] (nd05) {};
\node[drc,anchor=south,minimum width=6cm,minimum height=0.8cm] (nd06) [above=5pt of nd05.south] {Generic Definition Terms};
\node[drc] (nd07) [above=5pt of nd06.north east,anchor=south east] {Tests \\ (Conversion, Exchange, etc.)};

\draw[drc] let \p1=(nd06.north west), \p2=(nd07.south west), \p3=($(nd07.north west)+(-5pt,5pt)$), \p4=($(nd07.north east)+(0,5pt)$) in (\x1,\y2) -| (\x3,\y3) to node[above left=2pt and -2em]{Plain access} (\x4,\y4) -- ++(0,0.8cm) -| (\x1,\y2);
\node[align=center] (nd05titl) [below=2pt of nd05.north,anchor=north] {Generic Definition};

\draw[drc] (-0.5,6) rectangle (7.5,9) node[fitting node] (nd08) {};
\node[drc] (nd09) [above right=0pt of nd08.south east, anchor=south east] {Generic List Terms\\Word\ Number\ Variable\ Constant} ;
\draw let \p1=(nd01.center), \p2=(nd09.north) in node[drc] (nd10) at (\x1,\y2) [below=0pt,anchor=north] {Some Terms};
\node[drc] (nd11) [above=0pt of nd10.north,anchor=south] {More Than\\Interesting};
\node[drc] (nd12) [above=0pt of nd09.north,anchor=south] {Generic\\List One};
\node[align=center] (nd13) [below=2pt of nd08.north,anchor=north] {Another List};

\draw[arr_edge] (nd01) -- (nd10);
\draw[arr_edge] (nd11) -- (nd12);
\draw[arr_edge] (nd09) -| (nd05);
% wrap in calc $$ for tikzedt
\draw[arr_edge] (nd04) |- ($(nd05.north west)-(10pt,10pt)$) -- ($(nd05.south west)-(10pt,7.5pt)$) -| ($(nd06.south west)+(10pt,0)$);

\end{scope}

\end{tikzpicture}

\end{document}
share|improve this question
1  
This is tough because your nodes are defined in different manners and with different anchors. One thing that works is replace each {Node label} with {\rotatebox{180}{Node label}} and then rotate the whole document. However, since some labels span more than one line, you would then have to reverse the order of those lines, and apply \rotatebox to each line. It's such a case-specific solution I don't think it's a solution at all, but I'm pretty sure it will work. –  jlv Mar 27 at 3:49
    
Many thanks for the comment, @JānisL - I was hoping there was a way to "interrupt" the pgf transformations just for the text (or alternatively, reapply transformations only to text), but I wasn't aware of those complications - good to have them in mind. Cheers! –  sdaau Mar 27 at 5:48

1 Answer 1

up vote 1 down vote accepted

Ok, here is a fix - for a halfway fix, using the add reference and fitting nodeR styles (as per Connecting line calculations with fitting node in 3D tikz?), seems to fix the layout of nodes with rotate and transform shape - I'd just need help now on having the text not rotated in that case (see below); here is the image:

test55.png

Then, thanks to #168052 Referencing the contents of lasttikznode, and overlaying them on a node, I've found that it is possible to implement a node style, where the turn environment from the rotating package can be used to rotate the node content box only, implemented as a separate style rotnt; then the drc node style can simply inherit it - and the only inline change in the nodes' code, would be to style unstyled nodes with rotnt, so they also get rotated. And finally, I obtain the desired image:

test56.png

... and here is the code:

\documentclass{standalone}

\usepackage{tikz}
\usepackage{rotating} %tlmgr install rotating
\newbox\lastnodebox

\begin{document}

\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}

\begin{tikzpicture}
% http://tex.stackexchange.com/a/168052/2595
\tikzstyle{rotnt} = [
execute at begin node=\begin{turn}{180}\global\setbox\lastnodebox\hbox\bgroup,
execute at end node=\egroup\copy\lastnodebox\end{turn},
]
\tikzstyle{drc} = [draw, rectangle, line width=1pt, align=center, rotnt]
\tikzstyle{arr_edge} = [>=latex,->, line width=1pt]
%
%http://tex.stackexchange.com/a/47797/2595
\tikzset{add reference/.style={insert path={%
  coordinate [pos=0,xshift=-0.5\pgflinewidth,yshift=-0.5\pgflinewidth] (#1 south west)
  coordinate [pos=1,xshift=0.5\pgflinewidth,yshift=0.5\pgflinewidth]   (#1 north east)
  coordinate [pos=.5] (#1 center)
  (#1 south west |- #1 north east)     coordinate (#1 north west)
  (#1 center     |- #1 north east)     coordinate (#1 north)
  (#1 center     |- #1 south west)     coordinate (#1 south)
  (#1 south west -| #1 north east)     coordinate (#1 south east)
  (#1 center     -| #1 south west)     coordinate (#1 west)
  (#1 center     -| #1 north east)     coordinate (#1 east)
}}}
% http://tex.stackexchange.com/questions/167825/connecting-line-calculations-
% now fitting node must orient to rectangle coordinate for 3D:
\tikzset{
  fitting nodeR/.style={
    inner sep=0pt,
    fill=none,
    draw=none,%red, % for debug
    fit={(#1 south west) (#1 north east)},
  },
}
%
\node[] (tdrag3) at (27.5,1.5) {};
\begin{scope}[shift={(tdrag3)},
rotate=180,
anchor=center,
transform shape,
]
\node[drc,anchor=south west] (nd01) at (0,0) {Some \\ Words};

\node[drc,anchor=south] (nd02) at (3.5,2) {Some Terms};
\node[drc] (nd03) [above=0pt of nd02] {Something};
\node[drc] (nd04) [above=0pt of nd03] {Some Notions \\ Emulation \\ (Next)};

\draw[drc] (5.5,1.5) rectangle (12,5.5) [add reference=R1] node[fitting nodeR=R1] (nd05) {};
\node[drc,anchor=south,minimum width=6cm,minimum height=0.8cm] (nd06) [above=5pt of nd05.south] {Generic Definition Terms};
\node[drc] (nd07) [above=5pt of nd06.north east,anchor=south east] {Tests \\ (Conversion, Exchange, etc.)};

\draw[drc] let \p1=(nd06.north west), \p2=(nd07.south west), \p3=($(nd07.north west)+(-5pt,5pt)$), \p4=($(nd07.north east)+(0,5pt)$) in (\x1,\y2) -| (\x3,\y3) to node[above left=2pt and -2em]{Plain access} (\x4,\y4) -- ++(0,0.8cm) -| (\x1,\y2);
\node[align=center,rotnt] (nd05titl) [below=2pt of nd05.north,anchor=north] {Generic Definition};

\draw[drc] (-0.5,6) rectangle (7.5,9) [add reference=R2] node[fitting nodeR=R2] (nd08) {};
\node[drc] (nd09) [above right=0pt of nd08.south east, anchor=south east] {Generic List Terms\\Word\ Number\ Variable\ Constant} ;
\draw let \p1=(nd01.center), \p2=(nd09.north) in node[drc] (nd10) at (\x1,\y2) [below=0pt,anchor=north] {Some Terms};
\node[drc] (nd11) [above=0pt of nd10.north,anchor=south] {More Than\\Interesting};
\node[drc] (nd12) [above=0pt of nd09.north,anchor=south] {Generic\\List One};
\node[align=center,rotnt] (nd13) [below=2pt of nd08.north,anchor=north] {Another List};

\draw[arr_edge] (nd01) -- (nd10);
\draw[arr_edge] (nd11) -- (nd12);
\draw[arr_edge] (nd09) -| (nd05);
% wrap in calc $$ for tikzedt
\draw[arr_edge] (nd04) |- ($(nd05.north west)-(10pt,10pt)$) -- ($(nd05.south west)-(10pt,7.5pt)$) -| ($(nd06.south west)+(10pt,0)$);

\end{scope}

\end{tikzpicture}

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.