Text label within dotted line around nodes

quepasa 10/10/2018 at 08:14. 2 answers, 110 views
showlabels

Text should be added where it is in the picture

Hello, would like to add some text where it is put in the picture. Already tried a few things but did not get an easy solution. Could someone help me out please?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows, calc}

%%% styles for Figure: Main areas of leadership affected by Digital Transformation %%%
\tikzstyle{digital} = [rectangle, rounded corners, align=left, draw=black, fill=gray!20, text width=3cm]
\tikzstyle{line} = [thick,-,>=stealth]

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[node distance=2.2cm]

%%% NODES %%%
\node (competitive)[digital] {Competitive Landscape};                           
\node (customer) [digital, left of=competitive, xshift=-2cm] {Customer relationship};           
\node (work) [digital, right of=competitive, xshift=2cm] {People/Work environment};

%%% LINES %%%
\draw [line] (competitive) -- (customer);
\draw [line] (competitive) -- (work);

%%% RECTANGLES %%%
\draw[thick,dotted]    ($(customer.north west)+(-0.25,0.25)$) rectangle ($(work.south east)+(0.25,-0.6)$);

\end{tikzpicture}
\caption{Three pillars} \label{fig:leadership_digital}
\end{figure}   

\end{document}

2 Answers


SKL 10/10/2018 at 09:20.

You could use the fit-library to create a node surrounding your other boxes and then create another node at the south position with your text. This node can then have a white background if you like.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows, calc, fit}

%%% styles for Figure: Main areas of leadership affected by Digital Transformation %%%
\tikzstyle{digital} = [rectangle, rounded corners, align=left, draw=black, fill=gray!20, text width=3cm]
\tikzstyle{line} = [thick,-,>=stealth]

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[node distance=2.2cm]

%%% NODES %%%
\node (competitive)[digital] {Competitive Landscape};                           
\node (customer) [digital, left of=competitive, xshift=-2cm] {Customer relationship};           
\node (work) [digital, right of=competitive, xshift=2cm] {People/Work environment};

%%% LINES %%%
\draw [line] (competitive) -- (customer);
\draw [line] (competitive) -- (work);

%%% RECTANGLES %%%
\node[draw, thick, dotted, rounded corners, inner xsep=1em, inner ysep=1em, fit=(work) (customer)] (box) {};
\node[fill=white] at (box.south) {Text Here};

\end{tikzpicture}
\caption{Three pillars} \label{fig:leadership_digital}
\end{figure}   

\end{document}

If you need more whitespace before and/or afterwards, an easy (but probably not so nice) way is to just put a \quad before and after your text.

enter image description here


Zarko 10/10/2018 at 10:44.

with tikz libraries chains, fit and positioning is simple:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, chains, fit, positioning}

\begin{document}
    \begin{figure}
    \centering
    \begin{tikzpicture}[
 node distance = 10mm and 5mm,
   start chain = going right,
digital/.style = {rounded corners, draw, fill=gray!20,
                  text width=3cm, align=flush center, %left,
                  on chain, join=by line},
   line/.style = {thick,-Stealth}
                    ]
%%% NODES %%%
\node (n1) [digital] {Customer relationship};
\node (n2) [digital] {Competitive Landscape};
\node (n3) [digital] {People/Work environment};
%%% dotted RECTANGLE %%%
\node[draw, thick, dotted, inner sep=3ex, yshift=-1ex,
      fit=(n1) (n3)] (box) {};
\node[fill=white, inner xsep=1ex] at (box.south) {Text Here};
    \end{tikzpicture}
\caption{Three pillars}
\label{fig:leadership_digital}
    \end{figure}
\end{document}

enter image description here

note: your code assume, that nodes "digital" are connected by arrows, but on images are simple lines. if you prefer to have only lines, than change line style to line/.style = {thick,-}


HighResolutionMusic.com - Download Hi-Res Songs

1 Alan Walker

Diamond Heart flac

Alan Walker. 2018. Writer: Alan Walker;Sophia Somajo;Mood Melodies;James Njie;Thomas Troelsen;Kristoffer Haugan;Edvard Normann;Anders Froen;Gunnar Greve;Yann Bargain;Victor Verpillat;Fredrik Borch Olsen.
2 Sia

I'm Still Here flac

Sia. 2018. Writer: Sia.
3 Cardi B

Taki Taki flac

Cardi B. 2018. Writer: Bava;Juan Vasquez;Vicente Saavedra;Jordan Thorpe;DJ Snake;Ozuna;Cardi B;Selena Gomez.
4 Little Mix

Woman Like Me flac

Little Mix. 2018. Writer: Nicki Minaj;Steve Mac;Ed Sheeran;Jess Glynne.
5 Halsey

Without Me flac

Halsey. 2018. Writer: Halsey;Delacey;Louis Bell;Amy Allen;Justin Timberlake;Timbaland;Scott Storch.
6 Lady Gaga

I'll Never Love Again flac

Lady Gaga. 2018. Writer: Benjamin Rice;Lady Gaga.
7 Bradley Cooper

Shallow flac

Bradley Cooper. 2018. Writer: Andrew Wyatt;Anthony Rossomando;Mark Ronson;Lady Gaga.
8 Bradley Cooper

Always Remember Us This Way flac

Bradley Cooper. 2018. Writer: Lady Gaga;Dave Cobb.
9 Kelsea Ballerini

This Feeling flac

Kelsea Ballerini. 2018. Writer: Andrew Taggart;Alex Pall;Emily Warren.
10 Mako

Rise flac

Mako. 2018. Writer: Riot Music Team;Mako;Justin Tranter.
11 Dewain Whitmore

Burn Out flac

Dewain Whitmore. 2018. Writer: Dewain Whitmore;Ilsey Juber;Emilio Behr;Martijn Garritsen.
12 Avril Lavigne

Head Above Water flac

Avril Lavigne. 2018. Writer: Stephan Moccio;Travis Clark;Avril Lavigne.
13 Khalid

Better flac

Khalid. 2018. Writer: Charlie Handsome;Jamil Chammas;Denis Kosiak;Tor Erik Hermansen;Mikkel Stoleer Eriksen;Khalid.
14 Lady Gaga

Look What I Found flac

Lady Gaga. 2018. Writer: DJ White Shadow;Nick Monson;Mark Nilan Jr;Lady Gaga.
15 Deep Chills

Run Free flac

Deep Chills. 2018.
16 Dynoro

In My Mind flac

Dynoro. 2018. Writer: Georgi Kay;Feenixpawl;Ivan Gough.
17 Charli XCX

1999 flac

Charli XCX. 2018. Writer: Charli XCX;Troye Sivan;Leland;Oscar Holter;Noonie Bao.
18 NCT 127

Regular (English Version) flac

NCT 127. 2018.
19 Lukas Graham

Love Someone flac

Lukas Graham. 2018. Writer: Don Stefano;Morten "Rissi" Ristorp;Morten "Pilo" Pilegaard;Jaramye Daniels;James Alan;David LaBrel;Lukas Forchhammer Graham.
20 Rita Ora

Let You Love Me flac

Rita Ora. 2018. Writer: Rita Ora.

Language

Popular Tags