このようなブロック図をLaTeXで描く方法

このようなブロック図をLaTeXで描く方法

図に示されているようなブロック図を描こうとしたのですが、できません。このようなブロック図を描く方法を教えてください。ありがとうございます。

これまで試してみたが、

\usepackage{forest}
\useforestlibrary{edges}

\begin{forest}
for tree={draw, minimum width=2cm, minimum height=1cm, rounded corners},
forked edges,

[IDS for Automotive CAN Bus System [Deployment Strategy[ECU][CAN][Gateway]][Detection Approach[Specification Based][Anomaly Based[Machine Learning][Hybrid Based][Frequency Based]][Signature Based]][Attacking Technique[DoS][Replay]]]
\end{forest}

このような出力が PDF で出力されます。間違った出力]1

この出力が欲しい

答え1

これは主にここフォルダーを開始するたびに挿入する必要がありますfor tree={folder, grow'=0}。ツリーが少し広すぎるため、ルート ノード以外のすべてのテキスト幅を縮小しました。

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{forest}
\useforestlibrary{edges}
\makeatletter
% remove the stray space https://tex.stackexchange.com/a/513549
\patchcmd{\pgfutilsolvetwotwoleqfloat}
  { \noexpand\pgfmathfloatdivide@}
  {\noexpand\pgfmathfloatdivide@}
  {}{}
\makeatother
\begin{document}
\noindent\begin{forest}
before typesetting nodes={
   if={isodd(n_children("!r"))}{
     for nodewalk/.wrap pgfmath arg={{fake=r,n=#1}{calign with current edge}}{int((n_children("!r")+1)/2)},
   }{},
 },
forked edges,
for tree={draw, minimum width=2cm, minimum height=1cm, rounded corners,
if level=0{}{text width=2cm}},
[IDS for Automotive CAN Bus System 
 [Deployment Strategy,for tree={folder, grow'=0}
  [ECU]
  [CAN]
  [Gateway]
 ]
 [Detection Approach
  [Specification Based]
  [Anomaly Based,for tree={folder, grow'=0}
   [Machine Learning]
   [Hybrid Based]
   [Frequency Based]
  ]
  [Signature Based]
 ]
 [Attacking Technique,for tree={folder, grow'=0}
  [DoS]
  [Replay]
 ]
]
\end{forest}
\end{document}

ここに画像の説明を入力してください

showframeこのツリーが適合することを示すだけです (ただし、ジオメトリ パッケージをロードするだけでページが少し広くなります)。

編集:tempcounta/.max={level}{tree},使用されなかったものを削除しました。@cfr に感謝します。

2回目の編集: 修正を追加https://tex.stackexchange.com/a/513549@cfr の提案に従って。

関連情報