[latex]使用tikz的示例

[latex]使用tikz的示例,看着图就知道里面的每一步命令了:

%传热学图2-30,矩形区域中的二维稳态导热
\begin{tikzpicture}[scale=1,line width=1pt]
%画一个矩形
\path (0,0) coordinate (p00);
\path (0,5) coordinate (p01);
\path (5,5) coordinate (p11);
\path (5,0) coordinate (p10);
\draw[color=blue,line width=3pt] (p00)--(p01)--(p11)--(p10)--cycle;
%画x和y坐标轴
\draw [<->,line width=1.5pt] (0,6.5) node (yaxis) [above] {$y$}
    |- (6.5,0) node (xaxis) [right] {$x$};
%绘制原点
\path (-0.25,-0.25) node(axis0){$O$};   
%绘制文本node
\path (2,-0.5) node(text1)[below]{$t_1 \text{,} \theta = 0$};        
\path (5.5,2) node(text2)[right]{$t_1 \text{,} \theta = 0$};
\path (3,5.5) node(text3)[above]{$t_2 \text{,} \theta = 0$};   
\path (-0.5,2.5) node(text4)[left]{$t_1 \text{,} \theta = 0$}; 
%绘制文本node和矩形的连接线
\draw[line width=1pt] (text1)--(2.5,0); 
\draw[line width=1pt] (text2)--(5,2.5); 
\draw[line width=1pt] (text3)--(2.5,5); 
\draw[line width=1pt] (text4)--(0,2.5); 
%绘制文本ab
\path (0,5) node(texta)[left]{$a$};
\path (5,0) node(textb)[below]{$b$};
\end{tikzpicture}
效果如下:

[latex]使用tikz的示例_第1张图片

效果还不错,就是对箭头不满意,下面的箭头就比较理想:

%\input{tikz_file/图4-2a.tex} %传热学
%-----------------------------------------------------------------
\begin{tikzpicture}[>=stealth,line width=0.75pt] 
\useasboundingbox[dashed,very thin,draw](0,0)grid(5,5);
%矩形四个顶点坐标点
\coordinate(A) at(1,1);
\coordinate[label=135:$W$]  (B) at(1,4);
\coordinate (C) at(4,4); 
\coordinate[label=below:$H$] (D) at(4,1);
%绘制矩形
%\draw (A)--(B)--(C)--(D)--cycle;
\draw (A)rectangle(C);
%绘制坐标轴
\draw [<->] (A) +(1,0.25) node[right]{x}-| +(0.25,1) node[above]{y};
%标注文本
\path ($(A)!0.4!(B)$) +(-0.2,0) node(E)[left]{$t_ 0$};          
\path ($(B)!0.5!(C)$)+(0,0.2) node(F)[above]{${t_f} \text{,}{h_3}$};  
\path ($(D)!0.5!(C)$)+(0.2,0) node(G)[right]{${t_f} \text{,}{h_2}$};      
\path ($(A)!0.5!(D)$)+(0,-0.2) node(H)[below]{${t_f} \text{,}{h_1}$}; 
%画蛇形箭头
\draw (E)--($(A)!0.5!(B)$);
\draw [->,decorate,
decoration={snake,amplitude=1mm,segment length=9mm,post length=1mm}]
($(B)!0.5!(C)$)+(-0.4,0.2)--+(0.4,0.2);
\draw [->,decorate,
decoration={snake,amplitude=1mm,segment length=9mm,post length=1mm}]
($(C)!0.5!(D)$)+(+0.2,-0.4)--+(0.2,0.4);
\draw [->,decorate,
decoration={snake,amplitude=1mm,segment length=9mm,post length=1mm}]
($(A)!0.5!(D)$)+(-0.4,-0.2)--+(0.4,-0.2);
\end{tikzpicture}  
效果如下:

.[latex]使用tikz的示例_第2张图片

再看一个例子:

%传热学图4-2b
\begin{tikzpicture}[>=stealth,line width=0.5pt] 
\useasboundingbox[draw](-0.2,-0.2)rectangle(4.75,4.75);
\draw (1.0,1.0) rectangle (4.0,4.0);
\draw[xstep =0.5,ystep=0.5] (1.0,1.0) grid (4.0,4.0);
%矩形四个顶点坐标点
\coordinate[label=225:$O$](A) at(1,1);
\coordinate[label=135:$N$]  (B) at(1,4);
\coordinate (C) at(4,4); 
\coordinate[label=below:$M$] (D) at(4,1);
%绘制节点
\foreach \i in {1,1.5,...,4}{
	\foreach \j in {1,1.5,...,4}{
		\draw[fill](\i,\j)circle(0.75pt);
	}
}
%
\draw[dashed,pattern=north east lines] (2.25,1.75) rectangle (2.75,2.25);
%标注mn
\path (A)+(1.5,-0.1) node[below](M){$m$};
\path (A)+(-0.2,1.0) node[left](N){$n$};
\path (A)+(1.75,0.6 ) node[scale=0.8](mn){\tiny $(m\text{,}n)$};
%画箭头:
\draw[->] (A)+(0.5,-0.25) --+(1.2,-0.25) ;
\draw[->] (A)+(-0.2,0.5) --+(-0.2,1.2) ;
\draw (C)+(-0.25,+0.2) node[scale=1.2,rotate=-90]{\{} ;
\draw (C)+(-0.25,+0.2) coordinate[label=above:{\scriptsize $ \Delta x$}] ;
\draw (C)+(0.2,-0.25) node[scale=1.2]{\}} ;
\draw (C)+(0.5,-0.5) coordinate[label=above:{\scriptsize $ \Delta y$}] ;
%题注
\path ($(A)!0.5!(D)$)+(0,-0.8) node(caption){Fig.~$4-2(b)$};

\end{tikzpicture} 

效果如下:

[latex]使用tikz的示例_第3张图片

使用tikz怎么画花括号,这个花了我不少时间,虽然实现起来很简单.

你可能感兴趣的:([latex]使用tikz的示例)