Tikz:用框和线绘制传输线分类

Tikz:用框和线绘制传输线分类

请帮忙,我正在努力为我的硕士论文绘制下面的图片:

传输线分类

一旦我在 Tikz 上重现它,我就能将其翻译成我自己的语言。

答案1

有森林。查看答案这个问题

\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}

在此处输入图片描述

至于评论中的额外要求:

\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}

在此处输入图片描述

如有其他要求,请提出新问题,这是免费的。

相关内容