我是靠谱客的博主 细心战斗机,这篇文章主要介绍Latex中画出函数文件的调用关系拓扑图,现在分享给大家,希望可以做个参考。

流程图,思维导图,拓扑图通常能把我们遇到的一些复杂的关系结构用图形的方式展现出来。在Latex中要想画这样的拓扑图,有一个很好用的绘图工具包 pgf/tikz 。

1.pgf/tikz的安装:pgf/tikz 绘图工具用到的宏是 usepackage{tikz} 。如果你的Latex并不带有这个宏包,那就需要参考[1]中进行安装。也可以直接下载使用带有这个宏包的新版本 CTeX_2.9.2.164_Full。

2.pgf/tikz的使用:参考[2]pgf/tikz使用说明,这里详细介绍了pgf/tikz的各种用法。

利用Latex绘制函数关系的图

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
documentclass{report} usepackage{pgf} usepackage{tikz} usepackage{listings} usepackage{xcolor} usepackage{graphicx} usetikzlibrary{shapes.callouts} usetikzlibrary{arrows,decorations.pathmorphing, backgrounds, positioning, fit, petri, automata} definecolor{yellow1}{rgb}{1,0.8,0.2} lstset{ basicstyle=footnotesize, framexleftmargin=1.5mm, keywordstyle=color{blue}bfseries, identifierstyle=bf, commentstyle=itcolor[RGB]{96,96,96}, stringstyle=rmfamilyslshapecolor[RGB]{128,0,0}, showstringspaces=false } begin{document} begin{tikzpicture} [remember picture, note/.style={ellipse callout, fill=#1}, ->,>=stealth',shorten >=1pt,auto,node distance=2.8cm,semithick] tikzstyle{every state}=[rectangle,fill=yellow1,draw=none,text=black] %创建对象:node(对象属性) (对象名称) at (对象坐标) {对象内容}; node[state] (fun_main) at (-32, 16) { begin{lstlisting}[language={C}] #include<stdio.h> #include "func.h" void main(void) { int a,b,ans; int flag; scanf("%d%d%d",&a,&b,&flag); switch(flag) { case 0 : {ans = Sum(a,b);} break; case 1 : {ans = Product(a,b);} break; } printf("ans=%dn",ans); } end{lstlisting} }; node[state,fill=none] (filename_main) at ([yshift=0.2cm]fun_main.north) {$Funcunderline{hspace{0.5em}}main.c$}; node[state] (fun0) at (-26.5, 17) { begin{lstlisting}[language={C}] int Sum(int a, int b ); int Product(int a, int b ); end{lstlisting} }; node[state,fill=none] (file0) at ([yshift=0.2cm]fun0.north) {$Func.h$}; node[state] (fun1) at (-22, 18) { begin{lstlisting}[language={C}] #include<stdio.h> int Sum(int a,int b) { int c; c = a+b; return c; } end{lstlisting} }; node[state,fill=none] (file1) at ([yshift=0.2cm]fun1.north) {$Funcunderline{hspace{0.5em}}sum.c$}; node[state] (fun2) at (-21.6, 14) { begin{lstlisting}[language={C}] #include<stdio.h> int Product(int a,int b) { int c; c = a*b; return c; } end{lstlisting} }; node[state,fill=none] (file2) at ([yshift=0.2cm]fun2.north) {$Funcunderline{hspace{0.5em}}product.c$}; %node[标注填充颜色,相对标注对象坐标,边框] (标注对象名称) at (标注对象的坐标) {内容}; node[note=green!50, callout relative pointer={(-0.5,0.5)}, draw] (note_name)at (-28,14) { begin{lstlisting}[language={C}] Start from main! end{lstlisting} }; %箭头:([横平移,纵平移]箭头端点相对对象1的位置) (out:箭头出射角度,int:箭头入射角度) ([横平移,纵平移]箭头端点相对对象2的位置); draw[->] ([xshift=-2.0cm,yshift=-0.6cm]fun_main.north east) to[out=0,in=180] ([xshift=0cm,yshift=0cm]fun0.west); draw[->] (fun0.east) to[out=0,in=210] ([xshift=0.2cm,yshift=-0.6cm]fun1.north west); draw[->] (fun0.east) to[out=0,in=150] ([xshift=0.2cm,yshift=-0.6cm]fun2.north west); end{tikzpicture} end{document}

  排版出来的效果如下

参考:

[1] http://blog.csdn.net/mathsoperator/article/details/6747170
[2] http://mirror.lzu.edu.cn/CTAN/graphics/pgf/base/doc/pgfmanual.pdf

[3] Latex论坛,http://tex.stackexchange.com/

转载于:https://www.cnblogs.com/abc36725612/p/5990269.html

最后

以上就是细心战斗机最近收集整理的关于Latex中画出函数文件的调用关系拓扑图的全部内容,更多相关Latex中画出函数文件内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(55)

评论列表共有 0 条评论

立即
投稿
返回
顶部