-
Notifications
You must be signed in to change notification settings - Fork 46
/
3_method.tex
87 lines (68 loc) · 2.24 KB
/
3_method.tex
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
% !TeX root = ../main.tex
% -*- coding: utf-8 -*-
\chapter{常用包}
\label{chpt:method}
\section{The Tikz 绘图Package}
\label{sec:method:tikz}
The {\scshape pdf}\ package, where ``{\scshape pdf}'' is supposed to mean ``portable
graphics format'' (or ``pretty, good, functional'' if you
prefer\dots), is a package for creating graphics in an ``inline''
manner. It defines a number of \TeX\ commands that draw
graphics. For example, the code \verb|\tikz \draw (0pt,0pt) -- (20pt,6pt);|
yields the line \tikz \draw (0pt,0pt) -- (20pt,6pt); and the code \verb|\tikz \fill[orange] (1ex,1ex) circle (1ex);| yields \tikz
\fill[orange] (1ex,1ex) circle (1ex);.
\begin{figure}[h]
\centering
\input{./figure/pgf}
\caption{\label{fig:exmaple1} 示例图1}
\end{figure}
In a sense, when you use {\scshape pdf}\ you ``program'' your graphics, just
as you ``program'' your document when you use \TeX. You get all
the advantages of the ``\TeX-approach to typesetting'' for your
graphics: quick creation of simple graphics, precise positioning, the
use of macros, often superior typography. You also inherit all the
disadvantages: steep learning curve, no \textsc{wysiwyg}, small
changes require a long recompilation time, and the code does not
really ``show'' how things will look like.
\begin{figure}
\centering
\input{./figure/process}
\caption{\label{fig:exmaple2} 示例流程图2}
\end{figure}
\section{代码块}
\label{sec:method:code}
python 代码可以直接使用\textbf{python}环境
\begin{python}[caption={斐波那契Python}]
def fibonacci(n):
# Fibonacci number
if n < 0:
return False
if n <= 1:
return n
return fibonacci(n-2) + fibonacci(n-1)
\end{python}
C/C++ 代码可以直接使用\textbf{cpp}环境
\begin{cpp}[caption={斐波那契C++}]
unsigned long Fibonacci(int n)
{
// Fibonacci start from 0
if (n <= 1)
{
return n;
}
else
{
return Fibonacci(n - 1) + Fibonacci(n - 2);
}
}
\end{cpp}
其他代码,使用\textbf{lstlisting}指明 \textbf{language}即可,如matlab代码
\begin{lstlisting}[caption={Matlab代码},language=Matlab]
function a = factorial(n)
% return n!
if n==0
a=1;
else
a=n * factorial(n-1);
end
\end{lstlisting}