How would be possible to put a brace instead of a "line" connecting nodes and add some text above it with TikZ?
[Tex/LaTex] Connecting nodes with brace in TikZ
nodestikz-arrowstikz-pgf
Related Solutions
You can use relative coordinates.
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{arrows}
\tikzset{decision/.style = {diamond, draw, fill=blue!20, text width=4.5em, text badly centered, node
distance=3cm, inner sep=0pt},
block/.style = {rectangle, draw, fill=black!25, text width=5em, text centered, rounded
corners, minimum height=4em},
line/.style = {draw, -latex'},
cloud/.style = {draw, ellipse,fill=red!20, node distance=3cm, minimum height=2em}
}
\begin{document}
\begin{tikzpicture}[node distance = 2cm, auto]
\node [block] (st1) {Stage 1};
\node [block, right of=st1, node distance=3cm] (st2) {Stage 2};
\node [block, right of=st2, node distance=3cm] (st3) {Stage 3};
\path [line] (st1) -- (st2);
\path [line] (st2) -- (st3);
%% from st1 draw 1 unit down, then 2 units left (put a node), draw vertically up and then right to reach st1.west
\path[line,dashed] (st1.south) -- ++(0,-1) -- +(-2,0) node[pos=0.5,below]{Blah1} |- (st1.west) ;
%% draw 1 unit down from st3.south then horizontally left and up to reach st2.south.
\path[line,dashed] (st3.south) -- +(0,-1) -| (st2.south) node[pos=0.25,below]{Blah2} ; \end{tikzpicture}
\end{document}
Change the pos=<dimen>
as you wish. I have also used -|
to draw the lines which means draw horizontally first and then vertically
. Also, use \tikzset
instead of \tikzstyle
(which is deprecated).
If you label the node containing the text Subordinate clause
something like subclauselabel
, then you can use the intersections
library to find the intersection of perpendicular lines passing through your selected node anchors (e.g., vertical from mainclause.north west
and horizontal from subclauselabel.north.west
).
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,intersections}
\begin{document}
\tikz[baseline, remember picture] \node[inner sep = 0pt, anchor = base] (mainclause) {She said};
\tikz[baseline, remember picture] \node[inner sep = 0pt, anchor = base] (subclause) {that he knows};
\begin{tikzpicture}[remember picture, overlay]
\draw[decorate, decoration ={brace,raise=1pt}] (subclause.north west) -- (subclause.north east)
node (subclauselabel) [midway, above=1pt] {\footnotesize{Subordinate clause}};
\draw[decorate, decoration = brace] (mainclause.north west |- subclauselabel.north west) -- (subclauselabel.north east)
node [midway, above] {\footnotesize{Main clause}};
\end{tikzpicture}
\end{document}
Best Answer
An automatic solution:
The result:
The basic command to be used is:
In the
<list of items>
one should insert a comma separated list: each of them will be placed in an horizontal fashion and the distance between two of them is characterized by the keyitems distance
(initial value 3cm). Beware: too many items won't probably fit the page, so one can either reduce the distance of the items or scale the diagram.Scaling the diagram consists of introducing the standard two options
scale=<factor>
andtransform shape
. For example:In the
<options>
argument, optional, it is possible to introduce usual TikZ options (as did before) as well as the specific keys of the diagram. When one needs to customize several keys, it is better to create a new style:to be passed to the diagram: