3

Please, I'm struggling to draw the follow picture for my master's dissertation:

transmission line taxonomy

Once I reproduce it on Tikz I'm able to translate to my own language.

Victor
  • 117

1 Answers1

4

With forest. See the answers to this question.

\documentclass{article}
\usepackage{geometry}
\usepackage[edges]{forest}
\makeatletter
% remove the stray space https://tex.stackexchange.com/a/513549
% won't be needed for pgf version 3.1.5 and later
\patchcmd{\pgfutilsolvetwotwoleqfloat}
  { \noexpand\pgfmathfloatdivide@}
  {\noexpand\pgfmathfloatdivide@}
  {}{}
\makeatother

\forestset{% https://tex.stackexchange.com/a/442495
  declare dimen={my fork sep}{1em},
  my forked edge'/.style={
    edge={rotate/.option=!parent.grow},
    edge path'={let \noexpand\p1=($(.child anchor)-(!u.parent anchor)$) in 
    (!u.parent anchor) -- ++(\noexpand\x1-\forestoption{my fork sep},0) |- (.child anchor)},
  },
  my forked edge/.style={
    on invalid={fake}{!parent.parent anchor=children},
    child anchor=parent,
    my forked edge',
  },
  my forked edges/.style={for nodewalk={#1}{my forked edge}},
  my forked edges/.default=tree,
}
\begin{document}
\noindent
\begin{forest}
my forked edges, 
for tree={grow'=0,   edge=thick,tier/.option=level,  
l sep+=2em,anchor=base west,s sep=1ex,  font=\strut\sffamily,
alias/.wrap pgfmath arg={l-#1}{level}}
[TRANSMISSION \\LINE
 [Supports
  [{Steel sections, woord, etc}]
  [Bolts]
  [Guys and their fittings]
 ] 
 [Foundations 
 ] 
 [Conductors
  [Joints]
 ]
 [Insulator strings 
  [Conectors]
  [Insulators]
  [Fittings]
 ]
]
\path ([yshift=1em]current bounding box.north) coordinate (N);
% 0.5ex can be changed to increase/decreas the vertical distance between the
% level indicators and the tree
\foreach \X  [count=\Y starting from 0] in {SYSTEM,COMPONENTS,ELEMENTS}
{\node[anchor=south west,font=\strut\small\sffamily] (aux-\Y) at 
(l-\Y.west|-N){\X};}
\node[draw,fit=(aux-0)(aux-1)(aux-2)
(current bounding box.west|-aux-1)
(current bounding box.east|-aux-1),inner xsep=\forestoption{my fork sep}] (F){};
\foreach \X in {0,1,2}
{\draw ([xshift=-\forestoption{my fork sep}]aux-\X.west|-F.south)
-- ([xshift=-\forestoption{my fork sep}]aux-\X.west|-F.north); }
\end{forest}

\bigskip

\noindent% cf. https://tex.stackexchange.com/a/515604/194703
\begin{forest}
my forked edges, 
for tree={grow'=0,   edge=thick,tier/.option=level,  
l sep+=2em,anchor=base west,s sep=1ex,  font=\strut\sffamily,
alias/.wrap pgfmath arg={l-#1}{level}}
[,phantom
 [SYSTEM,alias=T1,for tree={no edge}
  [COMPONENTS,alias=T2
   [ELEMENTS,alias=T3]
  ]
 ]
 [TRANSMISSION \\LINE
  [Supports
   [{Steel sections, woord, etc}]
   [Bolts]
   [Guys and their fittings]
  ] 
  [Foundations 
  ] 
  [Conductors
   [Joints]
  ]
  [Insulator strings 
   [Conectors]
   [Insulators]
   [Fittings]
  ]
 ]
] 
\node[draw,fit=(T1)(T3)(T3-|current bounding box.east),
inner xsep=\forestoption{my fork sep}/2,
xshift=-\forestoption{my fork sep}/2] (F){};
\foreach \X in {1,2,3}
{\draw ([xshift=-\forestoption{my fork sep}]T\X.west|-F.south)
-- ([xshift=-\forestoption{my fork sep}]T\X.west|-F.north); }
\end{forest}
\end{document}

enter image description here

As for the extra request in the comments:

\documentclass{article}
\usepackage{geometry}
\usepackage[edges]{forest}
\makeatletter
% remove the stray space https://tex.stackexchange.com/a/513549
% won't be needed for pgf version 3.1.5 and later
\patchcmd{\pgfutilsolvetwotwoleqfloat}
  { \noexpand\pgfmathfloatdivide@}
  {\noexpand\pgfmathfloatdivide@}
  {}{}
\makeatother

\forestset{% https://tex.stackexchange.com/a/442495
  declare dimen={my fork sep}{1em},
  my forked edge'/.style={
    edge={rotate/.option=!parent.grow},
    edge path'={let \noexpand\p1=($(.child anchor)-(!u.parent anchor)$) in 
    (!u.parent anchor) -- ++(\noexpand\x1-\forestoption{my fork sep},0) |- (.child anchor)},
  },
  my forked edge/.style={
    on invalid={fake}{!parent.parent anchor=children},
    child anchor=parent,
    my forked edge',
  },
  my forked edges/.style={for nodewalk={#1}{my forked edge}},
  my forked edges/.default=tree,
}
\begin{document}
\noindent
\begin{forest}
my forked edges, 
for tree={grow'=0,   edge=thick,tier/.option=level,  
l sep+=2em,anchor=base west,s sep=1ex,  font=\strut\sffamily,
alias/.wrap pgfmath arg={l-#1}{level}}
[TRANSMISSION \\LINE
 [Supports
  [{Steel sections, woord, etc}]
  [Bolts]
  [Guys and their fittings]
 ] 
 [Foundations 
 ] 
 [Conductors
  [Joints]
 ]
 [Insulator strings 
  [Conectors]
  [Insulators]
  [Fittings]
 ]
]
\path ([yshift=1em]current bounding box.north) coordinate (N);
% 0.5ex can be changed to increase/decreas the vertical distance between the
% level indicators and the tree
\foreach \X  [count=\Y starting from 0] in {SYSTEM,COMPONENTS,ELEMENTS}
{\node[anchor=south west,font=\strut\small\sffamily,opacity=0] (aux-\Y) at 
(l-\Y.west|-N){\X};} % <- to be sure everything fits
\node[draw,fit=(aux-0)(aux-1)(aux-2)
(current bounding box.west|-aux-1)
(current bounding box.east|-aux-1),inner xsep=\forestoption{my fork sep}] (F){};
\foreach \X in {0,1,2}
{\draw ([xshift=-\forestoption{my fork sep}]aux-\X.west|-F.south)
--  coordinate (paux-\X) ([xshift=-\forestoption{my fork sep}]aux-\X.west|-F.north); }
\path (F.east) coordinate (paux-3);
\foreach \X  [count=\Y starting from 0] in {SYSTEM,COMPONENTS,ELEMENTS}
{\path (paux-\Y) -- node[font=\strut\small\sffamily]{\X}  (paux-\the\numexpr\Y+1);}
\end{forest}
\end{document}

enter image description here

For additional requests please ask a new question, which is free of charge.

  • I would like to have the same vertical alignment, which is the tricky part – Victor Dec 14 '19 at 20:35
  • @VictorVerga Sorry, I do not understand what you mean by "same vertical alignment". –  Dec 14 '19 at 20:37
  • @Schrondinger The red vertical lines should match all together at the same alignment: https://imgur.com/a/wvB39Cr – Victor Dec 14 '19 at 20:43
  • @Schrondinger the same idea applies to the blue lines – Victor Dec 14 '19 at 20:43
  • @VictorVerga I updated the answer accordingly. –  Dec 14 '19 at 21:01
  • @Schrondinger Congratulations. I have added the texts into your response, you can update it again. How can I adjust the width of each columns ? The code is very complex, is it possible to make the width of the elements column equal to the system column ? – Victor Dec 14 '19 at 22:24
  • @VictorVerga Thanks! I added a second solution and a fix for stray spaces. BTW, if the node text has commas as in Steel sections, woord, etc, you need to wrap it in braces, {Steel sections, woord, etc}. –  Dec 14 '19 at 22:41
  • Both are great solutions. How can I center the texts SYSTEM, COMPONENTS and ELEMENTS ? – Victor Dec 14 '19 at 23:19
  • @VictorVerga Center w.r.t. what? (Will be offline now for a while.) –  Dec 14 '19 at 23:21
  • @ Schrödinger's I mean center vertically and horizontally inside the boxes – Victor Dec 14 '19 at 23:22
  • @VictorVerga I will have to accept your decision to unaccept the answer, but I do not understand it. If this is an attempt to add even more requests to the question, please note that I am not responding to this. –  Dec 17 '19 at 23:46
  • @ Schrödinger's I am very detailist, I was expecting that the solution would be faithful to the photo. Also, I am unable to add this drawing to a figure enviroment because it is not a Tikz solution – Victor Dec 18 '19 at 00:00
  • @VictorVerga You can use a forest environment in a figure. –  Dec 18 '19 at 00:02