流程图,思维导图,拓扑图通常能把我们遇到的一些复杂的关系结构用图形的方式展现出来。在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绘制函数关系的图

\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=\it\color[RGB]{96,96,96},
stringstyle=\rmfamily\slshape\color[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=%d\n",ans);
}
\end{lstlisting}
};
\node[state,fill=none] (filename_main) at ([yshift=0.2cm]fun_main.north) {$Func\underline{\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) {$Func\underline{\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) {$Func\underline{\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/

Latex中画出函数文件的调用关系拓扑图的更多相关文章

  1. Latex中cls和sty文件有何区别?

    Latex中cls和sty文件有何区别? 资源 本文对 LaTeX 中 .cls 和 .sty 文件进行介绍,主要参考了 What are .cls and .sty files?How are th ...

  2. python—networkx:在一张图中画出多个子图

    通过plt.subplot能够在一张图中画出多个子图 #coding: utf-8 #!/usr/bin/env python """ Draw a graph with ...

  3. Linux 编程中的API函数和系统调用的关系【转】

    转自:http://blog.chinaunix.net/uid-25968088-id-3426027.html 原文地址:Linux 编程中的API函数和系统调用的关系 作者:up哥小号 API: ...

  4. haploview画出所有SNP的LD关系图

    有时候我们想画出所有SNP的LD关系图,则需要在命令行添加“-skipcheck”命令行,如下所示: java -jar Haploview.jar -skipcheck -n -pedfile 80 ...

  5. shell从函数文件里调用函数

    碰到一个shell中函数调用的小问题,记录一下. shell中函数有三种调用方式,一种是在文件前面定义函数,然后在以下直接调用:一种是通过加载shell,在shell中直接调用:第三种是将函数写入文件 ...

  6. wpf 在不同DPI下如何在DrawingVisual中画出清晰的图形

    环境Win10 VS2017 .Net Framework4.7.1   本文仅讨论在DrawingVisual中进行的画图.   WPF单位,系统DPI,显示器DPI三者的定义及关系 WPF单位:一 ...

  7. 如何在canvas中画出一个太极图

    先放一个效果图: 代码如下 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /&g ...

  8. android中画弧函数canvas.drawArc()之理解

    在学习android中图形图像处理技术这部分内容时,对绘制圆弧函数canvas.drawArc()的用法.参数含义及画图原理很是不理解,在网上搜索了一些,加上自己的理解,在此做个小总结,作为学习过程中 ...

  9. Mysql获取字符串中的数字函数方法和调用

    )) ) BEGIN ; ) default ''; set v_length=CHAR_LENGTH(Varstring); DO )) )) ) THEN )); END IF; ; END WH ...

随机推荐

  1. 启动 Eclipse 弹出“Failed to load the JNI shared library jvm.dll”错误的解决方法

    原因1:给定目录下jvm.dll不存在. 对策:(1)重新安装jre或者jdk并配置好环境变量.(2)copy一个jvm.dll放在该目录下. 原因2:eclipse的版本与jre或者jdk版本不一致 ...

  2. HTML学习笔记——标签

    最近开始学习前端的一些知识,了解了一下Html和CSS. HTML:是网页内容的载体,它负责的是网页的内涵,也就是网页要呈现的内容,包括了图片,视频还有文字.是网页要加载的东西: CSS:是样式表现, ...

  3. ffmpeg获取文件的总时长(mp3/mp4/flv等)

    使用ffmpeg.exe获取文件属性信息,C#中可以在进程外异步调用这个工具,如下: using (System.Diagnostics.Process pro = new System.Diagno ...

  4. 生成GUID唯一值的方法汇总(dotnet/javascript/sqlserver)

    一.在 .NET 中生成1.直接用.NET Framework 提供的 Guid() 函数,此种方法使用非常广泛.GUID(全局统一标识符)是指在一台机器上生成的数字,它保证对在同一时空中的任何两台计 ...

  5. 如何使用DOS命令(cd命令)

    如何使用DOS命令 DOS是Disk Operation System(磁盘操作系统)的简称,是个人计算机上的一类操作系统.它直接操纵管理硬盘的文件,一般都是黑底白色文字的界面.顾名思义,DOS主要是 ...

  6. W3Help-兼容性-知识库

    http://www.w3help.org/zh-cn/kb/ clear:none/left/right/both/inherit该特性表明元素框的哪一边不可以和先前的浮动框相邻.'clear' 特 ...

  7. Python Day12

    MySQL 数据库介绍 什么是数据库? 数据库(Database)是按照数据结构来组织.存储和管理数据的仓库, 每个数据库都有一个或多个不同的API用于创建,访问,管理,搜索和复制所保存的数据. 我们 ...

  8. jdk 安装 环境变量配置

    右键选择 计算机→属性→高级系统设置→高级→环境变量 1.系统变量→新建 变量名:JAVA_HOME 变量值:(变量值填写你的jdk的安装目录,例如本人是 C:\Program Files\Java\ ...

  9. 静态方法中不能new内部类的实例对象的总结

    class Test{ public void main(String[] args){ A testA=new A(); //这里会出现问题 new Thread(new Runnable(){ p ...

  10. qemu 源码调试

    1:下载最新的QEMU源码 git clone https://github.com/qemu/qemu.git 2:对qemu进行编译 ./configure --prefix=/usr --lib ...