
Я виделКак разрешить вращение якорей меток в TikZ, не вращая сам текст?; но этот вопрос, похоже, не отвечает на мою проблему, так что вот он.
Используя MWE ниже, я получаю следующую схему узлов, которая мне нужна:
Если я раскомментирую rotate=180
и anchor=center
, то получу следующее — хорошо, что текст в метках не повёрнут, как мне хотелось бы, но в остальном композиция получается беспорядочной:
Наконец, если я также включу/раскомментирую transform shape
- композиция станет лучше для некоторых элементов, хуже для других, но теперь также будет повернут текст в метках, что мне не нужно:
Итак, вопрос в том, есть ли способ правильно повернуть всю композицию, И при этом не повернуть текст в узлах? Мой желаемый результат, подделанный в GIMP:
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
\makeatletter
% https://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}
решение1
Хорошо, вот исправление — для половинчатого исправления, используя стили add reference
и fitting nodeR
(согласноРасчеты соединительной линии с помощью подгоночного узла в 3D tikz?), похоже, исправляет расположение узлов с помощью rotate
и transform shape
- мне просто нужна помощь, чтобы текст не поворачивался в этом случае (см. ниже); вот изображение:
Тогда, благодаря#168052 Ссылка на содержимое lasttikznode и наложение его на узел, я обнаружил, что можно реализовать стиль узла, где окружение turn
из rotating
пакета может использоваться только для поворота поля содержимого узла, реализованного как отдельный стиль rotnt
; тогда drc
стиль узла может просто унаследовать его - и единственным встроенным изменением в коде узлов будет стилизовать нестилизованные узлы с помощью rotnt
, чтобы они также поворачивались. И, наконец, я получаю желаемое изображение:
... а вот и код:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{rotating} %tlmgr install rotating
\newbox\lastnodebox
\begin{document}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
\begin{tikzpicture}
% https://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]
%
%https://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)
}}}
% https://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}