## 编译环境 操作系统 * [x] Windows 7/8/10 Tex发行版 * [x] TexLive `2020` ## 关于LATEX作图的问题 如何绘制这样的树形图? ![](https://wenda.latexstudio.net/data/attach/201210/yzN9CjVt.PNG)

2 回答2

0
```c \documentclass[tikz]{standalone} \usepackage{tikz} \usetikzlibrary{graphs,graphdrawing,} \usegdlibrary{layered} \begin{document} \begin{tikzpicture} \graph [ layered layout, nodes={draw,minimum height=3em,text width=5em,align=center,rounded corners}, level distance=2cm, sibling distance=5mm, ] { Adversarial example -> { Attack -> { Knowledge based -> { /"White-box", /"Black-box" }, Target based -> { Targeted, /"Non-targeted" } }, Defense -> { Detection, Model Enhancement -> { Adversarial training, Network construction, Testing, Verification } } } }; \end{tikzpicture} \end{document} ``` ![](https://wenda.latexstudio.net/data/attach/201210/SPGeAacl.png) 这个例子需要 LuaLaTeX 编译,图的细节方面可能不太容易调整,还是等待其他更好的回答吧
  • 好的,非常感谢! – Ice_spring 2020-12-13 14:19 回复
2
这个图,可能要用 `tikz` 的 `\usetikzlibrary{trees}` 吧。早年画过一个,后来就不想再用它画图了。 ``` \documentclass{ctexart} \usepackage{tikz} \usetikzlibrary{trees} \begin{document} \begin{tikzpicture} \node{$ A $对称}[ font=\small, edge from parent fork right, grow=right, edge from parent/.append style = {-latex}, level 1/.style = {level distance = 14ex, sibling distance=10em}, level 2/.style = {level distance = 19ex, sibling distance=5em}, level 3/.style = {level distance = 19ex, sibling distance=3em}, level 4/.style = {level distance = 26ex, sibling distance=6em} ] child{node{$ A^T $可用} child{node{存储花费大} child{ node{ \fbox{ \begin{minipage}{11ex} \textbf{GMRES},\\ FOM, GCR \end{minipage} } } edge from parent node[near end,above] {N} } child{node[text width = 12ex]{$ A $有复特征值} child{ node{ \fbox{ \begin{minipage}{13ex} \textbf{BiCGSTAB}\\ BiCRSTAB\\ CGS\\ GPBiCG\\ QMRCGSTAB\\ TFQMR \end{minipage} } } edge from parent node[near end,above] {N} } child{ node{ \fbox{ \begin{minipage}{13ex} BiCGSTAB($ l $)\\ IDR($ s $) \end{minipage} } } edge from parent node[near end,above] {Y} } edge from parent node[near end,above] {Y} } edge from parent node[near end,above] {N} } child{node{$ A $条件数好} child{node{BiCG, QMR} edge from parent node[near end,above] {N}} child{node{CGNR, CGNE} edge from parent node[near end,above] {Y} } edge from parent node[near end,above] {Y} } edge from parent node[near end,above] {N} } child{node{$ A $正定} child{node{$ A $条件数好} child{node{MINRES, MR} edge from parent node[near end,above] {N}} child{node{CGNR, CGNE} edge from parent node[near end,above] {Y}} edge from parent node[near end,above] {N} } child{node[text width=4\ccwd]{\textbf{CG}} edge from parent node[near end,above] {Y}} edge from parent node[near end,above] {Y} }; \end{tikzpicture} \end{document} ``` 都是以前玩的了

你的回答

请登录后回答

你的回答将会帮助更多人,请务必认真回答问题。