├── .gitignore ├── LICENSE ├── README.md ├── Tikz learning.pdf ├── Tikz learning.tex ├── class ├── ch01.tex ├── ch02.tex ├── ch03.tex ├── ch04.tex ├── ch05.tex ├── ch06.tex ├── ch07.tex ├── ch08.tex ├── ch09.tex └── ch10.tex ├── delete-temp-files.bat ├── elegantbook.cls ├── figure ├── cover.jpg ├── cover.pdf └── logo.png ├── mindmap.png ├── reference.bib └── settings.tex /.gitignore: -------------------------------------------------------------------------------- 1 | ## Core latex/pdflatex auxiliary files: 2 | *.aux 3 | *.lof 4 | *.log 5 | *.lot 6 | *.fls 7 | *.out 8 | *.toc 9 | *.fmt 10 | *.fot 11 | *.cb 12 | *.cb2 13 | .*.lb 14 | elegant*-cn.pdf 15 | elegant*-en.pdf 16 | 17 | ## Intermediate documents: 18 | *.dvi 19 | *.xdv 20 | *-converted-to.* 21 | # these rules might exclude image files for figures etc. 22 | # *.ps 23 | # *.eps 24 | # *.pdf 25 | 26 | ## Generated if empty string is given at "Please type another file name for output:" 27 | .pdf 28 | 29 | ## Bibliography auxiliary files (bibtex/biblatex/biber): 30 | *.bbl 31 | *.bcf 32 | *.blg 33 | *-blx.aux 34 | *-blx.bib 35 | *.run.xml 36 | 37 | ## Build tool auxiliary files: 38 | *.fdb_latexmk 39 | *.synctex 40 | *.synctex(busy) 41 | *.synctex.gz 42 | *.synctex.gz(busy) 43 | *.pdfsync 44 | 45 | ## Auxiliary and intermediate files from other packages: 46 | # algorithms 47 | *.alg 48 | *.loa 49 | 50 | # achemso 51 | acs-*.bib 52 | 53 | # amsthm 54 | *.thm 55 | 56 | # beamer 57 | *.nav 58 | *.pre 59 | *.snm 60 | *.vrb 61 | 62 | # changes 63 | *.soc 64 | 65 | # cprotect 66 | *.cpt 67 | 68 | # elsarticle (documentclass of Elsevier journals) 69 | *.spl 70 | 71 | # endnotes 72 | *.ent 73 | 74 | # fixme 75 | *.lox 76 | 77 | # feynmf/feynmp 78 | *.mf 79 | *.mp 80 | *.t[1-9] 81 | *.t[1-9][0-9] 82 | *.tfm 83 | 84 | #(r)(e)ledmac/(r)(e)ledpar 85 | *.end 86 | *.?end 87 | *.[1-9] 88 | *.[1-9][0-9] 89 | *.[1-9][0-9][0-9] 90 | *.[1-9]R 91 | *.[1-9][0-9]R 92 | *.[1-9][0-9][0-9]R 93 | *.eledsec[1-9] 94 | *.eledsec[1-9]R 95 | *.eledsec[1-9][0-9] 96 | *.eledsec[1-9][0-9]R 97 | *.eledsec[1-9][0-9][0-9] 98 | *.eledsec[1-9][0-9][0-9]R 99 | 100 | # glossaries 101 | *.acn 102 | *.acr 103 | *.glg 104 | *.glo 105 | *.gls 106 | *.glsdefs 107 | 108 | # gnuplottex 109 | *-gnuplottex-* 110 | 111 | # gregoriotex 112 | *.gaux 113 | *.gtex 114 | 115 | # htlatex 116 | *.4ct 117 | *.4tc 118 | *.idv 119 | *.lg 120 | *.trc 121 | *.xref 122 | 123 | # hyperref 124 | *.brf 125 | 126 | # knitr 127 | *-concordance.tex 128 | # TODO Comment the next line if you want to keep your tikz graphics files 129 | *.tikz 130 | *-tikzDictionary 131 | 132 | # listings 133 | *.lol 134 | 135 | # makeidx 136 | *.idx 137 | *.ilg 138 | *.ind 139 | *.ist 140 | 141 | # minitoc 142 | *.maf 143 | *.mlf 144 | *.mlt 145 | *.mtc[0-9]* 146 | *.slf[0-9]* 147 | *.slt[0-9]* 148 | *.stc[0-9]* 149 | 150 | # minted 151 | _minted* 152 | *.pyg 153 | 154 | # morewrites 155 | *.mw 156 | 157 | # nomencl 158 | *.nlg 159 | *.nlo 160 | *.nls 161 | 162 | # pax 163 | *.pax 164 | 165 | # pdfpcnotes 166 | *.pdfpc 167 | 168 | # sagetex 169 | *.sagetex.sage 170 | *.sagetex.py 171 | *.sagetex.scmd 172 | 173 | # scrwfile 174 | *.wrt 175 | 176 | # sympy 177 | *.sout 178 | *.sympy 179 | sympy-plots-for-*.tex/ 180 | 181 | # pdfcomment 182 | *.upa 183 | *.upb 184 | 185 | # pythontex 186 | *.pytxcode 187 | pythontex-files-*/ 188 | 189 | # thmtools 190 | *.loe 191 | 192 | # TikZ & PGF 193 | *.dpth 194 | *.md5 195 | *.auxlock 196 | 197 | # todonotes 198 | *.tdo 199 | 200 | # easy-todo 201 | *.lod 202 | 203 | # xmpincl 204 | *.xmpi 205 | 206 | # xindy 207 | *.xdy 208 | 209 | # xypic precompiled matrices 210 | *.xyc 211 | 212 | # endfloat 213 | *.ttt 214 | *.fff 215 | 216 | # Latexian 217 | TSWLatexianTemp* 218 | 219 | ## Editors: 220 | # WinEdt 221 | *.bak 222 | *.sav 223 | 224 | # Texpad 225 | .texpadtmp 226 | 227 | # Kile 228 | *.backup 229 | 230 | # KBibTeX 231 | *~[0-9]* 232 | 233 | # auto folder when using emacs and auctex 234 | ./auto/* 235 | *.el 236 | 237 | # expex forward references with \gathertags 238 | *-tags.tex 239 | 240 | # standalone packages 241 | *.sta 242 | 243 | # generated if using elsarticle.cls 244 | *.spl 245 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Hoganbin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### TikZ学习入门之葵花宝典 2 | 3 | ___ 4 | 5 | 6 | 在学习`LaTeX `与 `TikZ`过程中,八一发现到大家其学习`LaTeX `曲线陡峭,它并非所见即所得,可能一个微小的改动需要长时间的全文编译,而且代码并不能真正显示事物本来的样子,`TikZ`的底层是 PGF(portable graphics format) ,即它是PGF 的前端。 7 | 8 | 这份笔记去年计划是十章节内容: 9 | 10 | 1. 基础准备 11 | 12 | 2. 填充颜色 13 | 14 | 3. 指定参考点或坐标系 15 | 16 | 4. 直方图 17 | 18 | 5. 绘制函数图像 19 | 20 | 6. 流程图 21 | 22 | 7. 实战练习 23 | 24 | 8. 思维导图 25 | 26 | 9. 总结 27 | 28 | 10. 特殊纸张 29 | 30 | 但由于我没时间更新笔记,以后或许都没时间,不过将其源码公开发给大家学习,如果你正在学习`TikZ`的话,可以按我这个章节往后补充,它将成为你学习它的一笔人生财富.... -------------------------------------------------------------------------------- /Tikz learning.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hoganbin/TikZ-Learning-Notes/d78da88fe07f9c5203680caaa37ebb35c28f71a9/Tikz learning.pdf -------------------------------------------------------------------------------- /Tikz learning.tex: -------------------------------------------------------------------------------- 1 | \documentclass[cn,11pt, simple]{elegantbook} 2 | 3 | \title{TikZ学习入门之葵花宝典} 4 | \subtitle{未完续} 5 | 6 | \author{八一} 7 | \institute{ hoganbin1995@outlook.com} 8 | \weixin{八一考研数学竞赛} 9 | \date{ \today} 10 | 11 | \input{settings} 12 | \version{3.09} 13 | 14 | 15 | \extrainfo{人生的意义,在于折腾} 16 | 17 | \logo{logo.png} 18 | \cover{cover.pdf} 19 | \includeonly{class/ch01} 20 | 21 | 22 | 23 | \begin{document} 24 | \maketitle 25 | \tableofcontents 26 | % \thispagestyle{empty} 27 | \mainmatter 28 | \hypersetup{pageanchor=true} 29 | 30 | \chapter*{前言} 31 | 32 | 在学习\LaTeX 与 TikZ过程中,八一发现到大家其学习\LaTeX 曲线陡峭,它并非所见即所得,可能一个微小的改动需要长时间的全文编译,而且代码并不能真正显示事物本来的样子,TikZ 的底层是 PGF(portable graphics format) ,即它是PGF 的前端。 33 | 34 | 它也并不是唯一可以在 \LaTeX 中画出漂亮图的宏包,比如 xfig 就可以代替它。另外 pstricks 和 metapost 都可以完成 TikZ 的工作;在PGF 中有很多优秀的并且可以独立于 PGF 之外运行的包。比如pgfpages宏包,它功能强大,可以合并多页,可以制作水印,可以将多页缩放到一个页面里;pgfplots宏包可直接调用一个axis环境和进行一些简单的优化来绘制函数并通过数据点拟合函数和散点图等。 35 | 36 | 那我们开始学习TikZ,首先得有个前提工作:这里的\lstinline|tikz|宏包的加载是必须的,而\lstinline|tikz|有两种使用方法:一种命令式用\lstinline|\tikz|命令,是行内模式;一种环境式用\lstinline|tikzpicture|环境命令包围起来,是行间模式。如下所示: 37 | \begin{lstlisting} 38 | \tikz{\draw (1,0) -- (0,1) -- (-1,0) -- (0,-1) -- cycle;} 39 | \begin{tikzpicture} 40 | \draw (1,0) -- (0,1) -- (-1,0) -- (0,-1) -- cycle; 41 | \end{tikzpicture} 42 | \end{lstlisting} 43 | 44 | 行内模式对于注重内容的用户相对较少,基本不用,这种模式下直接调用而\lstinline|\tikz|命令。但不管是注重华丽表现效果还是注重内容的用户,总是会有需求需要某一整张图片来表达某些内容,而\lstinline|tikz|以及其他基于\lstinline|tikz|的宏包在命令行绘图这个领域是不错的。下面将主要使用\lstinline|tikzpicture|环境命令模式。 45 | 46 | 用\lstinline|tikz|绘制某个单独的图片而不是一般的A4页面推荐使用 standalone 类。如下所示: 47 | \begin{lstlisting} 48 | \documentclass[tikz,border=2pt]{standalone} 49 | \begin{document} 50 | \begin{tikzpicture} 51 | \draw[step=1,color=gray!40] (-2,-2) grid (2,2); 52 | \draw[->] (-3,0) -- (3,0); 53 | \draw[->] (0,-3) -- (0,3); 54 | \draw (0,0) circle (1); 55 | \end{tikzpicture} 56 | \end{document} 57 | \end{lstlisting} 58 | 59 | \include{class/ch01} 60 | \include{class/ch02} 61 | \include{class/ch03} 62 | \include{class/ch04} 63 | \include{class/ch05} 64 | \include{class/ch06} 65 | \include{class/ch07} 66 | \include{class/ch08} 67 | \include{class/ch10} 68 | \include{class/ch09} 69 | 70 | \nocite{*} 71 | \begin{thebibliography}{99} 72 | 73 | \addcontentsline{toc}{section}{参考文献} % 在目录中显示参考文献 74 | 75 | \bibitem{1} \url{http://hohei3108.hatenablog.com/entry/2017/10/15/000611} 76 | 77 | \bibitem{2} \url{https://blog.csdn.net/stereohomology/article/details/24266409} 78 | 79 | \bibitem{3} \href{https://www.latexstudio.net/}{\LaTeX 科技排版工作室} 80 | 81 | \bibitem{4} \url{https://github.com/Chris7462/TikZ} 82 | 83 | \bibitem{5} \url{http://blog.sina.com.cn/s/blog_72277faf0100xqz6.html} 84 | \end{thebibliography} 85 | %\bibliography{reference} 86 | 87 | \end{document} 88 | 89 | -------------------------------------------------------------------------------- /class/ch01.tex: -------------------------------------------------------------------------------- 1 | \chapter{基础准备} 2 | \begin{introduction} 3 | \item 点 4 | \item 圆 5 | \item 矩形 6 | \item 抛物线 7 | \item 文本 8 | \item 直线 9 | \item 抛物线 10 | \item pgfplots 11 | \end{introduction} 12 | \section{点(Point Path)} 13 | 一行的中间高度画一个半径为一半行高的红点\tikz \filldraw [red ] (0.5 ex ,0.5ex ) circle [radius =0.5 ex ];使用coordinate命令或者path命令附带coordinate来定义一个点。 14 | \begin{lstlisting} 15 | \begin{tikzpicture} 16 | \draw[step=1,color=gray!40] (-2,-2) grid (2,2); 17 | \path (1,1) coordinate (p1); 18 | \coordinate (p2) at ( 2, 0); 19 | \draw[dotted, red] (p1) -- (p2) ; 20 | \end{tikzpicture} 21 | \end{lstlisting} 22 | \begin{center} 23 | \begin{tikzpicture} 24 | \draw[step=1,color=gray!40] (-2,-2) grid (2,2); 25 | \path (1,1) coordinate (p1); 26 | \coordinate (p2) at ( 2, 0); 27 | \draw[dotted, red] (p1) -- (p2) ; 28 | \end{tikzpicture} 29 | \end{center} 30 | \subsection{控制点} 31 | 起点$x$的控制点 $y$,指的是曲线所在点 $x$ 处的切线方向指向 $y$ 点。如图所示。点 $x_{1} (0,0)$ 处的切线方向指向点$ y_{1} (1,1)$,点 $x_{2} (2,0)$ 点的切线方向指向点 $y_{2} (2,1)$,用法如下: 32 | \begin{verbatim} 33 | \draw[options] (x1,y1) .. controls (x2,y2) and (x3,y3) .. (x4,y4); 34 | \end{verbatim} 35 | \begin{lstlisting} 36 | \begin{tikzpicture} 37 | \filldraw[gray] (0,0) circle (2pt) (1,1) circle (2pt) 38 | (2,1) circle (2pt) (2,0) circle (2pt); 39 | \draw (0,0) .. controls (1,1) and (2,1) .. (2,0); 40 | \end{tikzpicture} 41 | \begin{tikzpicture} 42 | \filldraw (0,0) circle [radius =2 pt ] node [left ] {$ x _1$}; 43 | \filldraw [gray ] (1,1) circle [radius =2 pt ] node [left ] {$ y _1$}; 44 | \filldraw [gray ] (2,1) circle [radius =2 pt ] node [right ] {$ y_2$}; 45 | \filldraw (2,0) circle [radius =2 pt ] node [right ] {$ x _2$}; 46 | \draw (0,0) .. controls (1,1) and (2,1) .. (2,0); % 核心代码 47 | \end{tikzpicture} 48 | \begin{tikzpicture} 49 | \draw (0,0) .. controls (1,1) and (2,1) .. (4,0); 50 | \fill (1,1) circle (1pt) (2,1) circle (1pt); 51 | \end{tikzpicture} 52 | \end{lstlisting} 53 | \begin{center} 54 | \begin{tikzpicture} 55 | \filldraw[gray] (0,0) circle (2pt) (1,1) circle (2pt) 56 | (2,1) circle (2pt) (2,0) circle (2pt); 57 | \draw (0,0) .. controls (1,1) and (2,1) .. (2,0); 58 | \end{tikzpicture} 59 | \begin{tikzpicture} 60 | \filldraw (0,0) circle [radius =2 pt ] node [left ] {$ x _1$}; 61 | \filldraw [gray ] (1,1) circle [radius =2 pt ] node [left ] {$ y _1$}; 62 | \filldraw [gray ] (2,1) circle [radius =2 pt ] node [right ] {$ y_2$}; 63 | \filldraw (2,0) circle [radius =2 pt ] node [right ] {$ x _2$}; 64 | \draw (0,0) .. controls (1,1) and (2,1) .. (2,0); % 核心代码 65 | \end{tikzpicture} 66 | \begin{tikzpicture} 67 | \draw (0,0) .. controls (1,1) and (2,1) .. (4,0); 68 | \fill (1,1) circle (1pt) (2,1) circle (1pt); 69 | \end{tikzpicture} 70 | \end{center} 71 | 再来一个控制点的例子:用控制点画一个半圆,见下图。当然,本例只是阐释控制点,实际中很少用这种方式画半圆。 72 | \begin{lstlisting} 73 | \begin{tikzpicture} 74 | \draw (- 1.5,0) -- (1.5,0); 75 | \draw (0,- 0.5) -- (0,1.5); 76 | % show the control points 77 | \filldraw [gray ] ( - 1,0) circle [radius =2 pt ] 78 | (1,0) circle [radius =2 pt ] 79 | [cyan ] (- 1,0.555) circle [radius =2 pt ] 80 | [cyan ] (- 0.555,1) circle [radius =2 pt ] 81 | [cyan ] (0.555,1) circle [radius =2 pt ] 82 | [cyan ] (1,0.555) circle [radius =2 pt ]; 83 | \draw (- 1,0) .. controls (- 1,0.555) and (- 0.555,1) .. (0,1) .. controls (0.555,1) and (1,0.555) .. (1,0); 84 | \end{tikzpicture} 85 | \end{lstlisting} 86 | \begin{center} 87 | \begin{tikzpicture} 88 | \draw (- 1.5,0) -- (1.5,0); 89 | \draw (0,- 0.5) -- (0,1.5); 90 | % show the control points 91 | \filldraw [gray ] ( - 1,0) circle [radius =2 pt ] 92 | (1,0) circle [radius =2 pt ] 93 | [cyan ] (- 1,0.555) circle [radius =2 pt ] 94 | [cyan ] (- 0.555,1) circle [radius =2 pt ] 95 | [cyan ] (0.555,1) circle [radius =2 pt ] 96 | [cyan ] (1,0.555) circle [radius =2 pt ]; 97 | \draw (- 1,0) .. controls (- 1,0.555) and (- 0.555,1) .. (0,1) .. controls (0.555,1) and (1,0.555) .. (1,0); 98 | \end{tikzpicture} 99 | \end{center} 100 | 贝塞尔曲线是四个点画出一个曲线,。其中第一个点是起点,第四个点终点,然后另外两个点是控制点。 101 | \begin{lstlisting} 102 | \begin{tikzpicture}[scale=3] 103 | \draw[help lines] (0,0) grid (2,2); 104 | \draw[color=red] (0,0) .. controls (1,1) and (2,1) .. (2,0); 105 | \shade[ball color=gray!10] (0,0) circle (0.1); 106 | \shade[ball color=gray!40] (1,1) circle (0.1); 107 | \shade[ball color=gray!70] (2,1) circle (0.1); 108 | \shade[ball color=gray] (2,0) circle (0.1); 109 | \end{tikzpicture} 110 | \end{lstlisting} 111 | \begin{center} 112 | \begin{tikzpicture}[scale=3] 113 | \draw[help lines] (0,0) grid (2,2); 114 | \draw[color=red] (0,0) .. controls (1,1) and (2,1) .. (2,0); 115 | \shade[ball color=gray!10] (0,0) circle (0.1); 116 | \shade[ball color=gray!40] (1,1) circle (0.1); 117 | \shade[ball color=gray!70] (2,1) circle (0.1); 118 | \shade[ball color=gray] (2,0) circle (0.1); 119 | \end{tikzpicture} 120 | \end{center} 121 | \subsection{点的相对偏移} 122 | tikz中有一个重要的概念,当前点,然后点可以通过当前点根据相对偏移来确定一个新的点。上面代码第9行的 ++ 符号和第10行的 + 符号都根据当前点然后进行了 $\Delta x$ 和 $\Delta y$ 的相对偏移从而确定了一个新的点。这两个符号的区别在于是不是更新当前点数据。++符号更新当前点,而+符号不更新。 123 | 124 | ++适合描述一连串逐渐变化的点,+适合描述多个点围绕着一个点变化的情况。 125 | \begin{lstlisting} 126 | \begin{tikzpicture}[scale=1] 127 | \draw[step=1,color=gray!40] (-2,-2) grid (2,2); 128 | \draw[latex-latex, red] (0,-2) -- ++(-1,1) -- ++(-1,-1); 129 | \draw[dashed, blue] (0,1) -- +(-1,1) -- +(-2,0); 130 | \end{tikzpicture} 131 | \end{lstlisting} 132 | \begin{center} 133 | \begin{tikzpicture}[scale=1] 134 | \draw[step=1,color=gray!40] (-2,-2) grid (2,2); 135 | \draw[latex-latex, red] (0,-2) -- ++(-1,1) -- ++(-1,-1); 136 | \draw[dashed, blue] (0,1) -- +(-1,1) -- +(-2,0); 137 | \end{tikzpicture} 138 | \end{center} 139 | 140 | \subsection{node命令中点的定义} 141 | tikz中的点也支持极坐标表示,(30:1cm),第一个参数是极座标里面的角度,第二个参数是半径。 142 | \begin{lstlisting} 143 | \begin{tikzpicture} 144 | \node (node001) at (0,2) [draw] {test math competition}; 145 | \end{tikzpicture} 146 | \end{lstlisting} 147 | \begin{center} 148 | \begin{tikzpicture} 149 | \node (node001) at (0,2) [draw] {test math competition}; 150 | \end{tikzpicture} 151 | \end{center} 152 | 153 | 从这里可以看到只要写上draw选项外面就会加上一个长方形,也就是shape的默认选项是rectangle。如果你不希望外面有长方形,不写draw选项即可。 154 | 155 | 这里通过node命令定义了一个点,node001,在(0,2)那里。后面是可以使用的。 156 | \begin{lstlisting} 157 | \begin{tikzpicture} 158 | \node (node001) at (0,2) [draw] {node001}; 159 | \node (node002) at (-2,0) [draw] {node002}; 160 | \node (node003) at (2,0) [draw] {node003}; 161 | \draw (node cs:name=node003,anchor=north) |- (0,1); 162 | \draw (node002.north) |- (0,1) -| (node cs:name=node001,anchor=south); 163 | \end{tikzpicture} 164 | \end{lstlisting} 165 | \begin{center} 166 | \begin{tikzpicture} 167 | \node (node001) at (0,2) [draw] {node001}; 168 | \node (node002) at (-2,0) [draw] {node002}; 169 | \node (node003) at (2,0) [draw] {node003}; 170 | \draw (node cs:name=node003,anchor=north) |- (0,1); 171 | \draw (node002.north) |- (0,1) -| (node cs:name=node001,anchor=south); 172 | \end{tikzpicture} 173 | 174 | \end{center} 175 | 176 | 这里通过 node cs:name=node003 来获取之前那个node所在的点,然后通过 anchor=north 来定义那个node的接口在北边。除此之外的选项还有: south ,east ,west 。这里 |- 似乎是画垂直拐线的意思。上面的语法简写为可以node002.north。 177 | 178 | 此外还有 angle 选项控制node接口的开口角度。 179 | 180 | \subsection{两个点定义出一个点} 181 | \begin{lstlisting} 182 | \begin{tikzpicture} 183 | \node (p1) at (30:1) {$p_1$} ; 184 | \node (p2) at (75:1) {$p_2$} ; 185 | \draw (-0.2,0) -- (1.2,0) node[right] (xline) {$q_1$}; 186 | \draw (2,-0.2) -- (2,1.2) node[above] (yline) {$q_2$}; 187 | \draw[->] (p1) -- (p1 |- xline); 188 | \end{tikzpicture} 189 | 190 | \end{lstlisting} 191 | \begin{center} 192 | \begin{tikzpicture} 193 | \node (p1) at (30:1) {$p_1$} ; 194 | \node (p2) at (75:1) {$p_2$} ; 195 | \draw (-0.2,0) -- (1.2,0) node[right] (xline) {$q_1$}; 196 | \draw (2,-0.2) -- (2,1.2) node[above] (yline) {$q_2$}; 197 | \draw[->] (p1) -- (p1 |- xline); 198 | \end{tikzpicture} 199 | \end{center} 200 | 201 | 这种形式 (p1 |- xline) 表示取第一个点的$x$和第二个点的$y$组成一个新的点。如果是 (p1 -| xline) 表示取第二个点的$x$和第一个点的$y$组成一个新的点。 202 | 203 | 两个path的交点 204 | \begin{lstlisting} 205 | \begin{tikzpicture}[scale=3] 206 | \draw[help lines] (0,0) grid (2,2); 207 | \coordinate (A) at (0,0); 208 | \coordinate (B) at (2,0.5); 209 | \coordinate (C) at (2,0); 210 | \coordinate (D) at (0,2); 211 | \shade[ball color=red](A) circle (0.025) node[below] {A}; 212 | \shade[ball color=red](B) circle (0.025) node[below] {B}; 213 | \shade[ball color=red](C) circle (0.025) node[below] {C}; 214 | \shade[ball color=red](D) circle (0.025) node[below] {D}; 215 | \draw[name path=AB] (A) -- (B); \draw[name path=CD] (C) -- (D); 216 | \path[name intersections={of=AB and CD}] (intersection-1) coordinate (P); 217 | \shade[ball color=red](P) circle (0.025) node[below] {P}; 218 | \end{tikzpicture} 219 | \end{lstlisting} 220 | \begin{center} 221 | \begin{tikzpicture}[scale=3] 222 | \draw[help lines] (0,0) grid (2,2); 223 | \coordinate (A) at (0,0); 224 | \coordinate (B) at (2,0.5); 225 | \coordinate (C) at (2,0); 226 | \coordinate (D) at (0,2); 227 | \shade[ball color=red](A) circle (0.025) node[below] {A}; 228 | \shade[ball color=red](B) circle (0.025) node[below] {B}; 229 | \shade[ball color=red](C) circle (0.025) node[below] {C}; 230 | \shade[ball color=red](D) circle (0.025) node[below] {D}; 231 | \draw[name path=AB] (A) -- (B); \draw[name path=CD] (C) -- (D); 232 | \path[name intersections={of=AB and CD}] (intersection-1) coordinate (P); 233 | \shade[ball color=red](P) circle (0.025) node[below] {P}; 234 | \end{tikzpicture} 235 | \end{center} 236 | 237 | 这个例子用到了点的定义,点的标出,以及path交点的定义,要用到library: intersections 。有时候有些路径你不希望显示出来那么就用path命令来定义路径。 238 | 239 | 给新交点取名字:用 by 选项可以给画出来的交点取一个名字,默认的 intersection-1 之类的也可以使用。此外还可以加上选项: 240 | 241 | \begin{Verbatim} 242 | \path[name intersections={of=D and E,by={[label=above:$C$]C,[label=below:$C'$]C'}}]; 243 | \end{Verbatim} 244 | \section{圆(Circle Path)} 245 | 我们已经知道如何使用 tikz 在行内画图, 下面我们用以下代码在文中画出图 246 | \begin{lstlisting} 247 | \begin{tikzpicture} 248 | \draw[step=1,color=gray!40] (-2,-2) grid (2,2); 249 | \draw[->] (-3,0) -- (3,0); 250 | \draw[->] (0,-3) -- (0,3); 251 | \draw (0,0) circle (1); 252 | \end{tikzpicture} 253 | \end{lstlisting} 254 | \begin{center} 255 | \begin{tikzpicture} 256 | \draw[step=1,color=gray!40] (-2,-2) grid (2,2); 257 | \draw[->] (-3,0) -- (3,0); 258 | \draw[->] (0,-3) -- (0,3); 259 | \draw (0,0) circle (1); 260 | \end{tikzpicture} 261 | \end{center} 262 | 263 | 其中第一个点是圆中心,\lstinline{circle}表示画圆,第二个参数是半径大小. 264 | 265 | \begin{lstlisting} 266 | \begin{tikzpicture} 267 | \draw[step=1,color=gray!40] (-2,-2) grid (2,2); 268 | \draw[->] (-3,0) -- (3,0); 269 | \draw[->] (0,-3) -- (0,3); 270 | \draw (0,0) ellipse (1 and 0.5); 271 | \end{tikzpicture} 272 | \end{lstlisting} 273 | \begin{center} 274 | \begin{tikzpicture} 275 | \draw[step=1,color=gray!40] (-2,-2) grid (2,2); 276 | \draw[->] (-3,0) -- (3,0); 277 | \draw[->] (0,-3) -- (0,3); 278 | \draw (0,0) ellipse (1 and 0.5); 279 | \end{tikzpicture} 280 | \end{center} 281 | 282 | 这里第一个点是椭圆的中心点,ellipse表示画椭圆,后面参数两个值第一个是a也就是椭圆的半长轴,第二个是b也就是椭圆的半短轴。用法: 283 | \begin{Verbatim} 284 | \draw[options] (x,y) circle (raidus); 285 | \draw[options] (x,y) ellipse (x.raidus anda y.radius); 286 | \end{Verbatim} 287 | 288 | \begin{lstlisting} 289 | \begin{tikzpicture} 290 | \draw (0,0) circle (10pt); 291 | \draw[red] (1,0) circle (15pt); 292 | \draw[fill=red] (2,0) circle (20pt); 293 | \draw[red,fill=red] (3,0) ellipse (20pt and 25pt); 294 | \filldraw[blue,rotate=30] (3.5,-2) ellipse (25pt and 30pt); % another way 295 | \end{tikzpicture} 296 | 297 | \begin{tikzpicture} 298 | \draw (- 20pt,0) node [auto] {(a)}; 299 | \draw [thick ,blue ] (0pt ,0pt ) circle [radius =10 pt ] ; 300 | 301 | \draw (30pt,0) node [auto] {(b)}; 302 | \draw [rotate =15] (60pt ,0) ellipse [x radius =20 pt , y radius =10 pt ]; 303 | \end{tikzpicture} 304 | \tikz {\draw (0,0) circle (1);\fill [green](0,0) circle (1);} 305 | \tikz \filldraw [red] (0,0) ellipse (2 and 1); 306 | \begin{tikzpicture}[line width=1pt] 307 | \draw (0,0)circle(1.0) (1,0)circle(1.0) 308 | (60:1)circle(1.0); 309 | \clip (0,0) circle (1.0); 310 | \clip (1,0) circle (1.0); 311 | \fill[blue] (60:1)circle(1.0); 312 | \end{tikzpicture} 313 | \begin{center} 314 | \tikz {\draw (0,0)coordinate(D) node[below left=-0.5pt and -4pt]{$D$} --(0,1)coordinate(A) node[above left=-0.5pt and -4pt]{$A$}--(2,1)coordinate(B) node[above]{$B$} -- (1, 1) arc [start angle=90, end angle=180, radius=1] rectangle (2,1)--(0,0)-- (2, 0)coordinate(C) node[below]{$C$} ; 315 | \fill [green](0, 0) -- (2, 1) -- (1, 1)arc [start angle=90, end angle=180, radius=1] -- cycle; 316 | \clip (0,0) rectangle (2,1); 317 | \draw (1,0) circle(1); 318 | \draw (0,0) -- (2,0);} 319 | \end{center} 320 | \end{lstlisting} 321 | \begin{center} 322 | \begin{tikzpicture} 323 | \draw (0,0) circle (10pt); 324 | \draw[red] (1,0) circle (15pt); 325 | \draw[fill=red] (3,0) circle (20pt); 326 | \draw[red,fill=red] (5,0) ellipse (20pt and 25pt); 327 | \filldraw[blue,rotate=30] (6.5,-2) ellipse (25pt and 30pt); % another way 328 | \end{tikzpicture} 329 | \end{center} 330 | \begin{tikzpicture} 331 | \draw (- 20pt,0) node [auto] {(a)}; 332 | \draw [thick ,blue ] (0pt ,0pt ) circle [radius =10 pt ] ; 333 | \draw (30pt,0) node [auto] {(b)}; 334 | \draw [rotate =15] (60pt ,0) ellipse [x radius =20 pt , y radius =10 pt ]; 335 | \end{tikzpicture} 336 | \tikz {\draw (0,0) circle (1);\fill [green](0,0) circle (1);} 337 | \tikz \filldraw [red] (0,0) ellipse (2 and 1); 338 | \begin{tikzpicture}[line width=1pt] 339 | \draw (0,0)circle(1.0) (1,0)circle(1.0) 340 | (60:1)circle(1.0); 341 | \clip (0,0) circle (1.0); 342 | \clip (1,0) circle (1.0); 343 | \fill[blue] (60:1)circle(1.0); 344 | \end{tikzpicture} 345 | \begin{center} 346 | \tikz {\draw (0,0)coordinate(D) node[below left=-0.5pt and -4pt]{$D$} --(0,1)coordinate(A) node[above left=-0.5pt and -4pt]{$A$}--(2,1)coordinate(B) node[above]{$B$} -- (1, 1) arc [start angle=90, end angle=180, radius=1] rectangle (2,1)--(0,0)-- (2, 0)coordinate(C) node[below]{$C$} ; 347 | \fill [green](0, 0) -- (2, 1) -- (1, 1)arc [start angle=90, end angle=180, radius=1] -- cycle; 348 | \clip (0,0) rectangle (2,1); 349 | \draw (1,0) circle(1); 350 | \draw (0,0) -- (2,0);} 351 | \end{center} 352 | \begin{lstlisting} 353 | \begin{tikzpicture}[scale=0.5,thick] 354 | \def\a{5}%长半轴 355 | \def\b{3}%短半轴 356 | \def\c{4}%焦半轴 357 | \def\ptsize{2.0pt} %点的半径 358 | 359 | %x 轴 和 y轴 360 | \path[name path=xaxis,thick,draw,->](-6,0)--(6,0) node[right] {$x$}; 361 | \path[name path=yaxis,thick,draw,->](0,-6)--(0,6) node[above,right] {$y$}; 362 | %x 轴 与 y 轴的交点 363 | \path [name intersections={of = xaxis and yaxis}]; 364 | \coordinate[label=below right:$O$] (O) at (intersection-1); 365 | %画一个椭圆 366 | \draw [name path = myellipse ] (intersection-1) ellipse (\a cm and \b cm); 367 | %椭圆与x 轴交点 368 | \path [name intersections={of = xaxis and myellipse}]; 369 | \coordinate[label=below right:$A_2$] (a2) at (intersection-1); 370 | \coordinate[label=below left:$A_1$] (a1) at (intersection-2); 371 | %椭圆与y 轴交点 372 | \path [name intersections={of = yaxis and myellipse}]; 373 | \coordinate[label=above right:$B_2$] (b2) at (intersection-1); 374 | \coordinate[label=below right:$B_1$] (b1) at (intersection-2); 375 | %焦点 376 | \coordinate[label=below :$F_1$] (f1) at (-\c,0); 377 | \coordinate[label=below :$F_2$] (f2) at (\c,0); 378 | %a b c 的几何意义 379 | \draw (b2) --(f2) node[midway,above] {$a$}; 380 | \draw (b2) --(O) node[midway,left] {$b$}; 381 | \draw (O) --(f2) node[midway,below] {$c$}; 382 | %阴影部分填充 383 | \fill [pattern =north west lines,pattern color = black!70](b2)--(O)--(f2)--cycle; 384 | %画点 385 | \foreach \p in {O,a1,a2,b1,b2,f1,f2} 386 | \fill (\p) circle (\ptsize); 387 | %在图像右侧再画一个焦点在y轴上的椭圆 388 | \begin{scope}[xshift=13cm] 389 | \path[name path=xaxis,thick,draw,->](-6,0)--(6,0) node[right] {$x$}; 390 | \path[name path=yaxis,thick,draw,->](0,-6)--(0,6) node[above,right] {$y$}; 391 | \path [name intersections={of = xaxis and yaxis}]; 392 | \coordinate[label=below right:$O$] (O) at (intersection-1); 393 | %画一个椭圆 394 | \draw [name path = myellipse ] (intersection-1) ellipse (\b cm and \a cm); 395 | 396 | \path [name intersections={of = xaxis and myellipse}]; 397 | \coordinate[label=below right:$B_2$] (a2) at (intersection-1); 398 | \coordinate[label=below left:$B_1$] (a1) at (intersection-2); 399 | 400 | \path [name intersections={of = yaxis and myellipse}]; 401 | \coordinate[label=above right:$A_2$] (b2) at (intersection-1); 402 | \coordinate[label=below right:$A_1$] (b1) at (intersection-2); 403 | 404 | \coordinate[label=left :$F_1$] (f1) at (0,-\c); 405 | \coordinate[label=left :$F_2$] (f2) at (0,\c); 406 | 407 | \draw (a2) --(f2) node[midway,above] {$a$}; 408 | \draw (a2) --(O) node[midway,below] {$b$}; 409 | \draw (O) --(f2) node[midway,left] {$c$}; 410 | 411 | \fill [pattern =north west lines,pattern color = black!70](a2)--(O)--(f2)--cycle; 412 | 413 | \foreach \p in {O,a1,a2,b1,b2,f1,f2} 414 | \fill (\p) circle (\ptsize); 415 | 416 | \end{scope} 417 | \end{tikzpicture} 418 | \end{lstlisting} 419 | \begin{tikzpicture}[scale=0.5,thick] 420 | \def\a{5}%长半轴 421 | \def\b{3}%短半轴 422 | \def\c{4}%焦半轴 423 | \def\ptsize{2.0pt} %点的半径 424 | 425 | %x 轴 和 y轴 426 | \path[name path=xaxis,thick,draw,->](-6,0)--(6,0) node[right] {$x$}; 427 | \path[name path=yaxis,thick,draw,->](0,-6)--(0,6) node[above,right] {$y$}; 428 | %x 轴 与 y 轴的交点 429 | \path [name intersections={of = xaxis and yaxis}]; 430 | \coordinate[label=below right:$O$] (O) at (intersection-1); 431 | %画一个椭圆 432 | \draw [name path = myellipse ] (intersection-1) ellipse (\a cm and \b cm); 433 | %椭圆与x 轴交点 434 | \path [name intersections={of = xaxis and myellipse}]; 435 | \coordinate[label=below right:$A_2$] (a2) at (intersection-1); 436 | \coordinate[label=below left:$A_1$] (a1) at (intersection-2); 437 | %椭圆与y 轴交点 438 | \path [name intersections={of = yaxis and myellipse}]; 439 | \coordinate[label=above right:$B_2$] (b2) at (intersection-1); 440 | \coordinate[label=below right:$B_1$] (b1) at (intersection-2); 441 | %焦点 442 | \coordinate[label=below :$F_1$] (f1) at (-\c,0); 443 | \coordinate[label=below :$F_2$] (f2) at (\c,0); 444 | %a b c 的几何意义 445 | \draw (b2) --(f2) node[midway,above] {$a$}; 446 | \draw (b2) --(O) node[midway,left] {$b$}; 447 | \draw (O) --(f2) node[midway,below] {$c$}; 448 | %阴影部分填充 449 | \fill [pattern =north west lines,pattern color = black!70](b2)--(O)--(f2)--cycle; 450 | %画点 451 | \foreach \p in {O,a1,a2,b1,b2,f1,f2} 452 | \fill (\p) circle (\ptsize); 453 | %在图像右侧再画一个焦点在y轴上的椭圆 454 | \begin{scope}[xshift=13cm] 455 | \path[name path=xaxis,thick,draw,->](-6,0)--(6,0) node[right] {$x$}; 456 | \path[name path=yaxis,thick,draw,->](0,-6)--(0,6) node[above,right] {$y$}; 457 | \path [name intersections={of = xaxis and yaxis}]; 458 | \coordinate[label=below right:$O$] (O) at (intersection-1); 459 | %画一个椭圆 460 | \draw [name path = myellipse ] (intersection-1) ellipse (\b cm and \a cm); 461 | 462 | \path [name intersections={of = xaxis and myellipse}]; 463 | \coordinate[label=below right:$B_2$] (a2) at (intersection-1); 464 | \coordinate[label=below left:$B_1$] (a1) at (intersection-2); 465 | 466 | \path [name intersections={of = yaxis and myellipse}]; 467 | \coordinate[label=above right:$A_2$] (b2) at (intersection-1); 468 | \coordinate[label=below right:$A_1$] (b1) at (intersection-2); 469 | 470 | \coordinate[label=left :$F_1$] (f1) at (0,-\c); 471 | \coordinate[label=left :$F_2$] (f2) at (0,\c); 472 | 473 | \draw (a2) --(f2) node[midway,above] {$a$}; 474 | \draw (a2) --(O) node[midway,below] {$b$}; 475 | \draw (O) --(f2) node[midway,left] {$c$}; 476 | 477 | \fill [pattern =north west lines,pattern color = black!70](a2)--(O)--(f2)--cycle; 478 | 479 | \foreach \p in {O,a1,a2,b1,b2,f1,f2} 480 | \fill (\p) circle (\ptsize); 481 | 482 | \end{scope} 483 | 484 | \end{tikzpicture} 485 | \begin{lstlisting} 486 | \begin{tikzpicture} 487 | \draw(3,-1) coordinate (A) node[right] {A} 488 | -- (0,0) coordinate (B) node[left] {B} 489 | -- (2,2) coordinate (C) node[above right] {C} 490 | pic["$60\circ$", draw=orange, <->, angle eccentricity=1.2, angle radius=1cm] 491 | {angle=A--B--C}; 492 | \end{tikzpicture} 493 | 494 | \begin{tikzpicture} 495 | \draw(0,0) circle(4cm); %画一个4cm的圆圈 496 | %把圆的右半边填黑 497 | \begin{scope} 498 | \clip(0,0) circle(4cm); 499 | \fill[black] (0,-4) rectangle (4,4); 500 | \end{scope} 501 | %填黑八卦图左边的半圆 502 | \begin{scope} 503 | \clip(0,2) circle(2cm); 504 | \fill[black] (-4,0) rectangle (4,4); 505 | \end{scope} 506 | %填白八卦图右边的半圆 507 | \begin{scope} 508 | \clip(0,-2) circle(2cm); 509 | \fill[white] (-4,0) rectangle (4,-4); 510 | \end{scope} 511 | %把黑色部分的小圆圈填为白色 512 | \begin{scope} 513 | \clip(0,2) circle(0.5cm); 514 | \fill[white] (-4,0) rectangle (4,4); 515 | \end{scope} 516 | %绘制下面的白色圆圈 517 | \draw(0,-2) circle(0.5cm); 518 | \end{tikzpicture} 519 | \end{lstlisting} 520 | \begin{tikzpicture} 521 | \draw(3,-1) coordinate (A) node[right] {A} 522 | -- (0,0) coordinate (B) node[left] {B} 523 | -- (2,2) coordinate (C) node[above right] {C} 524 | pic["$60\circ$", draw=orange, <->, angle eccentricity=1.2, angle radius=1cm] 525 | {angle=A--B--C}; 526 | \end{tikzpicture} 527 | \begin{tikzpicture} 528 | \draw(0,0) circle(4cm); %画一个4cm的圆圈 529 | %把圆的右半边填黑 530 | \begin{scope} 531 | \clip(0,0) circle(4cm); 532 | \fill[black] (0,-4) rectangle (4,4); 533 | \end{scope} 534 | %填黑八卦图左边的半圆 535 | \begin{scope} 536 | \clip(0,2) circle(2cm); 537 | \fill[black] (-4,0) rectangle (4,4); 538 | \end{scope} 539 | %填白八卦图右边的半圆 540 | \begin{scope} 541 | \clip(0,-2) circle(2cm); 542 | \fill[white] (-4,0) rectangle (4,-4); 543 | \end{scope} 544 | %把黑色部分的小圆圈填为白色 545 | \begin{scope} 546 | \clip(0,2) circle(0.5cm); 547 | \fill[white] (-4,0) rectangle (4,4); 548 | \end{scope} 549 | %绘制下面的白色圆圈 550 | \draw(0,-2) circle(0.5cm); 551 | \end{tikzpicture} 552 | \begin{lstlisting} 553 | \begin{center} 554 | \begin{tikzpicture} 555 | \foreach \x in {0,1,...,10} { 556 | \node[draw, circle, inner sep=0pt, minimum size=\x mm] {}; 557 | } 558 | \foreach \a/\x/\y in {1/orange/八一杯, 2/teal/团子杯, 3/magenta/熊赛} { 559 | \node[circle, minimum size=2*\a mm, draw=\x!90, fill=\x!30, text=\x!70] at (2*\a, 0) {\y}; 560 | } 561 | \end{tikzpicture} 562 | 563 | \begin{tikzpicture} 564 | \tikzstyle{main}=[circle, minimum size = 10mm, thick, draw =black!80, node distance = 16mm] 565 | \tikzstyle{connect}=[-latex, thick] 566 | \tikzstyle{box}=[rectangle, draw=black!100] 567 | \node[main, fill = white!100] (z) [label=below:\emph{z}] { }; 568 | \node[main, fill = black!50] (d) [left=of z,label=below:$d$] { }; 569 | \node[main, fill = black!50] (w) [right=of z,label=below:$w$] {}; 570 | \path (d) edge [connect] (z) 571 | (z) edge [connect] (w); 572 | \node[rectangle, inner sep=0mm, fit= (z) (w),label=below right:$N$, xshift=13mm] {}; 573 | \node[rectangle, inner sep=5.6mm,draw=black!100, fit= (z) (w)] {}; 574 | \node[rectangle, inner sep=4.8mm, fit= (z) (w),label=below right:$M$, xshift=12.5mm] {}; 575 | \node[rectangle, inner sep=10.4mm, draw=black!100, fit = (d) (z) (w)] {}; 576 | \end{tikzpicture} 577 | \end{center} 578 | \end{lstlisting} 579 | \begin{center} 580 | \begin{tikzpicture} 581 | \foreach \x in {0,1,...,10} { 582 | \node[draw, circle, inner sep=0pt, minimum size=\x mm] {}; 583 | } 584 | \foreach \a/\x/\y in {1/orange/八一杯, 2/teal/团子杯, 3/magenta/熊赛} { 585 | \node[circle, minimum size=2*\a mm, draw=\x!90, fill=\x!30, text=\x!70] at (2*\a, 0) {\y}; 586 | } 587 | \end{tikzpicture} 588 | 589 | \begin{tikzpicture} 590 | \tikzstyle{main}=[circle, minimum size = 10mm, thick, draw =black!80, node distance = 16mm] 591 | \tikzstyle{connect}=[-latex, thick] 592 | \tikzstyle{box}=[rectangle, draw=black!100] 593 | \node[main, fill = white!100] (z) [label=below:\emph{z}] { }; 594 | \node[main, fill = black!50] (d) [left=of z,label=below:$d$] { }; 595 | \node[main, fill = black!50] (w) [right=of z,label=below:$w$] {}; 596 | \path (d) edge [connect] (z) 597 | (z) edge [connect] (w); 598 | \node[rectangle, inner sep=0mm, fit= (z) (w),label=below right:$N$, xshift=13mm] {}; 599 | \node[rectangle, inner sep=5.6mm,draw=black!100, fit= (z) (w)] {}; 600 | \node[rectangle, inner sep=4.8mm, fit= (z) (w),label=below right:$M$, xshift=12.5mm] {}; 601 | \node[rectangle, inner sep=10.4mm, draw=black!100, fit = (d) (z) (w)] {}; 602 | \end{tikzpicture} 603 | \end{center} 604 | \section{矩形与多边形(Rectangle Path)} 605 | 画正方形或矩形使用关键字 rectangle ,左下角和右上角坐标控制整个矩形的形状。如果将矩形旋转,则旋转角度以右下角坐标为轴心,逆时针方向旋转。用法如下: 606 | \begin{verbatim} 607 | \draw[options] (x1,y1) rectangle (x2,y2); 608 | \draw[options] (x,y) rectangle +(width,height); 609 | \end{verbatim} 610 | \begin{lstlisting} 611 | \begin{tikzpicture} 612 | \draw (-1,0) -- (1,0); 613 | \draw (0,-1) -- (0,1); 614 | \draw[rotate=30, fill=red] (-0.5,-0.5) rectangle (0.5,0.5); 615 | \draw (2,-0.5) rectangle +(1,1); 616 | \end{tikzpicture} 617 | \begin{tikzpicture}[scale=1.5] 618 | % 第一个坐标为左下角,第二个坐标为右上角。 619 | \filldraw [thick ,cyan ] (0.3,0) rectangle (0.8, 0.5); 620 | % 旋转角度以右下角坐标为轴心 ,逆时针旋转。 621 | \filldraw [thick ,yellow ,rotate =15] (- 0.5,0) rectangle (0,0.5); 622 | \draw [thick ,green ] (- 0.5,0) rectangle (0,0.5); 623 | \end{tikzpicture} 624 | \begin{tikzpicture}[line width=2pt] 625 | \draw (0,0) --(1,1) --(2,0) --cycle; 626 | \fill[blue] (0,0) --(1,1) --(2,0) --cycle; 627 | \end{tikzpicture} 628 | \tikz \draw (0,0) rectangle (2,1); 629 | \tikz \draw [step=0.5] (0,0) grid (3,2); 630 | \tikz {\draw (0,0) circle (1);\fill [green](0,0) circle (1);} 631 | \end{lstlisting} 632 | \begin{tikzpicture} 633 | \draw (-1,0) -- (1,0); 634 | \draw (0,-1) -- (0,1); 635 | \draw[rotate=30, fill=red] (-0.5,-0.5) rectangle (0.5,0.5); 636 | \draw (2,-0.5) rectangle +(1,1); 637 | \end{tikzpicture} 638 | \begin{tikzpicture}[scale=1.5] 639 | % 第一个坐标为左下角,第二个坐标为右上角。 640 | \filldraw [thick ,cyan ] (0.3,0) rectangle (0.8, 0.5); 641 | % 旋转角度以右下角坐标为轴心 ,逆时针旋转。 642 | \filldraw [thick ,yellow ,rotate =15] (- 0.5,0) rectangle (0,0.5); 643 | \draw [thick ,green ] (- 0.5,0) rectangle (0,0.5); 644 | \end{tikzpicture} 645 | \begin{tikzpicture}[line width=2pt] 646 | \draw (0,0) --(1,1) --(2,0) --cycle; 647 | \fill[blue] (0,0) --(1,1) --(2,0) --cycle; 648 | \end{tikzpicture} 649 | \tikz \draw (0,0) rectangle (2,1); 650 | \tikz \draw [step=0.5] (0,0) grid (3,2); 651 | \tikz {\draw (0,0) circle (1);\fill [green](0,0) circle (1);} 652 | \begin{lstlisting} 653 | \begin{tikzpicture}[scale=2] 654 | \draw[step=1,color=gray!40] (-2,-2) grid (2,2); 655 | \draw[color=red] (-1,-1) rectangle (1,1); 656 | \end{tikzpicture} 657 | \end{lstlisting} 658 | \begin{center} 659 | \begin{tikzpicture}[scale=2] 660 | \draw[step=1,color=gray!40] (-2,-2) grid (2,2); 661 | \draw[color=red] (-1,-1) rectangle (1,1); 662 | \end{tikzpicture} 663 | \end{center} 664 | 665 | 这里使用了可选项 color=red 来控制线条的颜色,然后画长方形的第一个点是左底点,rectangle表示画长方形,第二个点表示右顶点。如果想要放大图形,可在tikzpicture环境后面跟上可选项 [scale=2] ,即将图形放大两倍。 666 | \begin{lstlisting} 667 | \begin{tikzpicture} 668 | \draw (0,0) circle (4) ; 669 | \coordinate (O) at (0,0); 670 | \shade[ball color=red](O) circle (0.1) node[below] {O}; 671 | \def\n{5} 672 | \pgfmathsetmacro\i{\n-1} 673 | \foreach \x in {0,...,\i} 674 | { 675 | \def\pointname{\x} 676 | \coordinate (\pointname) at ($(0,0) +(\x*360/\n:4cm)$) ; 677 | \shade[ball color=red](\pointname) circle (0.05) node[below] {\small \x}; 678 | } 679 | 680 | \draw (0) 681 | \foreach \x in {0,...,\i} 682 | { -- (\x) } -- cycle; 683 | 684 | \end{tikzpicture} 685 | \end{lstlisting} 686 | \begin{center} 687 | \begin{tikzpicture} 688 | \draw (0,0) circle (4) ; 689 | \coordinate (O) at (0,0); 690 | \shade[ball color=red](O) circle (0.1) node[below] {O}; 691 | \def\n{5} 692 | \pgfmathsetmacro\i{\n-1} 693 | \foreach \x in {0,...,\i} 694 | { 695 | \def\pointname{\x} 696 | \coordinate (\pointname) at ($(0,0) +(\x*360/\n:4cm)$) ; 697 | \shade[ball color=red](\pointname) circle (0.05) node[below] {\small \x}; 698 | } 699 | 700 | \draw (0) 701 | \foreach \x in {0,...,\i} 702 | { -- (\x) } -- cycle; 703 | \end{tikzpicture} 704 | \end{center} 705 | 这个例子核心内容是批量定义点和点的运算,把这个弄懂了,后面tikz的核心大门就为你打开了,然后很多图形都可以用简洁的命令生成出来了。 706 | \section{网格(Grid Path)} 707 | 网格主要用于辅助绘图,其中 help lines 是个不错的参数设置。其用法: 708 | \begin{verbatim} 709 | \draw[options] (x1,y1) grid (x2,y2); 710 | \end{verbatim} 711 | \begin{lstlisting} 712 | \begin{tikzpicture} 713 | \draw[step=1.0cm, gray, very thin] (-1.4,-1.4) grid (1.4,1.4); 714 | \draw (-1.5,0) -- (1.5,0); 715 | \draw (0,-1.5) -- (0,1.5); 716 | \draw (0,0) circle (1cm); 717 | \draw[step=2pt] (0,0) grid (30pt,30pt); 718 | \end{tikzpicture} 719 | \end{lstlisting} 720 | \begin{center} 721 | \begin{tikzpicture} 722 | \draw[step=1.0cm, gray, very thin] (-1.4,-1.4) grid (1.4,1.4); 723 | \draw (-1.5,0) -- (1.5,0); 724 | \draw (0,-1.5) -- (0,1.5); 725 | \draw (0,0) circle (1cm); 726 | \draw[step=2pt] (0,0) grid (30pt,30pt); 727 | \end{tikzpicture} 728 | \end{center} 729 | 此外 step 用来控制网格之间的间距,可以color来设置网格的颜色,不过一般没那个必要。然后接下来第一个坐标点是网格的左底点,第二个坐标点是网格的右定点。 730 | \begin{lstlisting} 731 | \begin{tikzpicture} 732 | \draw[help lines] ( -5,-5 ) grid ( 5, 5); 733 | \end{tikzpicture} 734 | \end{lstlisting} 735 | \begin{center} 736 | \begin{tikzpicture} 737 | \draw[help lines] ( -5,-5 ) grid ( 5, 5); 738 | \end{tikzpicture} 739 | \end{center} 740 | 741 | 我们看到tikz的每一条命令最后都要跟一个分号";"。 742 | \section{直线(Straight Path)} 743 | 直线就是两个坐标点相连,中间 -- 符号表示直线的意思。用法如下: 744 | \begin{verbatim} 745 | \draw[options] (x1,y1) -- (x2,y2) -- (x3,y3); 746 | \end{verbatim} 747 | \begin{lstlisting} 748 | \begin{tikzpicture} 749 | \draw (-1.5,0) -- (1.5,0) -- (0,-1.5) -- (0,1.5); 750 | \draw[thick, rounded corners=10pt] (0,0) -- (0,2) -- (1,3.25) -- 751 | (2,2) -- (2,0) -- (0,2) -- (2,2) -- (0,0) -- (2,0); 752 | \end{tikzpicture} 753 | \end{lstlisting} 754 | \begin{center} 755 | \begin{tikzpicture} 756 | \draw (-1.5,0) -- (1.5,0) -- (0,-1.5) -- (0,1.5); 757 | \draw[thick, rounded corners=10pt] (0,0) -- (0,2) -- (1,3.25) -- 758 | (2,2) -- (2,0) -- (0,2) -- (2,2) -- (0,0) -- (2,0); 759 | \end{tikzpicture} 760 | \end{center} 761 | 之前网格是grid表示网格的意思。如果几个点用 -- 符号连接起来,表示这几个点连着来画几条折线,有多个画直线命令依次执行的意思。 762 | \begin{lstlisting} 763 | \begin{tikzpicture} 764 | \draw[help lines] ( -4,-4 ) grid (4,4); 765 | \draw[red] (-3,0) -- (3,0); 766 | \draw[red] (0,-3) -- (0,3); 767 | \end{tikzpicture} 768 | \end{lstlisting} 769 | \begin{center} 770 | \begin{tikzpicture} 771 | \draw[help lines] ( -4,-4 ) grid (4,4); 772 | \draw[red] (-3,0) -- (3,0); 773 | \draw[red] (0,-3) -- (0,3); 774 | \end{tikzpicture} 775 | \end{center} 776 | 如果在直线带上箭头,draw命令可以跟上可选项 \lstinline{->} ,这样直线的右端就有一个箭头了。此外还有: \lstinline{->>},\lstinline {->|} , \lstinline{-to},\lstinline {-latex} ,\lstinline {-stealth} ,他们的效果从上到下依次演示如下: 777 | \begin{lstlisting} 778 | \begin{tikzpicture} 779 | \draw[->] (-3,3) -- (3,3); 780 | \draw[->>] (-3,2) -- (3,2); 781 | \draw[->|] (-3,1) -- (3,1); 782 | \draw[-to] (-3,0) -- (3,0); 783 | \draw[-latex] (-3,-1) -- (3,-1); 784 | \draw[-stealth] (-3,-2) -- (3,-2); 785 | \end{tikzpicture} 786 | \end{lstlisting} 787 | \begin{center} 788 | \begin{tikzpicture} 789 | \draw[->] (-3,3) -- (3,3); 790 | \draw[->>] (-3,2) -- (3,2); 791 | \draw[->|] (-3,1) -- (3,1); 792 | \draw[-to] (-3,0) -- (3,0); 793 | \draw[-latex] (-3,-1) -- (3,-1); 794 | \draw[-stealth] (-3,-2) -- (3,-2); 795 | \end{tikzpicture} 796 | \end{center} 797 | \section{抛物线(Parabola Path)} 798 | 画实例用的抛物线使用关键字 parabola,用法如下: 799 | \begin{verbatim} 800 | \draw[options] (x1,y1) parabola (x2,y2); 801 | \end{verbatim} 802 | 803 | \tikz \draw (0,0) rectangle (1,1) (0,0) parabola (1,1);再画两个 804 | \tikz \draw[x=0.2cm,y=0.2cm] (0,0) parabola bend (4,10) (6,6);\tikz \draw (0,0) sin (1,1) cos (2,0) sin (3,-1) cos (4,0); 805 | 806 | 第一个点 (0,0) 是起点,使用 sin画到第二点 (1,1) 。如果没有给出起点,那么 cos 会以 (1,1) 为起点,画到点 (2,0)。[x=1ex,y=1ex] 是表示在一个行距高度内,宽度为 1.57 倍的行距内画图。 807 | section{箭头} 808 | Tikz 默认的箭头有点难看,主要是因为它指的不精确。一个名字叫作“悄悄地 (stealth) ”的箭头。 809 | \tikz{ 810 | \draw [line width=1mm, -{Stealth[length=10mm, open]}] 811 | (0,0) -- (2,0); 812 | \draw [|<->|] (2,.6) -- node[above=1mm] {10mm} ++(-10mm,0); 813 | } 814 | \begin{tikzpicture}[>= stealth] 815 | \draw [->, red] (0,0) arc [start angle =180, end angle=30,radius=1cm]; 816 | \draw [<<- ,very thick] (1,0) -- (1.5cm, 10pt) -- (2cm,0pt) -- (2.5cm,10pt); 817 | \end{tikzpicture} 818 | 819 | 以及Arc Path的使用来绘制曲线,用法: 820 | \begin{verbatim} 821 | \draw (x,y) arc (angle1:angle2:radius); 822 | \draw (x,y) arc [start angle=angle1, end angle=angle2, radius=radius]; 823 | \draw (x,y) arc (angle1:angle2:x.radius and y.radius); 824 | \draw (x,y) arc [start angle=angle1, end angle=angle2, x radius=rx, y radius=ry] 825 | \end{verbatim} 826 | \begin{lstlisting} 827 | \begin{tikzpicture} 828 | \draw (-1.5,0) -- (1.5,0); 829 | \draw (0,-1.5) -- (0,1.5); 830 | \draw (0.5,0) arc (0:120:0.5cm); 831 | \draw (1,0) arc (0:315:1.75cm and 1cm); 832 | \draw (-1,0) arc [start angle=180, end angle=120, radius=0.5cm]; 833 | % 以上不是推荐的方式 834 | \end{tikzpicture} 835 | \end{lstlisting} 836 | \begin{center} 837 | \begin{tikzpicture} 838 | \draw (-1.5,0) -- (1.5,0); 839 | \draw (0,-1.5) -- (0,1.5); 840 | \draw (0.5,0) arc (0:120:0.5cm); 841 | \draw (1,0) arc (0:315:1.75cm and 1cm); 842 | \draw (-1,0) arc [start angle=180, end angle=120, radius=0.5cm]; 843 | % 以上不是推荐的方式 844 | \end{tikzpicture} 845 | \end{center} 846 | 847 | 正弦或余弦曲线使用关键字sin/cos,用法: 848 | \begin{verbatim} 849 | \draw[options] (x1,y1) sin (x2,y2); 850 | \draw[options] (x1,y1) cos (x2,y2); 851 | \end{verbatim} 852 | \begin{lstlisting} 853 | \begin{tikzpicture} 854 | \draw[help lines] (-0.5,-1.5) grid (4.5,1.5); 855 | \draw[red] (0,0) sin (1,1) cos (2,0) sin (3,-1) cos (4,0); 856 | \draw[blue] (0,1) cos (1,0) sin (2,-1) cos (3,0) sin (4,1); 857 | \end{tikzpicture} 858 | \end{lstlisting} 859 | \begin{center} 860 | \begin{tikzpicture} 861 | \draw[help lines] (-0.5,-1.5) grid (4.5,1.5); 862 | \draw[red] (0,0) sin (1,1) cos (2,0) sin (3,-1) cos (4,0); 863 | \draw[blue] (0,1) cos (1,0) sin (2,-1) cos (3,0) sin (4,1); 864 | \end{tikzpicture} 865 | \end{center} 866 | \begin{lstlisting} 867 | \begin{tikzpicture}[scale=1.6]%scale参数可以使得图形放大一定的倍数而本身的字体大小可以保持不变。 868 | \def\iangle{120} 869 | %画左边的圆 870 | %scope环境里够成一整个区块,然后可以使这一整个区块进行平移。 871 | \begin{scope}[xshift=-2cm] 872 | \draw[->] (-1.2,0) --(1.2,0); 873 | \draw[->] (0,-1.2) --(0,1.2); 874 | \draw[thick] (0,0) circle(1cm); 875 | \coordinate [label = \iangle:$P$] (P) at (\iangle:1); 876 | \coordinate [label = below:$P0$] (P0) at (P |-0,0); 877 | \draw (P)--(P0); 878 | \draw (0,0)--(P); 879 | \fill [fill = gray,fill opacity=0.2] (0,0)--(0:1) arc (0:\iangle:1)--cycle; 880 | \filldraw [fill = gray,fill opacity=0.5] (0,0)--(0:0.3) arc (0:\iangle:0.3)--cycle; 881 | \node [right] at (\iangle/2:0.3) {\ang{\iangle}}; 882 | 883 | \end{scope} 884 | %画右边的正弦曲线 885 | \draw[->] (0,0) --({rad(210)},0); 886 | \draw[->] (0,-1.2) --(0,1.2); 887 | \draw [thick,domain=0:rad(210)] plot (\x,{sin(\x r)}) node [right] {$\sin x$}; 888 | 889 | \foreach \t in {0,90,180} 890 | { 891 | \draw ({rad(\t)},-0.05)--({rad(\t)},0.05) ; 892 | \node [below,outer sep =2pt ,font=\small , fill = white] at ({rad(\t)},0) {\ang{\t}}; 893 | } 894 | \foreach \y in {-1,1} 895 | { 896 | \draw (-0.05,\y) -- (0.05,\y); 897 | } 898 | \coordinate [label=above:{$Q$}] (Q) at ({rad(\iangle)},{sin(\iangle)}); 899 | \coordinate [label=below:{$Q_0$}] (Q0) at (Q |- 0,0); 900 | \draw (Q)--(Q0); 901 | %左右相互连接 902 | \draw[dashed] (P) --(Q); 903 | \end{tikzpicture} 904 | \end{lstlisting} 905 | \begin{center} 906 | \begin{tikzpicture}[scale=1.6]%scale参数可以使得图形放大一定的倍数而本身的字体大小可以保持不变。 907 | \def\iangle{120} 908 | %画左边的圆 909 | %scope环境里够成一整个区块,然后可以使这一整个区块进行平移。 910 | \begin{scope}[xshift=-2cm] 911 | \draw[->] (-1.2,0) --(1.2,0); 912 | \draw[->] (0,-1.2) --(0,1.2); 913 | \draw[thick] (0,0) circle(1cm); 914 | \coordinate [label = \iangle:$P$] (P) at (\iangle:1); 915 | \coordinate [label = below:$P0$] (P0) at (P |-0,0); 916 | \draw (P)--(P0); 917 | \draw (0,0)--(P); 918 | \fill [fill = gray,fill opacity=0.2] (0,0)--(0:1) arc (0:\iangle:1)--cycle; 919 | \filldraw [fill = gray,fill opacity=0.5] (0,0)--(0:0.3) arc (0:\iangle:0.3)--cycle; 920 | \node [right] at (\iangle/2:0.3) {\ang{\iangle}}; 921 | 922 | \end{scope} 923 | %画右边的正弦曲线 924 | \draw[->] (0,0) --({rad(210)},0); 925 | \draw[->] (0,-1.2) --(0,1.2); 926 | \draw [thick,domain=0:rad(210)] plot (\x,{sin(\x r)}) node [right] {$\sin x$}; 927 | 928 | \foreach \t in {0,90,180} 929 | { 930 | \draw ({rad(\t)},-0.05)--({rad(\t)},0.05) ; 931 | \node [below,outer sep =2pt ,font=\small , fill = white] at ({rad(\t)},0) {\ang{\t}}; 932 | } 933 | \foreach \y in {-1,1} 934 | { 935 | \draw (-0.05,\y) -- (0.05,\y); 936 | } 937 | \coordinate [label=above:{$Q$}] (Q) at ({rad(\iangle)},{sin(\iangle)}); 938 | \coordinate [label=below:{$Q_0$}] (Q0) at (Q |- 0,0); 939 | \draw (Q)--(Q0); 940 | %左右相互连接 941 | \draw[dashed] (P) --(Q); 942 | \end{tikzpicture} 943 | \end{center} 944 | \section{添加文本(Add text)} 945 | 添加文字比较简单,在已知位置上用 node 标出文字即可。其用法: 946 | \begin{verbatim} 947 | \draw (x,y) node[options] {text}; 948 | \draw (x,y) node[options] {text}; 949 | \node[options] at (x,y) {text}; 950 | options: above,below,left,right, or anchor=north,south,west,east. 951 | \end{verbatim} 952 | \begin{lstlisting} 953 | \begin{tikzpicture}[scale=2] 954 | \draw[<->] (0,1) -- (0,0) -- (1,0); 955 | \draw[fill] (0.5,0.5) circle (0.05); 956 | \draw (0.5,0.5) node[above=10pt] {A} node[left=10pt] {L} 957 | node[below=10pt] {B} node[right=10pt] {R}; 958 | \draw (0.5,0.5) node[above left=2pt] {AL} node[below left=2pt] {BL} 959 | node[below right=2pt] {BR} node[above right=2pt] {AR}; 960 | \end{tikzpicture} 961 | \begin{tikzpicture}[scale=2] 962 | \draw[<->] (0,1) -- (0,0) -- (1,0); 963 | \draw[fill] (0.5,0.5) circle (0.05); 964 | \draw (0.5,0.5) node[anchor=north] {N} node[anchor=west] {W} 965 | node[anchor=south] {S} node[anchor=east] {E}; 966 | \draw (0.5,0.5) node[anchor=north west] {NW} node[anchor=south west] {SW} 967 | node[anchor=south east] {SE} node[anchor=north east] {NE}; 968 | \end{tikzpicture} 969 | \end{lstlisting} 970 | \begin{center} 971 | \begin{tikzpicture}[scale=2] 972 | \draw[<->] (0,1) -- (0,0) -- (1,0); 973 | \draw[fill] (0.5,0.5) circle (0.05); 974 | \draw (0.5,0.5) node[above=10pt] {A} node[left=10pt] {L} 975 | node[below=10pt] {B} node[right=10pt] {R}; 976 | \draw (0.5,0.5) node[above left=2pt] {AL} node[below left=2pt] {BL} 977 | node[below right=2pt] {BR} node[above right=2pt] {AR}; 978 | \end{tikzpicture} 979 | \begin{tikzpicture}[scale=2] 980 | \draw[<->] (0,1) -- (0,0) -- (1,0); 981 | \draw[fill] (0.5,0.5) circle (0.05); 982 | \draw (0.5,0.5) node[anchor=north] {N} node[anchor=west] {W} 983 | node[anchor=south] {S} node[anchor=east] {E}; 984 | \draw (0.5,0.5) node[anchor=north west] {NW} node[anchor=south west] {SW} 985 | node[anchor=south east] {SE} node[anchor=north east] {NE}; 986 | \end{tikzpicture} 987 | \end{center} 988 | \begin{lstlisting} 989 | \begin{tikzpicture} 990 | \draw (0,0) .. controls (6,1) and (9,1) .. 991 | node[near start,sloped,above] {near start} 992 | node {midway} 993 | node[very near end,sloped,below] {very near end} (12,0); 994 | \end{tikzpicture} 995 | \end{lstlisting} 996 | \begin{center} 997 | \begin{tikzpicture} 998 | \draw (0,0) .. controls (6,1) and (9,1) .. 999 | node[near start,sloped,above] {near start} 1000 | node {midway} 1001 | node[very near end,sloped,below] {very near end} (12,0); 1002 | \end{tikzpicture} 1003 | \end{center} 1004 | \begin{verbatim} 1005 | \begin{tikzpicture} 1006 | \draw (0,0) node(a) [draw,align=center] {This is a test\\$a$ node} 1007 | (1,1) node(b) [draw] {Node B}; 1008 | \draw (a.north) |- (b.west); 1009 | \draw[color=red] (a.east) -| (2,1.5) -| (b.north); 1010 | \end{tikzpicture} 1011 | \end{verbatim} 1012 | \begin{center} 1013 | \begin{tikzpicture} 1014 | \draw (0,0) node(a) [draw,align=center] {This is a test\\$a$ node} 1015 | (1,1) node(b) [draw] {Node B}; 1016 | \draw (a.north) |- (b.west); 1017 | \draw[color=red] (a.east) -| (2,1.5) -| (b.north); 1018 | \end{tikzpicture} 1019 | \end{center} 1020 | \begin{lstlisting} 1021 | \begin{tikzpicture}[scale=2, >= stealth] 1022 | \draw[step=0.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4); 1023 | \filldraw[fill=green!20!white,draw=red!50!black] (0,0) -- (3mm,0mm) 1024 | arc [start angle=0, end angle=30, radius=3mm] -- cycle ; 1025 | \draw (2mm, 0.4mm) node {$\alpha$}; 1026 | \draw[->] (-1.5,0) -- (1.5,0) coordinate (x axis); 1027 | \draw[->] (0,-1.5) -- (0,1.5) coordinate (y axis); 1028 | \draw (0,0) circle [radius=1cm]; 1029 | \draw [red,very thick] (30:1cm) -- node[left=1pt,fill=white] {$\sin \alpha$} +(0,-0.5); 1030 | \draw [blue,very thick] (30:1cm) ++(0,-0.5) -- node[below=2pt,fill=white] {$\cos \alpha$} (0,0); 1031 | \draw [orange,very thick] (1,0) -- (1,{tan(30)}) node[right=1pt,fill=white] 1032 | {$\displaystyle \tan \alpha \color{black}= 1033 | \frac{{\color{red}\sin \alpha }}{\color{blue}\cos \alpha}$}; 1034 | \draw (0,0) -- (1,{tan(30)}); 1035 | \foreach \x/\xtext in {-1,-0.5/-\frac{1}{2}, 1} 1036 | \draw [very thick] (\x cm, -1pt) -- (\x cm, 1pt) node[anchor=north,fill=white] {$\xtext$}; 1037 | \foreach \y in {-1,-0.5,0.5,1} 1038 | \draw [very thick] (-1pt,\y cm) -- (1pt,\y cm) node[anchor=east,fill=white] {$\y$}; 1039 | \end{tikzpicture} 1040 | \end{lstlisting} 1041 | \begin{center} 1042 | \begin{tikzpicture}[scale=2, >= stealth] 1043 | \draw[step=0.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4); 1044 | \filldraw[fill=green!20!white,draw=red!50!black] (0,0) -- (3mm,0mm) 1045 | arc [start angle=0, end angle=30, radius=3mm] -- cycle ; 1046 | \draw (2mm, 0.4mm) node {$\alpha$}; 1047 | \draw[->] (-1.5,0) -- (1.5,0) coordinate (x axis); 1048 | \draw[->] (0,-1.5) -- (0,1.5) coordinate (y axis); 1049 | \draw (0,0) circle [radius=1cm]; 1050 | \draw [red,very thick] (30:1cm) -- node[left=1pt,fill=white] {$\sin \alpha$} +(0,-0.5); 1051 | \draw [blue,very thick] (30:1cm) ++(0,-0.5) -- node[below=2pt,fill=white] {$\cos \alpha$} (0,0); 1052 | \draw [orange,very thick] (1,0) -- (1,{tan(30)}) node[right=1pt,fill=white] 1053 | {$\displaystyle \tan \alpha \color{black}= 1054 | \frac{{\color{red}\sin \alpha }}{\color{blue}\cos \alpha}$}; 1055 | \draw (0,0) -- (1,{tan(30)}); 1056 | \foreach \x/\xtext in {-1,-0.5/-\frac{1}{2}, 1} 1057 | \draw [very thick] (\x cm, -1pt) -- (\x cm, 1pt) node[anchor=north,fill=white] {$\xtext$}; 1058 | \foreach \y in {-1,-0.5,0.5,1} 1059 | \draw [very thick] (-1pt,\y cm) -- (1pt,\y cm) node[anchor=east,fill=white] {$\y$}; 1060 | \end{tikzpicture} 1061 | \end{center} 1062 | 1063 | \section{添加样式(Add Styles)} 1064 | \textsf{Styles}是可用于组织图形绘制方式的预定义选项集。要全局定义样式,可以在文档开头使用\textbackslash tikzset命令,用法: 1065 | \begin{verbatim} 1066 | \tikzset{style_name./style={options}} 1067 | \end{verbatim} 1068 | \begin{lstlisting} 1069 | \tikzset{blue_thin_lines/.style={color=blue!50,very thin}} 1070 | \begin{tikzpicture} 1071 | \draw[step=0.5cm, blue_thin_lines] (0,0) grid (2,2); 1072 | \end{tikzpicture} 1073 | \end{lstlisting} 1074 | \tikzset{blue_thin_lines/.style={color=blue!50,very thin}} 1075 | \begin{center} 1076 | \begin{tikzpicture} 1077 | \draw[step=0.5cm, blue_thin_lines] (0,0) grid (2,2); 1078 | \end{tikzpicture} 1079 | \end{center} 1080 | 为了在局部定义一个样式,我们使用一对方括号 ``[ ]''来定义图片开头的样式,用法: 1081 | \begin{verbatim} 1082 | [style_name/.style={options}] 1083 | \end{verbatim} 1084 | \begin{lstlisting} 1085 | \begin{tikzpicture} 1086 | [red_thick_lines/.style={color=red!50,very thick}]; 1087 | \draw[step=0.5cm, red_thick_lines] (0,0) grid (2,2); 1088 | \end{tikzpicture} 1089 | \end{lstlisting} 1090 | \begin{center} 1091 | \begin{tikzpicture} 1092 | [red_thick_lines/.style={color=red!50,very thick}]; 1093 | \draw[step=0.5cm, red_thick_lines] (0,0) grid (2,2); 1094 | \end{tikzpicture} 1095 | \end{center} 1096 | 也可以分层定义样式,用法: 1097 | \begin{verbatim} 1098 | \tikzset{style_name1/.style={style_name2, options}} 1099 | \end{verbatim} 1100 | \begin{lstlisting} 1101 | \tikzset{green_help_lines/.style={help lines, color=green!90}} 1102 | \begin{tikzpicture} 1103 | \draw[step=0.5cm, green_help_lines] (0,0) grid (5,5); 1104 | \end{tikzpicture} 1105 | \end{lstlisting} 1106 | \begin{center} 1107 | \tikzset{green_help_lines/.style={help lines, color=green!90}} 1108 | \begin{tikzpicture} 1109 | \draw[step=0.5cm, green_help_lines] (0,0) grid (5,5); 1110 | \end{tikzpicture} 1111 | \end{center} 1112 | 样式也可以与参数一起使用,用法: 1113 | \begin{verbatim} 1114 | [style_name/.style={options},style_name/.default={options}] 1115 | \end{verbatim} 1116 | \begin{lstlisting} 1117 | \begin{tikzpicture} 1118 | [para_color/.style={help lines,color=#1!50}, para_color/.default=blue] 1119 | \draw[step=0.5cm, para_color] (0,0) grid (2,2); 1120 | \draw[step=0.5cm, para_color=red] (2,0) grid (4,2); 1121 | \end{tikzpicture} 1122 | \end{lstlisting} 1123 | \begin{center} 1124 | \begin{tikzpicture} 1125 | [para_color/.style={help lines,color=#1!50}, para_color/.default=blue] 1126 | \draw[step=0.5cm, para_color] (0,0) grid (2,2); 1127 | \draw[step=0.5cm, para_color=red] (2,0) grid (4,2); 1128 | \end{tikzpicture} 1129 | \end{center} 1130 | 1131 | 预定义一个属性集合,到时候直接赋给相应的实体,TikZ本身就是个宏,因此它为我们提供了强大的属性定义功能,来看这段代码: 1132 | \begin{lstlisting} 1133 | \begin{tikzpicture} 1134 | [LNode/.style={circle, draw=blue!50, fill=blue!20, very thick, minimum size=10mm} 1135 | \node[LNode] (n1) at (0, 0){$\int x \mathrm{d}x$}; 1136 | \end{tikzpicture} 1137 | \end{lstlisting} 1138 | \begin{center} 1139 | \begin{tikzpicture} 1140 | [L1Node/.style={circle, draw=blue!50, fill=blue!20, very thick, minimum size=50mm} 1141 | % L2Node/.style={rectangle,draw=green!50,fill=green!20,very thick, minimum size=50mm}] 1142 | \node[L1Node] (n1) at (0, 0){$\int_{a}^{b} f(x)\mathrm{d}x$}; 1143 | % \node[L2Node] (n2) at (2, 0){$n!$}; 1144 | \end{tikzpicture} 1145 | \end{center} 1146 | \section{Draw options and context} 1147 | \subsection{绘图选项} 1148 | 有一些绘图选项可以用来控制颜色、厚度和线条类型。 1149 | \begin{itemize} 1150 | \item 颜色: 1151 | blue \tikz \filldraw[blue] (0,0) rectangle (1.5em,1.5ex);, 1152 | black \tikz \filldraw[black] (0,0) rectangle (1.5em,1.5ex);, 1153 | brown \tikz \filldraw[brown] (0,0) rectangle (1.5em,1.5ex);, 1154 | cyan \tikz \filldraw[cyan] (0,0) rectangle (1.5em,1.5ex);, 1155 | gray \tikz \filldraw[gray] (0,0) rectangle (1.5em,1.5ex);, 1156 | green \tikz \filldraw[green] (0,0) rectangle (1.5em,1.5ex);, 1157 | lightgray \tikz \filldraw[lightgray] (0,0) rectangle (1.5em,1.5ex);, 1158 | lime \tikz \filldraw[lime] (0,0) rectangle (1.5em,1.5ex);, 1159 | magenta \tikz \filldraw[magenta] (0,0) rectangle (1.5em,1.5ex);, 1160 | orange \tikz \filldraw[orange] (0,0) rectangle (1.5em,1.5ex);, 1161 | pink \tikz \filldraw[pink] (0,0) rectangle (1.5em,1.5ex);, 1162 | purple \tikz \filldraw[purple] (0,0) rectangle (1.5em,1.5ex);, 1163 | red \tikz \filldraw[red] (0,0) rectangle (1.5em,1.5ex);, 1164 | yellow \tikz \filldraw[yellow] (0,0) rectangle (1.5em,1.5ex);, 1165 | teal \tikz \filldraw[teal] (0,0) rectangle (1.5em,1.5ex);, 1166 | violet \tikz \filldraw[violet] (0,0) rectangle (1.5em,1.5ex);, 1167 | white \tikz \draw[fill=white] (0,0) rectangle (1.5em,1.5ex);.\\ 1168 | 注意:颜色是可以混合, 比如这种颜色命令 \verb|[blue!40!white]| 意味着$40\%$蓝色和$60\%$白色混合在一起。 1169 | \item 厚度: 1170 | ultra thin \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[ultra thin] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1171 | very thin \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[very thin] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1172 | thin \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[thin] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1173 | semithick \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[semithick] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1174 | thick \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[thick] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1175 | very thick \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[very thick] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1176 | ultra thick \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[ultra thick] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}.\\ 1177 | 注意: \verb![help lines]=[gray,very thin]!. 线厚度也可以通过\verb![line width]! 选择,例如 \verb![line width=0.5cm]!. 1178 | \item 线型: 1179 | loosely dashed \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[loosely dashed] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1180 | dashed \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[dashed] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1181 | densely dashed \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[densely dashed] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1182 | loosely dotted \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[loosely dotted] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1183 | dotted \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[dotted] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1184 | densely dotted \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[densely dotted] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}. 1185 | \item 箭头: 1186 | \verb!<-! \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[<-] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1187 | \verb!<<-! \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[<<-] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1188 | \verb!<-|! \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[<-|] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1189 | \verb!<<-|! \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[<<-|] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1190 | \verb!->! \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[->] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1191 | \verb!->>! \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[->>] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1192 | \verb!|->! \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[|->] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1193 | \verb!|->>! \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[|->>] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1194 | \verb!<->! \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[<->] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}, 1195 | \verb!<<->>! \begin{tikzpicture} \filldraw[white] (0,0) rectangle (1em,1.5ex); \draw[<<->>] (0,0.7ex) -- (1em,0.7ex);\end{tikzpicture}.\\ 1196 | 注意:你也可以添加\verb!>=stealth!到选项中,它可将箭头更改为'stealth-like'的样式。 1197 | \end{itemize} 1198 | 用法如下: 1199 | \begin{verbatim} 1200 | \draw[color, thickness, line type, arrow] (x1,y1) -- (x2,y2); 1201 | \end{verbatim} 1202 | \begin{lstlisting} 1203 | \begin{tikzpicture} 1204 | \draw[red, very thin, densely dashed, <-] (0,0) -- (0.9,0); 1205 | \draw[green, ultra thick, loosely dotted, |->] (1.1,0) -- (1.9,0); 1206 | \draw[blue, semithick, <->, >=stealth] (2.1,0) -- (2.9,0); 1207 | \draw[purple, line width=0.3cm] (3.1,0) -- (3.9,0); 1208 | \end{tikzpicture} 1209 | \end{lstlisting} 1210 | \begin{center} 1211 | \begin{tikzpicture} 1212 | \draw[red, very thin, densely dashed, <-] (0,0) -- (0.9,0); 1213 | \draw[green, ultra thick, loosely dotted, |->] (1.1,0) -- (1.9,0); 1214 | \draw[blue, semithick, <->, >=stealth] (2.1,0) -- (2.9,0); 1215 | \draw[purple, line width=0.3cm] (3.1,0) -- (3.9,0); 1216 | \end{tikzpicture} 1217 | \end{center} 1218 | \subsection{node树} 1219 | node结点不但可以用于添加标识,还可以来绘制树形图,下面看一个例子,两个可作个对比,后面对前加了个样式: 1220 | \begin{lstlisting} 1221 | \begin{tikzpicture} 1222 | \node {root} 1223 | child {node {a1}} 1224 | child {node {a2} 1225 | child {node {b1}} 1226 | child {node {b2}}} 1227 | child {node {a3}}; 1228 | \end{tikzpicture} 1229 | \begin{tikzpicture} 1230 | [every node/.style={fill=blue!30,draw=blue!70,rounded corners}, 1231 | edge from parent/.style={blue,thick,draw}] 1232 | \node {root} 1233 | child {node {a1}} 1234 | child {node {a2} 1235 | child {node {b1}} 1236 | child {node {b2}}} 1237 | child {node {a3}}; 1238 | \end{tikzpicture} 1239 | \end{lstlisting} 1240 | \begin{center} 1241 | \begin{tikzpicture} 1242 | \node {root} 1243 | child {node {a1}} 1244 | child {node {a2} 1245 | child {node {b1}} 1246 | child {node {b2}}} 1247 | child {node {a3}}; 1248 | \end{tikzpicture} 1249 | \begin{tikzpicture} 1250 | [every node/.style={fill=blue!30,draw=blue!70,rounded corners}, 1251 | edge from parent/.style={blue,thick,draw}] 1252 | \node {root} 1253 | child {node {a1}} 1254 | child {node {a2} 1255 | child {node {b1}} 1256 | child {node {b2}}} 1257 | child {node {a3}}; 1258 | \end{tikzpicture} 1259 | \end{center} 1260 | \begin{lstlisting} 1261 | \tikzset{place/.style={circle,draw=blue!50,fill=blue!20, 1262 | thick,inner sep=0pt,minimum size=6mm}} 1263 | \tikzset{transition/.style={rectangle,draw=black!50, 1264 | fill=black!20,thick,inner sep=0pt,minimum size=4mm}} 1265 | \tikzset{every label/.style=red} 1266 | \begin{tikzpicture}[bend angle=45] 1267 | \node[place] (waiting) {}; 1268 | \node[place] (critical) [below=of waiting] {}; 1269 | \node[place](semaphore) [below=of critical,label=above:$s\le3$] {}; 1270 | \node[transition](leave critical) [right=of critical]{}; 1271 | \node[transition] (enter critical)[left=of critical]{}; 1272 | \draw [->] (enter critical) to (critical); 1273 | \draw [->] (waiting) to [bend right] (enter critical); 1274 | \draw [->] (enter critical) to [bend right] (semaphore); 1275 | \draw [->] (semaphore) to [bend right] (leave critical); 1276 | \draw [->] (critical) to (leave critical); 1277 | \draw [->] (leave critical) to [bend right] (waiting); 1278 | \end{tikzpicture} 1279 | \end{lstlisting} 1280 | \tikzset{place/.style={circle,draw=blue!50,fill=blue!20, 1281 | thick,inner sep=0pt,minimum size=6mm}} 1282 | \tikzset{transition/.style={rectangle,draw=black!50, 1283 | fill=black!20,thick,inner sep=0pt,minimum size=4mm}} 1284 | \tikzset{every label/.style=red} 1285 | \begin{center} 1286 | \begin{tikzpicture}[bend angle=45] 1287 | \node[place] (waiting) {}; 1288 | \node[place] (critical) [below=of waiting] {}; 1289 | \node[place](semaphore) [below=of critical,label=above:$s\le3$] {}; 1290 | \node[transition](leave critical) [right=of critical]{}; 1291 | \node[transition] (enter critical)[left=of critical]{}; 1292 | \draw [->] (enter critical) to (critical); 1293 | \draw [->] (waiting) to [bend right] (enter critical); 1294 | \draw [->] (enter critical) to [bend right] (semaphore); 1295 | \draw [->] (semaphore) to [bend right] (leave critical); 1296 | \draw [->] (critical) to (leave critical); 1297 | \draw [->] (leave critical) to [bend right] (waiting); 1298 | \end{tikzpicture} 1299 | \end{center} 1300 | \subsection{scope环境} 1301 | scope环境就是作用域控制,一个局域环境,参数只影响内部,外部的参数也影响不进来,不过值得一提的是,定义的点外面也可以用。scope环境一个有用的特性的里面的clip命令不会影响到外面。其用法: 1302 | \begin{verbatim} 1303 | \begin{scope}[options] 1304 | % only apply graphic options inside this scope, but not to anything outside. 1305 | \end{scope} 1306 | \end{verbatim} 1307 | \begin{lstlisting} 1308 | \begin{tikzpicture}[ultra thick] 1309 | \draw (0,0) -- (0,1); 1310 | \begin{scope}[thin] 1311 | \draw (1,0) -- (1,1); 1312 | \end{scope} 1313 | \draw (2,0) -- (2,1); 1314 | \end{tikzpicture} 1315 | \end{lstlisting} 1316 | \begin{center} 1317 | \begin{tikzpicture}[ultra thick] 1318 | \draw (0,0) -- (0,1); 1319 | \begin{scope}[thin] 1320 | \draw (1,0) -- (1,1); 1321 | \end{scope} 1322 | \draw (2,0) -- (2,1); 1323 | \end{tikzpicture} 1324 | \end{center} 1325 | \subsection{迭代语句} 1326 | \begin{lstlisting} 1327 | \begin{tikzpicture} 1328 | \draw[help lines] (0,0) grid (3,2); 1329 | \foreach \x in {0,1,...,4} 1330 | \draw[xshift=\x cm] (0,-1) -- (0,1); 1331 | \end{tikzpicture} 1332 | \end{lstlisting} 1333 | \begin{center} 1334 | \begin{tikzpicture} 1335 | \draw[help lines] (0,0) grid (3,2); 1336 | \foreach \x in {0,1,...,4} 1337 | \draw[xshift=\x cm] (0,-1) -- (0,1); 1338 | \end{tikzpicture} 1339 | \end{center} 1340 | 1341 | 1342 | 其中... 表示一直这样有规律下去生成迭代列表。迭代语句有很多用法,详见后面的具体例子。 1343 | \subsection{其它} 1344 | \begin{enumerate} 1345 | \item 平移:xshift ,x坐标轴平移。 yshift ,y坐标轴平移。 rotate ,旋转 。 注意xshift默认的单位并不是cm,如果要单位是cm需要写出来; 1346 | \begin{center} 1347 | \begin{tikzpicture} 1348 | \draw[help lines] (0,0) grid (3,2); 1349 | \draw (0,0) -- (1,1); 1350 | \draw[red] (0,0) -- ([xshift=1cm] 1,1); 1351 | \end{tikzpicture} 1352 | \end{center} 1353 | \item 旋转:后面加上可选项 rotate=30 即可,意思是图形逆时针旋转30度; 1354 | \begin{center} 1355 | \begin{tikzpicture} 1356 | \draw (0,0)[rotate=30] ellipse (2 and 1); 1357 | \end{tikzpicture} 1358 | \end{center} 1359 | \item 反对称:xscale=-1或者yscale=-1就刚好相对y轴或x轴反对称; 1360 | \item 翻转:例子如下 1361 | \begin{lstlisting} 1362 | \begin{tikzpicture} 1363 | \draw[help lines, step=0.5] (0,0) grid (7,1.5); 1364 | \draw[red, very thick] (0,0) -- (0,0.5) 1365 | [shift={(4pt,2pt)}] (0,0) -- (0,0.5); 1366 | \draw[red, very thick] (0.5,0) -- (0.5,0.5) 1367 | [shift={+(4pt,2pt)}] (0.5,0) -- (0.5,0.5); 1368 | \draw[rotate=30,fill=blue] (1.5,-1) rectangle (2,-0.5); 1369 | \draw[rotate around={60:(3,0.5)},fill=blue] (2.5,0.25) rectangle (3,0.75); 1370 | \draw[xscale=1,yscale=1.1,fill=green] (4,0.5) circle (0.5); 1371 | \draw[xslant=2,very thick] (5,0) -- (5.5,0.5) -- (5.5,0); 1372 | \end{tikzpicture} 1373 | \end{lstlisting} 1374 | \begin{center} 1375 | \begin{tikzpicture} 1376 | \draw[help lines, step=0.5] (0,0) grid (7,1.5); 1377 | \draw[red, very thick] (0,0) -- (0,0.5) 1378 | [shift={(4pt,2pt)}] (0,0) -- (0,0.5); 1379 | \draw[red, very thick] (0.5,0) -- (0.5,0.5) 1380 | [shift={+(4pt,2pt)}] (0.5,0) -- (0.5,0.5); 1381 | \draw[rotate=30,fill=blue] (1.5,-1) rectangle (2,-0.5); 1382 | \draw[rotate around={60:(3,0.5)},fill=blue] (2.5,0.25) rectangle (3,0.75); 1383 | \draw[xscale=1,yscale=1.1,fill=green] (4,0.5) circle (0.5); 1384 | \draw[xslant=2,very thick] (5,0) -- (5.5,0.5) -- (5.5,0); 1385 | \end{tikzpicture} 1386 | \end{center} 1387 | \item 循环并行:其用法 1388 | \begin{verbatim} 1389 | \foreach \variable in {list of values}{ 1390 | \commands ; 1391 | \end{verbatim} 1392 | \begin{lstlisting} 1393 | \begin{tikzpicture} 1394 | \foreach \x in {-0.5cm,0cm,0.5cm}{ 1395 | \draw[red,very thick] (\x,-5pt) -- (\x,5pt); 1396 | } 1397 | \foreach \y in {-0.5cm,0cm,0.5cm}{ 1398 | \draw[blue,very thick] (1cm,\y) -- (1.5cm,\y); 1399 | } 1400 | \foreach \x in {0,...,9}{ 1401 | \draw[green,very thick] (\x,-1) circle (0.4cm); 1402 | } 1403 | \foreach \x in {2,2.5,...,4}{ 1404 | \draw[purple,very thick] (\x cm,-3pt) -- (\x cm,3pt); 1405 | } 1406 | \end{tikzpicture} 1407 | \end{lstlisting} 1408 | \begin{center} 1409 | \begin{tikzpicture} 1410 | \foreach \x in {-0.5cm,0cm,0.5cm}{ 1411 | \draw[red,very thick] (\x,-5pt) -- (\x,5pt); 1412 | } 1413 | \foreach \y in {-0.5cm,0cm,0.5cm}{ 1414 | \draw[blue,very thick] (1cm,\y) -- (1.5cm,\y); 1415 | } 1416 | \foreach \x in {0,...,9}{ 1417 | \draw[green,very thick] (\x,-1) circle (0.4cm); 1418 | } 1419 | \foreach \x in {2,2.5,...,4}{ 1420 | \draw[purple,very thick] (\x cm,-3pt) -- (\x cm,3pt); 1421 | } 1422 | \end{tikzpicture} 1423 | \end{center} 1424 | \begin{lstlisting} 1425 | \begin{tikzpicture} 1426 | \foreach \x in {1,2,...,5,7,8,...,12}{ 1427 | \foreach \y in {1,...,5}{ 1428 | \draw (\x,\y) +(-0.5,-0.5) rectangle +(0.5,0.5); 1429 | \draw (\x,\y) node{\x,\y}; 1430 | } 1431 | } 1432 | \end{tikzpicture} 1433 | \end{lstlisting} 1434 | \begin{center} 1435 | \begin{tikzpicture} 1436 | \foreach \x in {1,2,...,5,7,8,...,12}{ 1437 | \foreach \y in {1,...,5}{ 1438 | \draw (\x,\y) +(-0.5,-0.5) rectangle +(0.5,0.5); 1439 | \draw (\x,\y) node{\x,\y}; 1440 | } 1441 | } 1442 | \end{tikzpicture} 1443 | \begin{lstlisting} 1444 | \begin{tikzpicture} 1445 | [L1Node/.style={circle, draw=blue!50, fill=blue!20, very thick, minimum size=10mm}, 1446 | L2Node/.style={rectangle,draw=green!50,fill=green!20,very thick, minimum size=10mm}] 1447 | \foreach \x in {1,...,5} 1448 | \node[L1Node] (w1_\x) at (2*\x, 0){$\int_\Omega x_\x$}; 1449 | \end{tikzpicture} 1450 | \end{lstlisting} 1451 | \begin{center} 1452 | \begin{tikzpicture} 1453 | [L1Node/.style={circle, draw=blue!50, fill=blue!20, very thick, minimum size=20mm}, 1454 | L2Node/.style={rectangle,draw=green!50,fill=green!20,very thick, minimum size=10mm}] 1455 | \foreach \x in {1,...,5} 1456 | \node[L1Node] (w1_\x) at (2*\x, 0){$\int_\Omega x_\x\mathrm{d}x$}; 1457 | \end{tikzpicture} 1458 | \end{center} 1459 | \end{center} 1460 | \item 确定路径: 1461 | \begin{itemize} 1462 | \item 线条:path路径是最基本的命令,draw命令等价于 \lstinline{\path[draw]} ,fill命令等价于 \lstinline{\path[fill]} ,filldraw命令等价于 \lstinline{\path[draw,fill]} ,其他clip,shade命令情况类似。 1463 | \item 虚线和点线:线条除了之前说的dashed和dotted两种样式之外,还有loosely dashed,densely dashed和loosely dotted, densely dotted; 1464 | \item 线条的粗细:其他选项还有 ultra thin , very thin, thin, semithick, very thick, ultra thick 1465 | \begin{center} 1466 | \begin{tikzpicture} 1467 | \draw [ultra thick] (0,1) -- (2,1); 1468 | \draw [thick] (0,0.5) -- (2,0.5); 1469 | \draw [thin] (0,0) -- (2,0); 1470 | \end{tikzpicture} 1471 | \end{center} 1472 | 或者直接通过可选项line width来定义: 1473 | \begin{center} 1474 | \begin{tikzpicture} 1475 | \draw [line width=0.4pt] (0,0) -- (2,0); 1476 | \draw[red] (0,1) -- (2,1); 1477 | \draw [line width=0.2cm] (4,.75) -- (5,.25); 1478 | \end{tikzpicture} 1479 | \end{center} 1480 | \end{itemize} 1481 | \end{enumerate} 1482 | \section{pgfplots宏包} 1483 | pgfplots宏包真是太好了,有时甚至画一个基本的坐标轴都懒得动用其他宏包命令了,我可以直接调用一个axis环境和进行一些简单的优化即可。当然就作为坐标轴作图可能总是用pgfplots宏包可能会稍显单调,但如果要求不是特别高的确实用pgfplots宏包会基于坐标轴的各个图形非常的称心如意,比如下面两个例子直接画函数与根据数据点来绘制: 1484 | \begin{lstlisting} 1485 | \begin{tikzpicture} 1486 | \begin{axis} 1487 | \addplot {x^2}; 1488 | \end{axis} 1489 | \end{tikzpicture} 1490 | \begin{tikzpicture} 1491 | \begin{axis} 1492 | \addplot coordinates 1493 | {(0,0) 1494 | (1,1) 1495 | (2,3) 1496 | (3,9)}; 1497 | \end{axis} 1498 | \end{tikzpicture} 1499 | \end{lstlisting} 1500 | \begin{tikzpicture} 1501 | \begin{axis} 1502 | \addplot {x^2}; 1503 | \end{axis} 1504 | \end{tikzpicture} 1505 | \begin{tikzpicture} 1506 | \begin{axis} 1507 | \addplot coordinates 1508 | {(0,0) 1509 | (1,1) 1510 | (2,3) 1511 | (3,9)}; 1512 | \end{axis} 1513 | \end{tikzpicture} 1514 | \begin{lstlisting} 1515 | \begin{tikzpicture} 1516 | \begin{axis} 1517 | \addplot[color=red]{exp(x)}; 1518 | \end{axis} 1519 | \end{tikzpicture} 1520 | %Here ends the furst plot 1521 | \hskip 5pt 1522 | %Here begins the 3d plot 1523 | \begin{tikzpicture} 1524 | \begin{axis} 1525 | \addplot3[ 1526 | surf, 1527 | ] 1528 | {exp(-x^2-y^2)*x}; 1529 | \end{axis} 1530 | \end{tikzpicture} 1531 | \end{lstlisting} 1532 | \begin{tikzpicture} 1533 | \begin{axis} 1534 | \addplot[color=red]{exp(x)}; 1535 | \end{axis} 1536 | \end{tikzpicture} 1537 | %Here ends the furst plot 1538 | \hskip 5pt 1539 | %Here begins the 3d plot 1540 | \begin{tikzpicture} 1541 | \begin{axis} 1542 | \addplot3[ 1543 | surf, 1544 | ] 1545 | {exp(-x^2-y^2)*x}; 1546 | \end{axis} 1547 | \end{tikzpicture} 1548 | \begin{lstlisting} 1549 | \begin{tikzpicture} 1550 | \begin{axis}[ 1551 | axis lines = left, 1552 | xlabel = $x$, 1553 | ylabel = {$f(x)$}, 1554 | ] 1555 | %Below the red parabola is defined 1556 | \addplot [ 1557 | domain=-10:10, 1558 | samples=100, 1559 | color=red, 1560 | ] 1561 | {x^2 - 2*x - 1}; 1562 | \addlegendentry{$x^2 - 2x - 1$} 1563 | %Here the blue parabloa is defined 1564 | \addplot [ 1565 | domain=-10:10, 1566 | samples=100, 1567 | color=blue, 1568 | ] 1569 | {x^2 + 2*x + 1}; 1570 | \addlegendentry{$x^2 + 2x + 1$} 1571 | 1572 | \end{axis} 1573 | \end{tikzpicture} 1574 | \end{lstlisting} 1575 | \begin{center} 1576 | \begin{tikzpicture} 1577 | \begin{axis}[ 1578 | axis lines = left, 1579 | xlabel = $x$, 1580 | ylabel = {$f(x)$}, 1581 | ] 1582 | %Below the red parabola is defined 1583 | \addplot [ 1584 | domain=-10:10, 1585 | samples=100, 1586 | color=red, 1587 | ] 1588 | {x^2 - 2*x - 1}; 1589 | \addlegendentry{$x^2 - 2x - 1$} 1590 | %Here the blue parabloa is defined 1591 | \addplot [ 1592 | domain=-10:10, 1593 | samples=100, 1594 | color=blue, 1595 | ] 1596 | {x^2 + 2*x + 1}; 1597 | \addlegendentry{$x^2 + 2x + 1$} 1598 | 1599 | \end{axis} 1600 | \end{tikzpicture} 1601 | \end{center} 1602 | \begin{lstlisting} 1603 | \begin{tikzpicture} 1604 | \begin{axis}[ 1605 | title={Temperature dependence of CuSO$_4\cdot$5H$_2$O solubility}, 1606 | xlabel={Temperature [\textcelsius]}, 1607 | ylabel={Solubility [g per 100 g water]}, 1608 | xmin=0, xmax=100, 1609 | ymin=0, ymax=120, 1610 | xtick={0,20,40,60,80,100}, 1611 | ytick={0,20,40,60,80,100,120}, 1612 | legend pos=north west, 1613 | ymajorgrids=true, 1614 | grid style=dashed, 1615 | ] 1616 | 1617 | \addplot[ 1618 | color=blue, 1619 | mark=square, 1620 | ] 1621 | coordinates { 1622 | (0,23.1)(10,27.5)(20,32)(30,37.8)(40,44.6)(60,61.8)(80,83.8)(100,114) 1623 | }; 1624 | \legend{CuSO$_4\cdot$5H$_2$O} 1625 | 1626 | \end{axis} 1627 | \end{tikzpicture} 1628 | \end{lstlisting} 1629 | \begin{center} 1630 | \begin{tikzpicture} 1631 | \begin{axis}[ 1632 | title={Temperature dependence of CuSO$_4\cdot$5H$_2$O solubility}, 1633 | xlabel={Temperature [\textcelsius]}, 1634 | ylabel={Solubility [g per 100 g water]}, 1635 | xmin=0, xmax=100, 1636 | ymin=0, ymax=120, 1637 | xtick={0,20,40,60,80,100}, 1638 | ytick={0,20,40,60,80,100,120}, 1639 | legend pos=north west, 1640 | ymajorgrids=true, 1641 | grid style=dashed, 1642 | ] 1643 | 1644 | \addplot[ 1645 | color=blue, 1646 | mark=square, 1647 | ] 1648 | coordinates { 1649 | (0,23.1)(10,27.5)(20,32)(30,37.8)(40,44.6)(60,61.8)(80,83.8)(100,114) 1650 | }; 1651 | \legend{CuSO$_4\cdot$5H$_2$O} 1652 | 1653 | \end{axis} 1654 | \end{tikzpicture} 1655 | \end{center} 1656 | \begin{lstlisting} 1657 | \begin{tikzpicture} 1658 | \begin{axis}[ 1659 | x tick label style={ 1660 | /pgf/number format/1000 sep=}, 1661 | ylabel=Year, 1662 | enlargelimits=0.05, 1663 | legend style={at={(0.5,-0.1)}, 1664 | anchor=north,legend columns=-1}, 1665 | ybar interval=0.7, 1666 | ] 1667 | \addplot 1668 | coordinates {(2012,408184) (2011,408348) 1669 | (2010,414870) (2009,412156) (2008,415 838)}; 1670 | \addplot 1671 | coordinates {(2012,388950) (2011,393007) 1672 | (2010,398449) (2009,395972) (2008,398866)}; 1673 | \legend{Men,Women} 1674 | \end{axis} 1675 | \end{tikzpicture} 1676 | \begin{tikzpicture} 1677 | \begin{axis}[ 1678 | title=Exmple using the mesh parameter, 1679 | hide axis, 1680 | colormap/cool, 1681 | ] 1682 | \addplot3[ 1683 | mesh, 1684 | samples=50, 1685 | domain=-8:8, 1686 | ] 1687 | {sin(deg(sqrt(x^2+y^2)))/sqrt(x^2+y^2)}; 1688 | \addlegendentry{$\frac{\sin(r)}{r}$} 1689 | \end{axis} 1690 | \end{tikzpicture} 1691 | \end{lstlisting} 1692 | \begin{tikzpicture} 1693 | \begin{axis}[ 1694 | x tick label style={ 1695 | /pgf/number format/1000 sep=}, 1696 | ylabel=Year, 1697 | enlargelimits=0.05, 1698 | legend style={at={(0.5,-0.1)}, 1699 | anchor=north,legend columns=-1}, 1700 | ybar interval=0.7, 1701 | ] 1702 | \addplot 1703 | coordinates {(2012,408184) (2011,408348) 1704 | (2010,414870) (2009,412156) (2008,415 838)}; 1705 | \addplot 1706 | coordinates {(2012,388950) (2011,393007) 1707 | (2010,398449) (2009,395972) (2008,398866)}; 1708 | \legend{Men,Women} 1709 | \end{axis} 1710 | \end{tikzpicture} 1711 | \begin{tikzpicture} 1712 | \begin{axis}[ 1713 | title=Exmple using the mesh parameter, 1714 | hide axis, 1715 | colormap/cool, 1716 | ] 1717 | \addplot3[ 1718 | mesh, 1719 | samples=50, 1720 | domain=-8:8, 1721 | ] 1722 | {sin(deg(sqrt(x^2+y^2)))/sqrt(x^2+y^2)}; 1723 | \addlegendentry{$\frac{\sin(r)}{r}$} 1724 | \end{axis} 1725 | \end{tikzpicture} 1726 | 1727 | \begin{lstlisting} 1728 | \begin{tikzpicture} 1729 | \begin{axis} 1730 | \addplot3[ 1731 | surf, 1732 | ] 1733 | coordinates { 1734 | (0,0,0) (0,1,0) (0,2,0) 1735 | 1736 | (1,0,0) (1,1,0.6) (1,2,0.7) 1737 | 1738 | (2,0,0) (2,1,0.7) (2,2,1.8) 1739 | }; 1740 | \end{axis} 1741 | \end{tikzpicture} 1742 | \begin{tikzpicture} 1743 | \begin{axis} 1744 | [ 1745 | view={60}{30}, 1746 | ] 1747 | \addplot3[ 1748 | domain=0:5*pi, 1749 | samples = 60, 1750 | samples y=0, 1751 | ] 1752 | ({sin(deg(x))}, 1753 | {cos(deg(x))}, 1754 | {x}); 1755 | \end{axis} 1756 | \end{tikzpicture} 1757 | 1758 | \end{lstlisting} 1759 | \begin{tikzpicture} 1760 | \begin{axis} 1761 | \addplot3[ 1762 | surf, 1763 | ] 1764 | coordinates { 1765 | (0,0,0) (0,1,0) (0,2,0) 1766 | 1767 | (1,0,0) (1,1,0.6) (1,2,0.7) 1768 | 1769 | (2,0,0) (2,1,0.7) (2,2,1.8) 1770 | }; 1771 | \end{axis} 1772 | \end{tikzpicture} 1773 | \begin{tikzpicture} 1774 | \begin{axis} 1775 | [ 1776 | view={60}{30}, 1777 | ] 1778 | \addplot3[ 1779 | domain=0:5*pi, 1780 | samples = 60, 1781 | samples y=0, 1782 | ] 1783 | ({sin(deg(x))}, 1784 | {cos(deg(x))}, 1785 | {x}); 1786 | \end{axis} 1787 | \end{tikzpicture} 1788 | 1789 | \section{电路图} 1790 | 电路基本符号,具体详细看\href{http://texdoc.net/texmf-dist/doc/latex/circuitikz/circuitikzmanual.pdf}{CircuiTikZ} 1791 | \begin{enumerate} 1792 | \item battery : 电池\tikz[circuit ee IEC]{\node[battery] {};} 1793 | \item bulb : 灯泡 \tikz[circuit ee IEC]{\node[bulb] {};} 1794 | \item make contact : 开关 \tikz[circuit ee IEC]{\node[make contact] {};} 1795 | \item make contact : 开关另一种形式 额外选项{[set make contact graphic= var make contact IEC graphic]} \tikz[circuit ee IEC,set make contact graphic= var make contact IEC graphic]{\node[make contact] {};} 1796 | \item resistor 电阻 (加上选项[ohm=20k]则上面写上电阻数值) \tikz[circuit ee IEC]{\node[resistor] {};} 1797 | \item contact 电线交点 \tikz[circuit ee IEC]{\node[contact] {};} 1798 | \item current direction to路径上加上电流方向(如果是[\textbf{current direction'}]则方向反向。) \tikz[circuit ee IEC]{\draw (0,0) to[current direction] (1,0);} 1799 | \end{enumerate} 1800 | 1801 | 连线问题:各个元器件之间的连线除了一般的 -- 连直线外,还可以通过 -| 或者 |- 来处理垂直拐线的问题,其中 -| 你可以理解为从第一个点先横着走再竖着走,而 |- 你可以理解为先从第一个点竖着走再横着走。 1802 | 1803 | 翻转问题:四个基本的选项[ point up ,point down, point left, point right],分别是朝上,朝下,朝左和朝右,其他复杂的角度的处理方法不是用rotate选项,而是在路径上加上上面的电路符号选项,这样那些元器件会自动跟随路径对齐的。 1804 | \section{小总结} 1805 | TikZ只是一个前端(frontend),画图功能通过调用底层PGF宏包完成。 1806 | \begin{enumerate} 1807 | \item 简易的tikz环境:一个分号表示画图的结束; 1808 | \begin{lstlisting} 1809 | \tikz ...; 1810 | \end{lstlisting} 1811 | 可以有多个画图语句 1812 | \begin{lstlisting} 1813 | \tikz{...;...;...;} 1814 | \end{lstlisting} 1815 | \item 整体缩放图形倍数:magniication=1为原始大小 1816 | \begin{lstlisting} 1817 | \begin{tikzpicture}[scale=] 1818 | ...... 1819 | \end{tikzpicture} 1820 | \end{lstlisting} 1821 | \item 自定义一个图形,可方便重复使用:\lstinline|\def\{}| 1822 | \begin{lstlisting} 1823 | %自定义一个正方形 1824 | \def\rectangle{-- ++(1,0) -- ++(0,1) -- ++(-1,0) -- cycle} 1825 | \end{lstlisting} 1826 | \item 自定义一组样式,方便重复使用,并可设置参数:\lstinline|/.style={}| 1827 | \begin{lstlisting} 1828 | help line/.style={very thin, color=#1red!20!blue!20,rounded corners=2pt} 1829 | \end{lstlisting} 1830 | \item 最基本画图命令:\lstinline|\path| 1831 | \begin{lstlisting} 1832 | \draw=\path[draw], \draw[color=]=\path[draw=] 1833 | \fill=\path[fill], \fill[color=]=\path[fill=] 1834 | \filldraw=\path[fill, draw] 1835 | \clip=\path[clip] 1836 | \end{lstlisting} 1837 | \item 定位: 1838 | \begin{lstlisting} 1839 | +(x,y) 在之前的画笔点的基础上偏移(x,y),但并不改变画笔点; 1840 | ++(x,y)同样是偏移(x,y),但把偏移之后的点做为新的画笔点。 1841 | \end{lstlisting} 1842 | \item scope环境:需要注意\lstinline|\clip|的作用范围是从其语句之后一直到当前所在scope的结束 1843 | \begin{lstlisting} 1844 | \begin{scope}[] 1845 | ...... 1846 | \end{scope} 1847 | \end{lstlisting} 1848 | \item 几个典例: 1849 | \begin{itemize} 1850 | \item 球坐标(angle:radius) 1851 | \item 弧 (point at the initial angle) arc(inital angle:terminal angle:radius) 1852 | \item 圆 (center) circle (radius) 1853 | \item 椭圆 (center) ellipse (x radius and y radius) 1854 | \item 矩形 (point 1) rectangle (point 2) 1855 | \item 交点 (intersection of and ) 1856 | \end{itemize} 1857 | \item 可用选项: 1858 | \begin{itemize} 1859 | \item 箭头:->, ->>, <-, <<-, <-> 1860 | \item 旋转:rotate= 1861 | \item 圆角:rounded corners= 1862 | \item 颜色:color=... 1863 | \item 虚线:dashed, loosely dashed, densely dashed, dotted, loosely dotted, densely dotted 1864 | \item 宽度:very thin, thin (正常宽度), thick, very thick 1865 | \end{itemize} 1866 | \item 缩放: 1867 | \begin{lstlisting} 1868 | [scale=],[xscale=],[yscale=]. 1869 | \end{lstlisting} 1870 | 其中若取值为实数,其绝对值表示缩放的倍数;若是负数,表示进行翻转;若xscale是负数则左右翻转,yscale是负数则上下翻转,scale是负数则同时翻转。 1871 | \item 偏移: 1872 | \begin{lstlisting} 1873 | [shift=], [shift=+],[xshift=], [yshift=]. 1874 | \end{lstlisting} 1875 | 将后面的图加上一个矢量。其中[shift=+]表示,此加上的矢量为前一个画笔点+。 1876 | \end{enumerate} -------------------------------------------------------------------------------- /class/ch02.tex: -------------------------------------------------------------------------------- 1 | \chapter{填充颜色} 2 | 由于 tikz 绘图默认只能是左对齐,所以可以将它嵌套在表格 table 环 3 | 境中,使用表格内容居中,就可以达到中心对齐的目的。 4 | \begin{center} 5 | \begin{tikzpicture}[scale=3]%启动绘图环境,并放大 3倍 6 | \clip (-0.1,-0.2) rectangle (1.1,0.75); 7 | \draw[step=0.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4); 8 | \draw (-1.5,0) -- (1.5,0); 9 | \draw (0,-1.5) -- (0,1.5); 10 | \draw (0,0) circle [radius=1cm]; 11 | \filldraw[fill=green!20!white,draw=red!50!green] (0,0) -- (3mm,0mm) 12 | arc [start angle=0, end angle=30, radius=3mm] -- (0,0); 13 | \end{tikzpicture} 14 | \end{center} 15 | 行间画一段填充扇形。 16 | 17 | 韦恩图Venn 18 | 19 | %韦恩图venn - 两个圆相交 20 | \begin{tikzpicture} 21 | \draw (0,0) circle (2cm); 22 | \draw (2,0) circle (2cm); 23 | \clip[draw] (0,0) circle (2cm); 24 | \clip[draw] (2,0) circle (2cm); 25 | \foreach \x in {-1,-0.75,-0.5,-0.25,0,0,0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25,2.5,2.75} 26 | \draw[xshift=\x cm] (-2,2)--(2,-2); 27 | \node at (1,0) {$I$}; 28 | \end{tikzpicture} 29 | %韦恩图venn - 3个圆相交 30 | \begin{tikzpicture} 31 | \draw (0,0) circle (2cm); 32 | \draw (55:2.67cm) circle (2cm); 33 | \draw (0:3cm) circle (2cm); 34 | \begin{scope} 35 | \clip (0,0) circle (2cm); 36 | \clip (55:2.67cm) circle (2cm); 37 | \clip (0:3cm) circle (2cm); 38 | \foreach \x in {-1,-0.75,-0.5,-0.25,0,0,0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25,2.5,2.75} 39 | \draw[xshift=\x cm] (-2,2)--(2,-2); 40 | \end{scope} 41 | \node at (1.5,-0.5) {$II$}; 42 | \end{tikzpicture} 43 | 44 | %韦恩图venn - 3个圆相交(斜线填充) 45 | \begin{tikzpicture} %用[scale=0.8]出问题! 46 | \tikzset{venn circle/.style={draw,circle,minimum width=6cm,fill=#1,opacity=0.5,very thick}} 47 | \node [venn circle = red] (A) at (0,0) {$A$}; 48 | \node [venn circle = blue] (B) at (60:4cm) {$B$}; 49 | \node [venn circle = green] (C) at (0:4cm) {$C$}; 50 | \draw (0,0) circle (3cm); 51 | \draw (60:4cm) circle (3cm); 52 | \draw (0:4cm) circle (3cm); 53 | \begin{scope} 54 | \clip (0,0) circle (3cm); 55 | \clip (60:4cm) circle (3cm); 56 | \foreach \x in {-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5} 57 | \draw[overlay, xshift=\x cm] (2,4)--(2,0); 58 | \end{scope} 59 | \begin{scope} 60 | \clip (60:4cm) circle (3cm);\clip (0:4cm) circle (3cm); 61 | \foreach \y in {-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5} 62 | \draw[overlay, xshift=\y cm] (1,0)--(5,4); 63 | \end{scope} 64 | \begin{scope} 65 | \clip (0,0) circle (3cm); 66 | \clip (0:4cm) circle (3cm); 67 | \foreach \z in {-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5} 68 | \draw[overlay, yshift=\z cm] (0,3)--(4,3); 69 | \end{scope} 70 | \node at (2,-0.5) {$III$}; 71 | \end{tikzpicture} 72 | 73 | 用pattern包填充 74 | 75 | \begin{tikzpicture}[red,every node/.style={font=\Large}] 76 | \draw[pattern=north west lines] (0,0) circle(1.5); 77 | \draw (2,0) circle(1.5); 78 | \node[fill=white,inner sep=1pt,rounded corners,below=3] at (90:1.5) {$A$}; 79 | \node[xshift=2cm,below=3] at (90:1.5) {$B$}; 80 | \end{tikzpicture} 81 | 82 | \begin{tikzpicture}[scale=25] 83 | \begin{scope} 84 | \clip (0,0) arc (-90:0:1/8) arc (90:180:1/8); 85 | \fill[gray,even odd rule] (0,0) arc (-90:0:1/8) arc (90:180:1/8) 86 | arc (-90:270:1/16) arc (-180:180:1/16) arc (-90:0:1/16) arc (90:180:1/16); 87 | \end{scope} 88 | \draw [->,thick](-0.05,0)--(0.3,0);\draw [->,thick](0,-0.05)--(0,0.3); 89 | \node[right]at(0.3,0){$x$};\node[left]at(0,0.3){$y$}; 90 | \draw (0,0) arc (-90:90:1/8) (0,0) arc (-90:90:1/16) 91 | (0,0) arc (180:0:1/8) (0,0) arc (180:0:1/16) (0,0)--(1/8,1/8); 92 | \node [below]at(0.069,0.0627){$A$}; 93 | \node [above]at(0.136,0.123){$B$}; 94 | \node [right]at(0.105,0.0541){$C$}; 95 | \end{tikzpicture} 96 | \begin{tikzpicture}[scale=25] 97 | \begin{scope} 98 | \clip (0,0) arc (-90:0:1/8) arc (90:180:1/8); 99 | \fill[pattern=horizontal lines] 100 | (0,0) arc (-90:0:1/8) --(1/16,1/16) arc (90:0:1/16); 101 | \fill[pattern=vertical lines] 102 | (0,0) arc (180:90:1/8) --(1/16,1/16) arc (0:90:1/16); 103 | \end{scope} 104 | \draw [->,thick](-0.05,0)--(0.3,0);\draw [->,thick](0,-0.05)--(0,0.3); 105 | \node[right]at(0.3,0){$x$};\node[left]at(0,0.3){$y$}; 106 | \draw (0,0) arc (-90:90:1/8) (0,0) arc (-90:90:1/16) 107 | (0,0) arc (180:0:1/8) (0,0) arc (180:0:1/16) (0,0)--(1/8,1/8); 108 | \node [below]at(0.069,0.0627){$A$}; 109 | \node [above]at(0.136,0.123){$B$}; 110 | \node [right]at(0.105,0.0541){$C$}; 111 | \end{tikzpicture} 112 | 113 | \begin{tikzpicture}[smooth] 114 | \draw[arrows={-Stealth[length=5pt, inset=3.5pt]}] (-0.5,0) -- (3.0,0)node (xaxis) [right=-1pt] {$x$}; 115 | \draw[arrows={-Stealth[length=5pt, inset=3.5pt]}] (0,-0.5) -- (0,4.5)node (yaxis) [above=-0.6pt] {$y$}; 116 | \draw (-0.18,-0.18) node {$o$}; 117 | \draw[color=red,domain=0:2.0,fill=green!20] plot (\x,4*\x-\x*\x); 118 | \draw[color=red!40,domain=0:2.90] plot (\x,4*\x-\x*\x) ; 119 | \draw[color=blue!30,domain=0:2.3] plot (\x,2*\x) ; 120 | \draw[fill=black] (2,4) circle [radius=0.2pt] node[above=-1.8pt] {$A(2,4)$}; 121 | \end{tikzpicture} 122 | \begin{tikzpicture}[yscale=0.7] 123 | \draw[-stealth] (-0.4,0)--(2,0) node[below,scale=0.6]{$x$}; 124 | \draw[-stealth] (0,-0.3)--(0,5) node[left,scale=0.6]{$y$}; 125 | \draw (0,0) node [below left,scale=0.6] {$o$}; 126 | \foreach \i in {1}{\draw (\i,0)--node [below,scale=0.6] {$1$}(\i,0.05);} 127 | \draw (0,1) node [left,scale=0.6] {$1$}; 128 | \draw (1.35,1) node [right,scale=0.6] {$l_x$}; 129 | \draw (0.4,3.85742) node [above,scale=0.6] {$l_y$}; 130 | \draw (1.35,-0.2) -- (1.35,4.25519); 131 | \draw (-0.2,3.85742) -- (1.55,3.85742); 132 | \draw (1.35,3.85742) node [below right,scale=0.6] {$M(x,y)$}; 133 | %\clip (-1,-1) rectangle (5,5);%只在这个区域内画图 134 | \draw[domain=1:4,smooth,variable=\t] plot ({ln(\t)+1/(2*\t)-0.5},\t)node[above,scale=0.6] {$C_3$}; 135 | \draw[domain=0:1.8,smooth] plot (\x,{0.5*1+0.5*exp(\x)}) node[below right,scale=0.6] {$C_1$}; 136 | \draw[domain=0:1.45,smooth] plot (\x,{exp(\x)}) node[below right,scale=0.6] {$C_2$}; 137 | \filldraw [fill=gray!20] (0,0) -- plot [domain=0:1.35,smooth] (\x,{exp(\x)}) -- (1.35,0) -- (0,0); 138 | \filldraw [fill=white] (0,0) -- plot [domain=0:1.35,smooth] (\x,{0.5*1+0.5*exp(\x)}) -- (1.35,0) -- (0,0); 139 | \filldraw [fill=gray!40] (0,1) -- plot [domain=0:1.35,smooth] (\x,{exp(\x)}) -- (0,3.85742) -- (0,1); 140 | \filldraw [fill=white] (0,1) -- plot [domain=1:3.85742,smooth,variable=\t] ({ln(\t)+1/(2*\t)-0.5},\t) -- (0,3.85742) -- (0,1); 141 | \end{tikzpicture} 142 | 143 | \begin{tikzpicture}[scale=1.5] 144 | \draw[-stealth] (-0.3,0) -- (2.2,0)node (xaxis) [right,scale=0.8] {$x$}; 145 | \draw[-stealth] (0,-1.6) -- (0,1.6)node (yaxis) [left,scale=0.8] {$y$}; 146 | \fill[pink!] (0,0) -- (1,-1) arc [start angle=315, end angle=405, radius=1.414] -- (0,0); 147 | \fill[pink!] (1,0) -- (1,1) arc [start angle=90, end angle=180, radius=1] -- (0,0); 148 | \fill[grassgreen] (0,0) -- (1,-1) arc [start angle=315, end angle=360, radius=1.414] -- (1.414,0)--(2,0) arc [start angle=360, end angle=270, radius=1] -- (1,-1); 149 | \fill[grassgreen] (0,0) -- (1,1) arc [start angle=45, end angle=0, radius=1.414] -- (1.414,0)--(2,0) arc [start angle=0, end angle=90, radius=1] -- (1,1); 150 | \draw (1,-0.02)--(1,0.02) node[below] {$\scaleobj{0.6}{1}$}; 151 | \draw (1.414,-0.02)--(1.414,0.02) node[below] {$\scaleobj{0.6}{\sqrt{2}}$}; 152 | \draw[style=dashed,color=red,domain=-0.1:1.4] plot(\x,-\x); 153 | \draw[color=black,domain=-0.1:2.2] plot(\x,0); 154 | \draw[style=dashed] (0,0)--(0,-1.414) arc [start angle=270, end angle=450, radius=1.414]; 155 | \draw (1,0) circle [radius=1]; 156 | %\fill[pattern=north west lines](0,0)--(-2,0)--(-2,2)--(0,2)arc(90:270:0.8); 157 | %\fill[pattern=north west lines]arc(-45:0:1); 158 | \end{tikzpicture} 159 | \section{填充} 160 | 画一个带渐变阴影的形状。默认阴影是从灰到白。 当然你可以设置不同颜色及不同的渐变方式, 比如中心渐变,左部渐变等。 161 | 162 | \begin{tikzpicture}[rounded corners, ultra thick] 163 | \shade [top color=yellow, bottom color=orange] (0,0) rectangle +(2,1); 164 | \shade [top color=yellow, bottom color=blue] (3,0) -- (4,0) -- (3.5 ,1.5) -- cycle; 165 | \shadedraw [inner color=blue, outer color=black, draw = red] (6,0) rectangle +(2,1); 166 | \shade[ball color=cyan] (9, 0.5) circle (0.5cm); 167 | \end{tikzpicture} 168 | 169 | 用法: 170 | \begin{verbatim} 171 | \fill[options] (x1,y1) -- (x2,y2) arc (angle1:angle2:radius) -- (x3,y3); 172 | \fill[options] (x1,y1) -- (x2,y2) arc (angle1:angle2:radius) -- cycle; % better 173 | \filldraw[options] (x1,y1) -- (x2,y2) arc (angle1:angle2:radius) -- cycle; 174 | \end{verbatim} 175 | \begin{lstlisting} 176 | \begin{tikzpicture}[line width=5pt] 177 | \fill[blue!80] (0,0) -- (3,0) arc (0:30:2) -- (0,0); 178 | \draw (4,0) -- (5,0) -- (5,1) -- (4,0); 179 | \draw (6,0) -- (7,0) -- (7,1) -- cycle; 180 | \filldraw[fill=green!20!white, draw=green!50!black] 181 | (8,0) -- (11,0) arc (0:45:3) -- cycle; 182 | \end{tikzpicture} 183 | \end{lstlisting} 184 | \begin{center} 185 | \begin{tikzpicture}[line width=5pt] 186 | \fill[blue!80] (0,0) -- (3,0) arc (0:30:2) -- (0,0); 187 | \draw (4,0) -- (5,0) -- (5,1) -- (4,0); 188 | \draw (6,0) -- (7,0) -- (7,1) -- cycle; 189 | \filldraw[fill=green!20!white, draw=green!50!black] 190 | (8,0) -- (11,0) arc (0:45:3) -- cycle; 191 | \end{tikzpicture} 192 | \end{center} 193 | 194 | \section{阴影} 195 | 用法: 196 | \begin{verbatim} 197 | \shade[options] (x1,y1) rectangle (x2,y2); 198 | \shadedraw[options] (x1,y1) circle (radius); 199 | \end{verbatim} 200 | \begin{lstlisting} 201 | \begin{tikzpicture}[rounded corners,ultra thick] 202 | \shade (0,0) rectangle (2,1); 203 | \shadedraw (3,0.5) circle (.5cm); 204 | \shade[top color=yellow,bottom color=black] (0,0) rectangle +(2,1); 205 | \shade[left color=yellow,right color=black] (3,0) rectangle +(2,1); 206 | \shadedraw[inner color=yellow,outer color=black,draw=yellow] 207 | (6,0) rectangle +(2,1); 208 | \shade[ball color=green] (9,.5) circle (.5cm); 209 | \shadedraw[left color=gray,right color=green, draw=green!50!black] 210 | (10,0.3) -- +(1,0) arc (0:30:1) -- cycle; 211 | \end{tikzpicture} 212 | \end{lstlisting} 213 | \begin{tikzpicture}[rounded corners,ultra thick] 214 | \shade (0,0) rectangle (2,1); 215 | \shadedraw (3,0.5) circle (.5cm); 216 | \shade[top color=yellow,bottom color=black] (0,0) rectangle +(2,1); 217 | \shade[left color=yellow,right color=black] (3,0) rectangle +(2,1); 218 | \shadedraw[inner color=yellow,outer color=black,draw=yellow] 219 | (6,0) rectangle +(2,1); 220 | \shade[ball color=green] (9,.5) circle (.5cm); 221 | \shadedraw[left color=gray,right color=green, draw=green!50!black] 222 | (10,0.3) -- +(1,0) arc (0:30:1) -- cycle; 223 | \end{tikzpicture} -------------------------------------------------------------------------------- /class/ch03.tex: -------------------------------------------------------------------------------- 1 | \chapter{指定参考点或坐标系} 2 | Tikz 默认单位是厘米,直角坐标下,二元数 (1,2) 表示 $x$ 方向一倍的单位长度 (1cm) ,$y$方向2倍的单位长度 (1cm) 。这种表示是绝对坐标。当然最好是添加上单位。比如(1cm,2pt), 表示$x$ 方向 1cm,$y$ 方向2个磅\footnote{磅,pt 是 point的简写,是英文字号的单位,在欧美字体度量系统常用, 1pt 大约为 0.35 毫米。常用的 5 号字体是 10.5 磅,绝对长度约 3.7 毫米。} 长度。其用法如下: 3 | \begin{verbatim} 4 | (xpt,ycm): xpt in x-direction and ycm in y-directions. 5 | (xdegree:ycm): ycm in direction x degree. 6 | +(x,y): xcm above and ycm right from the previous specified position. 7 | ++(x,y): xcm above and ycm right from the previous specified position 8 | and making this the new specified position. 9 | (x1,y1) -- (x2,y2): straight line from (x1,y1) to (x2,y2); 10 | (x1,y1) -| (x2,y2): a horizontal and vertical line from (x1,y1) to (x2,y2); 11 | (x1,y1) |- (x2,y2); a vertical and horizontal line from (x1,y1) to (x2,y2); 12 | \end{verbatim} 13 | \begin{lstlisting} 14 | \begin{tikzpicture} 15 | \draw[red,very thick] (30:1cm) -- (0,0); 16 | \draw[blue,very thick] (0,0) -| +(1.5,0.5) ; 17 | \draw[green,very thick] (0,0) |- ++(0,1) -- (1,0); 18 | \end{tikzpicture} 19 | \end{lstlisting} 20 | \begin{center} 21 | \begin{tikzpicture} 22 | \draw[red,very thick] (30:1cm) -- (0,0); 23 | \draw[blue,very thick] (0,0) -| +(1.5,0.5) ; 24 | \draw[green,very thick] (0,0) |- ++(0,1) -- (1,0); 25 | \end{tikzpicture} 26 | \end{center} 27 | 另一种方式的坐标是参考上一个点的参考坐标系,通常在二元数前添 28 | 加“ + ”号进行标识。比如 +(0cm, 1cm) 表示相对上一个点向上移动 1cm。而 ++(2cm,0cm) 表示,相对于上一个点向右移动 2cm。下面给出几个例子体会 + 与 ++ 的区别。 29 | 30 | 在极坐标系下, 使用类似 (30:1cm) 的方式, 表示 30 度方向的一个 1cm长度所在那个点。 31 | \begin{tikzpicture}[>=Stealth,scale=0.2,smooth] 32 | \draw[->](-10,0)--(0,0) node[below left=-1.2pt]{$O$}--(20,0) node[below=1.5pt]{$x$}; 33 | \draw[->](0,-8)--(0,10)node[left]{$y$}; 34 | \draw (0,0) sin (3,3) cos (6,0); 35 | \draw (6,0) sin (9,-3) cos (12,0); 36 | \end{tikzpicture} 37 | \begin{tikzpicture}[domain=0:4] 38 | \draw[very thin,color=gray] (0,-1.5) grid (4.0,4.0); 39 | \draw[->] (-1.5,0) -- (4.2,0) node[right] {$x$}; 40 | \draw[->] (0,1.5) -- (0,4.2) node[above] {$f(x)$}; 41 | \draw[color=red] plot (\x,\x) node[right] {$f(x) =x$}; 42 | \draw[color=blue] plot (\x,{cos(\x r)}) node[below right] {$f(x) = \cos x$}; 43 | \draw[black] plot (\x,{sin(\x r)}) node[above right] {$f(x) = \sin x$}; 44 | \draw[color=orange] plot (\x,{0.01*exp(\x)}) 45 | node[right] {$f(x) = \frac{1}{10} \mathrm e^x$}; 46 | \end{tikzpicture} 47 | \begin{tikzpicture}[x={(-.1cm,-.15cm)},y={(1cm,0cm)},z={(0cm,1cm)}] 48 | \draw[->] (0,0,0) -- (10,0,0) node[below] {$x$}; 49 | \draw[->] (0,-2,0) -- (0,2,0) node[right] {$y$}; 50 | \draw[->] (0,0,-2) -- (0,0,3) node[above] {$z$}; 51 | \draw[color=red] plot[domain=0:2*pi] ({sin(\x r)},{cos(\x r)},2); 52 | \draw[color=red] (0,0,0) -- (0,1,2) (0,0,0) -- (0,-1,2); 53 | \end{tikzpicture} 54 | 55 | \begin{tikzpicture} 56 | \draw(0,0)coordinate(A)node[left]{$A$}(2,0)coordinate(B)node[below]{$B$} 57 | (1.5,0.6)coordinate(D)node[left]{$D$}(3.5,0.6)coordinate(C)node[right]{$C$}; 58 | \draw(0,4)coordinate(A1)node[left]{$A_1$}(2,4)coordinate(B1)node[below right=-2pt and -2pt]{$B_1$} 59 | (1.5,4.6)coordinate(D1)node[above]{$D_1$}(3.5,4.6)coordinate(C1)node[right]{$C_1$}; 60 | \draw(A)--(A1)--(D1)--(C1)--(B1)--(A1)(A)--(B)--(C)--(C1)(B)--(B1); 61 | \draw(0.75,2.3)coordinate(N)node[left]{$N$} 62 | (2,2)coordinate(M)node[left]{$M$}(2.75,0.3)coordinate(E)node[right]{$E$}; 63 | \draw[densely dashed](A)--(D)--(A1)(D1)--(D)--(C1)(D)--(C)(N)--(M)(D)--(E); 64 | \draw(C1)--(E)(A1)--(M)--(A); 65 | \end{tikzpicture} 66 | \begin{tikzpicture} 67 | \draw(-0.3,0.3)coordinate(A)node[left]{$A$}--(0,0)coordinate(B)node[below]{$B$}--(1.8,0)coordinate(C)node[below]{$C$}; 68 | \draw[densely dashed](A)--(C); 69 | \draw[shift={(1cm,1.732cm)}](-0.3,0.3)coordinate(D)node[left]{$D$}--(0,0)coordinate(E)node[below right=0pt and -4pt]{$E(F)$}--(1.8,0)coordinate(G)node[right]{$G$}--(D); 70 | \draw(A)--(D)(B)--(E)(C)--(G); 71 | \end{tikzpicture} 72 | \begin{tikzpicture}[>=Stealth] 73 | \draw(-0.3,0.3)coordinate(A)node[left]{$A$}--(0,0)coordinate(B)node[below]{$B$}--(1.8,0)coordinate(C)node[below]{$C$}; 74 | \draw[densely dashed](A)--(C); 75 | \draw[shift={(1cm,1.732cm)}](-0.3,0.3)coordinate(D)node[left]{$D$}--(0,0)coordinate(E)node[below right=0pt and -4pt]{$E(F)$}--(1.8,0)coordinate(G)node[right]{$G$}--(D); 76 | \draw(A)--(D)(B)--(E)(C)--(G); 77 | \draw[->](1,0)node[below]{$H$}--(3.2,0)node[below]{$x$}; 78 | \draw[->](1,0)--(1,2.7)node[left]{$z$}; 79 | \draw[->,densely dashed](1,0)--(0.18,0.8)node[below]{$y$}; 80 | \end{tikzpicture} 81 | 82 | \begin{tikzpicture}[scale=0.7] 83 | \draw(0,0)coordinate(A)node[left]{$A$}(6,0)coordinate(B)node[right]{$B$} 84 | (2,2.4)coordinate(D)node[left]{$D$}(8,2.4)coordinate(C)node[right]{$C$} 85 | (0,3.6)coordinate(A1)node[left]{$A_1$}(2,6)coordinate(D1)node[above]{$D_1$} 86 | (8,6)coordinate(C1)node[above]{$C_1$}(4,3)coordinate(O)node[left]{$O$} 87 | (6,3.6)coordinate(B1)node[below left=-0.5pt and -4pt]{$B_1$}(7.1,1.32)coordinate(E)node[right]{$E$} 88 | (6,1.8)coordinate(H)node[left]{$H$}(7,4.8)coordinate(G)node[left]{$G$} 89 | (8,4.2)coordinate(F)node[right]{$F$}; 90 | \draw(A)--(A1)--(D1)--(C1)--(B1)--(A1)(A)--(B)--(B1)(B)--(C)--(C1) 91 | (E)--(F)--(G)--(H)--(E); 92 | \draw[densely dashed](A)--(D)--(D1)(D)--(C)(H)--(O)--(E)(F)--(O)--(G); 93 | \end{tikzpicture} 94 | \begin{tikzpicture} 95 | \draw(0,0)coordinate(E)node[below]{$E$}--++(0,1)coordinate(D)node[above]{$D$}--++(2,0)coordinate(A)node[above]{$A$}--++(0,-1)coordinate(B)node[below left=0pt and -2pt]{$B$}--(E) 96 | (B)--++(2,0)coordinate(C)node[above right=-2pt and -3pt]{$C$}--++(-60:2)coordinate(G)node[below]{$G$} 97 | --++(-2,0)coordinate(F)node[below]{$F$}--(B)(A)--(C); 98 | \end{tikzpicture} -------------------------------------------------------------------------------- /class/ch04.tex: -------------------------------------------------------------------------------- 1 | \chapter{直方图} 2 | \begin{tikzpicture}[xscale=0.7,yscale=10,>=Stealth] 3 | \draw[decorate,decoration={snake,segment length=1mm,amplitude=0.5mm}] 4 | (0,0)node[below left]{$O$}--(0.5,0); 5 | \draw[->](0.5,0)--(8.3,0)node[below]{百分比}; 6 | \draw[->](0,0)--(0,0.4)node[right]{频率/组距}; 7 | \foreach \x in{2.5,...,8.5} 8 | \node[below]at(\x-1.5,0){$\x$}; 9 | \draw(1,0)--(1,0.05)--(2,0.05)(2,0)--(2,0.1)--(3,0.1)(3,0)--(3,0.15)--(4,0.15)(4,0)--(4,0.35)--(5,0.35)--(5,0.35)--(5,0)(5,0.2)--(6,0.2)--(6,0)(6,0.15)--(7,0.15)--(7,0); 10 | \draw[densely dotted](6,0.15)--(0,0.15)node[left]{$0.15$} 11 | (5,0.2)--(0,0.2)node[left]{$0.20$}(4,0.35)--(0,0.35)node[left]{$a$}(2,0.1)--(0,0.1)node[left]{$b$}(1,0.05)--(0,0.05)node[left]{$0.05$}; 12 | \end{tikzpicture} 13 | \begin{tikzpicture}[xscale=0.7,yscale=10,>=Stealth] 14 | \draw[decorate,decoration={snake,segment length=1mm,amplitude=0.5mm}] 15 | (0,0)node[below left]{$O$}--(0.5,0); 16 | \draw[->](0.5,0)--(8.3,0)node[below]{百分比}; 17 | \draw[->](0,0)--(0,0.4)node[right]{频率/组距}; 18 | \foreach \x in{1.5,...,7.5} 19 | \node[below]at(\x-0.5,0){$\x$}; 20 | \draw(1,0)--(1,0.15)--(2,0.15)(2,0)--(2,0.2)--(3,0.2)(3,0)--(3,0.3) 21 | --(4,0.3)--(4,0)(4,0.2)--(5,0.2)--(5,0)(5,0.1)--(6,0.1)--(6,0)(6,0.05)-- 22 | (7,0.05)--(7,0); 23 | \draw[densely dotted](6,0.05)--(0,0.05)node[left]{$0.05$} 24 | (5,0.1)--(0,0.1)node[left]{$0.10$}(4,0.2)--(3,0.2)(2,0.2)--(0,0.2) 25 | node[left]{$0.20$}(3,0.3)--(0,0.3)node[left]{$0.30$}(1,0.15)--(0,0.15)node[left]{$0.15$}; 26 | \end{tikzpicture} -------------------------------------------------------------------------------- /class/ch05.tex: -------------------------------------------------------------------------------- 1 | \chapter{绘制函数图像} 2 | 这里分享的是一个初学者制作的几个简单的数学象限里的图片 3 | 4 | \begin{tikzpicture}[domain=-2:4,yscale=1,samples=200,>=latex,thick] 5 | % \clip (0,0) rectangle (5,5);% 切り抜き 6 | \draw[thick,->] (-1,0) -- (4,0) node[right] {$x$};% x軸 7 | \draw[thick,->] (0,-1) -- (0,4) node[below left] {$y$};% y軸 8 | \draw (0,0) node[below left] {O};% 原点 9 | 10 | \coordinate (O) at (0,0); 11 | 12 | \draw[domain=-0.5:2,color=black] plot (\x, {2*\x}) node[right] {$y=2x$}; 13 | \draw[domain=-1:4,color=black] plot (\x, {-2/3*\x+2}) node[right] {$2x+3y=6$}; 14 | \draw[domain=-1:4,color=black] plot (\x, {3/2}) node[right] {$y=\dfrac{3}{2}$}; 15 | 16 | \coordinate (A) at (1,2); 17 | \coordinate (O) at (3/4,3/2); 18 | \coordinate (B) at (2,3/2); 19 | \coordinate (C) at (2,2/3); 20 | 21 | \pic["$\alpha$",draw=black,->,very thick,angle eccentricity=1.4,angle radius=8mm] {angle=B--O--A}; 22 | \pic["$\beta$",draw=black,->,thick,angle eccentricity=1.4,angle radius=9mm] {angle=C--O--B}; 23 | \end{tikzpicture} 24 | \begin{tikzpicture}[domain=-2:4,yscale=1,samples=200,>=latex,thick] 25 | % \clip (0,0) rectangle (5,5);% 切り抜き 26 | \draw[thick,->] (-2,0) -- (4,0) node[right] {$x$};% x軸 27 | \draw[thick,->] (0,-2) -- (0,6) node[below left] {$y$};% y軸 28 | \draw (0,0) node[below left] {O};% 原点 29 | 30 | \draw (0,0) circle[radius=10mm]; 31 | 32 | \coordinate (O) at (0,0); 33 | \coordinate (A) at (5/2,12/2); 34 | \coordinate (B) at (4/2,-3/2); 35 | \coordinate (C) at (77/65,21/65); 36 | 37 | \fill (A) circle (2pt) node[right] {$\mathrm{A}(5,12)$};% 点 38 | \fill (B) circle (2pt) node[right] {$\mathrm{B}(4,-3)$};% 点 39 | \fill (C) circle (2pt) node[right] {$\mathrm{C}$};% 点 40 | 41 | \draw (O)--(A); 42 | \draw (O)--(B); 43 | \draw (C)--(5/13,12/13); 44 | \draw (C)--(4/5,-3/5); 45 | 46 | \draw [thick,->] (O)--(5/13,12/13) node[right] {$\dfrac{\bm{a}}{\|\bm{a}\|}$}; 47 | \draw [thick,->] (O)--(4/5,-3/5) node[right] {$\dfrac{\bm{b}}{\|\bm{b}\|}$}; 48 | 49 | \draw[domain=-2:3,color=black] plot (\x, {3/11*\x}) node[right] {$3x-11y=0$}; 50 | \end{tikzpicture} 51 | 52 | 53 | \begin{tikzpicture}[domain=-2:4,yscale=0.5,samples=200,>=latex,thick] 54 | % \clip (0,0) rectangle (5,5);% 切り抜き 55 | \draw[thick,->] (-2,0) -- (4,0) node[right] {$x$};% x軸 56 | \draw[thick,->] (0,-4) -- (0,7) node[below right] {$y$};% y軸 57 | \draw (0,0) node[below left] {O};% 原点 58 | \draw[domain=-2:-0.36,color=black] plot (\x, {(2*\x*\x*\x+1)/(\x*\x)}) node[below left] {$y=\dfrac{2x^3+1}{x^2}$}; 59 | \draw[domain=0.4:3,color=black] plot (\x, {(2*\x*\x*\x+1)/(\x*\x)}); 60 | \draw[domain=-2:3,color=black,dashed,thin] plot (\x, {2*\x}); 61 | \draw (1.2,2) node[right] {$y=2x$}; 62 | \draw[domain=-2:4,color=black] plot (\x, {-2}) node[below] {$y=a$}; 63 | \end{tikzpicture} 64 | \begin{tikzpicture}[domain=-2:4,scale=1,samples=200,>=latex,thick] 65 | % \clip (0,0) rectangle (5,5);% 切り抜き 66 | \draw[thick,->] (-2,0) -- (5,0) node[right] {$x$};% x軸 67 | \draw[thick,->] (0,-1) -- (0,9) node[below right] {$y$};% y軸 68 | \draw (0,0) node[below left] {O};% 原点 69 | 70 | \draw[domain=4.2:-2.5,color=black] plot (\x, {1/2*\x*\x}) node[right] {$C:y=\dfrac{1}{2}x^2$}; 71 | \draw[domain=-0.5:4.4,color=black] plot (\x, {2*\x}) node[right] {$y=2x$}; 72 | 73 | \coordinate (O) at (0,0); 74 | \coordinate (Q) at (2,2); 75 | \coordinate (R) at (2,4); 76 | \coordinate (P) at (1*1.2,2*1.2); 77 | 78 | \draw[dashed] (4,8) -- (4,0) node[below] {4};% y軸 79 | 80 | \draw (Q) node[right] {Q}; 81 | \draw (R) node[above left] {R}; 82 | \draw (P) node[left] {P}; 83 | \draw (2,0) node[below] {$t$}; 84 | 85 | \draw (R)--(2,0); 86 | \draw (O)--(P) node [midway,left] {$X$}; 87 | \draw (P)--(Q) node [midway,below] {$Y$}; 88 | 89 | \draw [bend left,distance=20mm,dotted] (O) to node [fill=white,inner sep=0.5pt,circle] {[$\sqrt{5}$]} (R); 90 | \draw [bend right,distance=10mm,dotted] (O) to node [fill=white,inner sep=0.5pt,circle] {[1]} (2,0); 91 | \draw [bend left,distance=20mm,dotted] (R) to node [fill=white,inner sep=0.5pt,circle] {[2]} (2,0); 92 | \end{tikzpicture} 93 | 94 | 95 | \begin{tikzpicture}[domain=-2:4,scale=0.5,samples=200,>=latex,thick] 96 | % \clip (0,0) rectangle (5,5);% 切り抜き 97 | \draw[thick,->] (-2,0) -- (10,0) node[right] {$x$};% x軸 98 | \draw[thick,->] (0,-1) -- (0,9) node[below right] {$y$};% y軸 99 | \draw (0,0) node[below left] {O};% 原点 100 | 101 | \draw[domain=4.2:-2.5,color=black] plot (\x, {1/2*\x*\x}) node[right] {$C:y=\dfrac{1}{2}x^2$}; 102 | \draw[fill=black] (2,2) circle[radius=1mm] node[right] {$P$}; 103 | \draw[domain=4.2:-1.5,color=black,rotate=-63] plot (\x, {1/2*\x*\x}); 104 | \draw[fill=black,rotate=-63] (2,2) circle[radius=0.8mm] node[below] {$P'$}; 105 | 106 | \draw[domain=-0.5:4.4,color=black] plot (\x, {2*\x}) node[right] {$y=2x$}; 107 | 108 | \draw[dashed] (4,8) -- (4,0) node[below] {4};% y軸 109 | \draw (8.8,0) node[below] {$4\sqrt{5}$}; 110 | \draw (0.2,0) node[above right] {$\theta$}; 111 | 112 | \coordinate (O) at (0,0); 113 | 114 | \draw [bend left,distance=20mm,dotted] (O) to node [fill=white,inner sep=0.5pt,circle] {[$\sqrt{5}$]} (4,8); 115 | \draw [bend left,distance=20mm,dotted] (4,8) to node [fill=white,inner sep=0.5pt,circle] {[2]} (4,0); 116 | \draw [bend left,distance=15mm,dotted] (O) to node [fill=white,inner sep=0.5pt,circle] {[1]} (4,0); 117 | \end{tikzpicture} -------------------------------------------------------------------------------- /class/ch06.tex: -------------------------------------------------------------------------------- 1 | \chapter{流程图} 2 | \begin{center} 3 | \tikzset{ 4 | every picture/.style={ 5 | >=Stealth, 6 | node distance=5mm and 5mm 7 | }} 8 | \tikzstyle{SS} %开始结束 9 | =[rounded corners, draw] 10 | \tikzstyle{IO} %输入输出 11 | =[trapezium, trapezium left angle=70, trapezium right angle=110, draw] 12 | \tikzstyle{NR} %内容 13 | =[draw] 14 | \tikzstyle{PD} %判断 15 | =[diamond, aspect=4, draw, inner sep=1.5pt]\hfill 16 | \begin{tikzpicture}[every node/.style={minimum width=1.8cm},->] 17 | \node[draw,rounded corners,minimum height=0.6cm,minimum width=1.3cm](start){开始}; 18 | \node[rectangle,draw, below=of start](in){$A=\frac12$}; 19 | \node[rectangle,draw, below=of in,minimum height=0.6cm](n1){$k=1$}; 20 | \node[PD, below=of n1,minimum height=0.6cm](pd){$k\leqslant 2$}; 21 | \node[rectangle,draw,below=of pd,minimum height=0.6cm](M1){}; 22 | \node[rectangle,draw,below=of M1,minimum height=0.6cm](M2){$k=k+1$}; 23 | \node[IO,right=of M1](M3){输出$A$}; 24 | \node[SS,below=of M3,minimum width=1.3cm](M4){结束}; 25 | \draw (pd)--node[right=-0.55cm]{是}(M1); 26 | \draw (pd) -| node[right=-.6cm]{否} (M3); 27 | \draw (M2.west)--++(-0.5,0) |- ($(n1.south)!0.5!(pd.north)$); 28 | \path(start)edge(in) 29 | (in)edge(n1) 30 | (n1)edge(pd) 31 | (pd)edge(M1) 32 | (M1)edge(M2) 33 | (M3)edge(M4); 34 | \end{tikzpicture} 35 | % 流程图定义基本形状 36 | \tikzstyle{ellipse}=[draw, rectangle, minimum width=2.8em, rounded corners=6pt,line width=0.5pt]% minimum height=1.5em, fill=red!20 37 | \tikzstyle{pxsbx}=[trapezium, trapezium left angle=75, trapezium right angle=105, minimum width=3em, text centered, draw = black, fill=white,line width=0.5pt] 38 | \tikzstyle{lingxing}=[draw,diamond,shape aspect=3,inner sep = 0.4pt,thick,font=\itshape,line width=0.5pt] 39 | %,minimum size=8mm 40 | \begin{tikzpicture}[node distance=1.2cm] 41 | %定义流程图具体形状 42 | \node (start) [ellipse,inner sep=1.5pt] {开始}; 43 | \node (srn) [pxsbx, below of=start,node distance=1.0cm,inner sep=1.5pt] {输入}; 44 | \node (yizhi) [minimum height=0cm,draw, below of=srn,node distance=1.0cm,inner sep=2pt] {过程}; 45 | \node (tiaojian) [lingxing,draw, below of=yizhi,inner sep=1.5pt] {判断}; 46 | \node (shi) [minimum height=0cm,draw, below of=tiaojian,inner sep=2pt] {循环1}; 47 | \node (fuzhi1) [minimum height=0cm,draw, below of=shi,inner sep=2pt] {循环2}; 48 | \node (fuzhi2) [minimum height=0cm,draw, below of=fuzhi1,inner sep=2pt] {循环3}; 49 | \node (fou) [right of=tiaojian,xshift=1cm,coordinate] {}; 50 | \node (shuchus) [below of=fou,draw,pxsbx,inner sep=1.5pt,node distance=1.0cm] {输出$\!S$}; 51 | \node (end) [below of=shuchus,draw,ellipse,inner sep=1.5pt,node distance=1.0cm] {结束}; 52 | %连接具体形状 53 | \draw[arrows={-Stealth[scale=0.8]}](start) -- (srn); 54 | \draw[arrows={-Stealth[scale=0.8]}](srn) -- (yizhi) ; 55 | \path (yizhi) -- (tiaojian) coordinate[pos=0.5](yt); 56 | \node [left of=yt,coordinate,node distance=2.3cm] (c1) {}; 57 | \draw[arrows={-Stealth[scale=0.8]}](yizhi) -- (tiaojian); 58 | \draw[arrows={-Stealth[scale=0.8]}](tiaojian) -- node[right=-0.5mm,blue]{是}(shi); 59 | \draw[arrows={-Stealth[scale=0.8]}](shi) -- (fuzhi1); 60 | \draw[arrows={-Stealth[scale=0.8]}](fuzhi1)--(fuzhi2); 61 | \draw[arrows={Stealth[scale=0.8]-}](yt)--(c1); 62 | \draw(c1)|- (fuzhi2); 63 | \draw(tiaojian)-- node[midway,above=-1mm,blue]{否}(fou); 64 | \draw[arrows={-Stealth[scale=0.8]}](fou)--(shuchus); 65 | \draw[arrows={-Stealth[scale=0.8]}](shuchus)--(end); 66 | \end{tikzpicture} 67 | \end{center} 68 | 69 | \setlength{\unitlength}{1mm} 70 | \newcommand{\wrt}[1]{\makebox(0,0)[c]{#1}} 71 | \newcommand{\lline}[1]{\line(-1,0){#1}} 72 | \newcommand{\rline}[1]{\line(1,0){#1}} 73 | %\newcommand{\Uline}[1]{\line(0,1){#1}} 74 | \newcommand{\dline}[1]{\line(0,-1){#1}} 75 | %\newcommand{\lvec}[1]{\vector(-1,0){#1}} 76 | \newcommand{\rvec}[1]{\vector(1,0){#1}} 77 | \newcommand{\uvec}[1]{\vector(0,1){#1}} 78 | \newcommand{\dvec}[1]{\vector(0,-1){#1}} 79 | \newsavebox{\condition} 80 | \newsavebox{\process} 81 | \newsavebox{\inputoutput} 82 | \savebox{\process}(0,0){\thicklines 83 | \put(-10,-3){\framebox(20,6){}} 84 | } 85 | \savebox{\condition}(0,0){\thicklines 86 | \put(-10,0){\line(2,1){10}} 87 | \put(-10,0){\line(2,-1){10}} 88 | \put(10,0){\line(-2,1){10}} 89 | \put(10,0){\line(-2,-1){10}} 90 | } 91 | \savebox{\inputoutput}(0,0){\thicklines 92 | \put(-10.5,-3){\rline{18}} 93 | \put(-10.5,-3){\line(1,2){3}} 94 | \put(10.5,3){\lline{18}} 95 | \put(10.5,3){\line(-1,-2){3}} 96 | } 97 | {\vspace*{1cm}\hspace*{3cm} 98 | \begin{picture}(45,73)(20,-73)\thicklines 99 | \put(40,3){\oval(15,6)}\put(40,3){\wrt{开始}} \put(40,0){\dvec{5}} 100 | \put(40,-8){\usebox{\inputoutput}} \put(40,-8){\wrt{输入$m,\,n$}} 101 | \put(40,-11){\dvec{5}} \put(40,-19){\usebox{\process}} 102 | \put(40,-19){\wrt{$i=1$}} \put(40,-22){\dvec{8}} 103 | \put(40,-33){\usebox{\process}} \put(40,-33){\wrt{$a=m\times i$}} 104 | \put(40,-36){\dvec{5}} \put(40,-46){\usebox{\condition}} 105 | \put(40,-46){\wrt{$n$整除$a$?}} \put(40,-51){\dvec{5}} 106 | \put(41,-53){\makebox(0,0)[l]{是}} 107 | \put(40,-59){\usebox{\inputoutput}} \put(40,-59){\wrt{输出$a,\,i$}} 108 | \put(40,-62){\dvec{5}} 109 | \put(40,-70){\oval(15,6)}\put(40,-70){\wrt{结束}} 110 | \put(30,-46){\line(-1,0){15}} \put(28,-45){\makebox(0,0)[b]{否}} 111 | \put(15,-46){\uvec{10}} \put(15,-33){\usebox{\process}} 112 | \put(15,-33){\wrt{$i=i+1$}} \put(15,-30){\line(0,1){5}} 113 | \put(15,-25){\rvec{25}} 114 | \end{picture}} 115 | % 流程图定义基本形状 116 | \tikzstyle{ellipse}=[draw, rectangle, minimum width=2.8em, rounded corners=6pt,line width=0.5pt]% minimum height=1.5em, fill=red!20 117 | \tikzstyle{pxsbx}=[trapezium, trapezium left angle=75, trapezium right angle=105, minimum width=3em, text centered, draw = black, fill=white,line width=0.5pt] 118 | \tikzstyle{lingxing}=[draw,diamond,shape aspect=3,inner sep = 0.4pt,thick,font=\itshape,line width=0.5pt]%,minimum size=8mm 119 | \begin{tikzpicture}[node distance=1.2cm] 120 | %定义流程图具体形状 121 | \node (start) [ellipse,inner sep=1.5pt] {开始}; 122 | \node (srn) [pxsbx, below of=start,node distance=1.0cm,inner sep=1.5pt] {输入$\!n=0$}; 123 | \node (yizhi) [minimum height=0cm,draw, below of=srn,node distance=1.0cm,inner sep=2pt] {$A=3^n-2^n$}; 124 | \node (panduan) [lingxing,draw, below of=yizhi,inner sep=1.5pt,minimum width=5em,minimum height=1.5em,node distance=1cm] {\phantom{$N$}}; 125 | \node (hh) [minimum height=0.95em,minimum width=3em,draw, left of=yizhi,node distance=1.0cm,inner sep=2pt,xshift=-0.8cm,yshift=-1mm] {$$}; 126 | 127 | \node (shuchu) [below of=panduan,draw,pxsbx,inner sep=1.5pt,node distance=1.1cm] {输出$\!n$}; 128 | \node (end) [below of=shuchu,draw,ellipse,inner sep=1.5pt,node distance=1.0cm] {结束}; 129 | %连接具体形状 130 | \draw[arrows={-Stealth[scale=0.8]}](start) -- (srn); 131 | \draw[arrows={-Stealth[scale=0.8]}](srn) -- (yizhi) ; 132 | \path (srn) -- (yizhi) coordinate[pos=0.5](yt); 133 | \draw[arrows={-Stealth[scale=0.8]}](yizhi) -- (panduan) ; 134 | \draw[arrows={-Stealth[scale=0.8]}](panduan) -- (shuchu) node[pos=0.45,left=-1mm]{否}; 135 | \draw[arrows={-Stealth[scale=0.8]}](panduan) -| (hh)node[left=-1.4em,below=2.4em]{是}; 136 | \draw[arrows={-Stealth[scale=0.8]}](hh) |- (yt) ; 137 | \draw[arrows={-Stealth[scale=0.8]}](shuchu)--(end); 138 | \end{tikzpicture} 139 | 140 | %例1 141 | \begin{tikzpicture}[->,arrows={-Stealth[scale=0.8]}] 142 | %放框 143 | \node[SS](start){开始}; 144 | \node[IO, below=of start](in){输入$N$}; 145 | \node[NR, below=of in](n1){$k=1$, $S=0$}; 146 | \node[NR, below=of n1](n2){$S=S+\dfrac1{k(k+1)}$}; 147 | \node[NR, right=of n2](n3){$k=k+1$}; 148 | \node[PD, below=of n2](pd){$k] 164 | \node[SS](start){开始}; 165 | \node[NR, below=of start](n1){$a=1$}; 166 | \node[NR, below right=1mm and 5mm of n1](n2){$a=a^2+2$}; 167 | \node[PD, below=8mm of n1](pd){$a<10$?}; 168 | \node[IO, below=of pd](out){输出$a$}; 169 | \node[SS, below=of out](stop){结束}; 170 | \path (start) edge (n1) 171 | (n1) edge (pd) 172 | (pd) edge node[right]{否}(out) 173 | (out) edge (stop); 174 | \draw (pd.east)node[below]{是} -| (n2); 175 | \draw (n2) -- (n2-|n1); 176 | \end{tikzpicture} 177 | %例3 178 | \begin{tikzpicture}[->] 179 | \node[SS](start){开始}; 180 | \node[IO, below=of start](in){输入$x$, $t$}; 181 | \node[NR, below=of in](n1){$M=1$, $S=3$, $k=1$}; 182 | \node[PD, below=of n1](pd){$k\le t$}; 183 | \node[NR, on grid, below left=1cm and 2cm of pd](n3){$M=\dfrac Mkx$}; 184 | \node[IO, on grid, below right=1cm and 2cm of pd](out){输出$S$}; 185 | \node[NR, below=of n3](n4){$S=M+S$}; 186 | \node[NR, below=of n4](n5){$k=k+1$}; 187 | \node[SS, below=of out](stop){结束}; 188 | \path (start) edge (in) 189 | (in) edge (n1) 190 | (n1) edge (pd) 191 | (n3) edge (n4) 192 | (n4) edge (n5) 193 | (out) edge (stop); 194 | \draw (pd) -| node[left]{是} (n3); 195 | \draw (pd) -| node[right]{否} (out); 196 | \draw (n5.west)--++(-0.5,0) |- ($(n1.south)!0.5!(pd.north)$); 197 | \end{tikzpicture} 198 | -------------------------------------------------------------------------------- /class/ch07.tex: -------------------------------------------------------------------------------- 1 | \chapter{实战练习} 2 | \begin{tikzpicture}[smooth] 3 | \draw[arrows={-Stealth[length=5pt, inset=3.5pt]}] (-0.5,0) -- (3.0,0)node (xaxis) [right=-1pt] {$x$}; 4 | \draw[arrows={-Stealth[length=5pt, inset=3.5pt]}] (0,-0.5) -- (0,4.5)node (yaxis) [above=-0.6pt] {$y$}; 5 | \draw (-0.18,-0.18) node {$o$}; 6 | \draw[color=red,domain=0:2.0,fill=green!20] plot (\x,4*\x-\x*\x); 7 | \draw[color=red!40,domain=0:2.90] plot (\x,4*\x-\x*\x) ; 8 | \draw[color=blue!30,domain=0:2.3] plot (\x,2*\x) ; 9 | \draw[fill=black] (2,4) circle [radius=0.2pt] node[above=-1.8pt] {$\scaleobj{0.8}{A(2,4)}$}; 10 | \end{tikzpicture} 11 | \begin{tikzpicture}[yscale=0.7] 12 | \draw[-stealth] (-0.4,0)--(2,0) node[below,scale=0.6]{$x$}; 13 | \draw[-stealth] (0,-0.3)--(0,5) node[left,scale=0.6]{$y$}; 14 | \draw (0,0) node [below left,scale=0.6] {$o$}; 15 | \foreach \i in {1}{\draw (\i,0)--node [below,scale=0.6] {$1$}(\i,0.05);} 16 | \draw (0,1) node [left,scale=0.6] {$1$}; 17 | \draw (1.35,1) node [right,scale=0.6] {$l_x$}; 18 | \draw (0.4,3.85742) node [above,scale=0.6] {$l_y$}; 19 | \draw (1.35,-0.2) -- (1.35,4.25519); 20 | \draw (-0.2,3.85742) -- (1.55,3.85742); 21 | \draw (1.35,3.85742) node [below right,scale=0.6] {$M(x,y)$}; 22 | %\clip (-1,-1) rectangle (5,5);%只在这个区域内画图 23 | \draw[domain=1:4,smooth,variable=\t] plot ({ln(\t)+1/(2*\t)-0.5},\t)node[above,scale=0.6] {$C_3$}; 24 | \draw[domain=0:1.8,smooth] plot (\x,{0.5*1+0.5*exp(\x)}) node[below right,scale=0.6] {$C_1$}; 25 | \draw[domain=0:1.45,smooth] plot (\x,{exp(\x)}) node[below right,scale=0.6] {$C_2$}; 26 | \filldraw [fill=gray!20] (0,0) -- plot [domain=0:1.35,smooth] (\x,{exp(\x)}) -- (1.35,0) -- (0,0); 27 | \filldraw [fill=white] (0,0) -- plot [domain=0:1.35,smooth] (\x,{0.5*1+0.5*exp(\x)}) -- (1.35,0) -- (0,0); 28 | \filldraw [fill=gray!40] (0,1) -- plot [domain=0:1.35,smooth] (\x,{exp(\x)}) -- (0,3.85742) -- (0,1); 29 | \filldraw [fill=white] (0,1) -- plot [domain=1:3.85742,smooth,variable=\t] ({ln(\t)+1/(2*\t)-0.5},\t) -- (0,3.85742) -- (0,1); 30 | \end{tikzpicture} 31 | 32 | \begin{tikzpicture}[scale=1.5] 33 | \draw[-stealth] (-0.3,0) -- (2.2,0)node (xaxis) [right,scale=0.8] {$x$}; 34 | \draw[-stealth] (0,-1.6) -- (0,1.6)node (yaxis) [left,scale=0.8] {$y$}; 35 | \fill[pink!] (0,0) -- (1,-1) arc [start angle=315, end angle=405, radius=1.414] -- (0,0); 36 | \fill[pink!] (1,0) -- (1,1) arc [start angle=90, end angle=180, radius=1] -- (0,0); 37 | \fill[grassgreen] (0,0) -- (1,-1) arc [start angle=315, end angle=360, radius=1.414] -- (1.414,0)--(2,0) arc [start angle=360, end angle=270, radius=1] -- (1,-1); 38 | \fill[grassgreen] (0,0) -- (1,1) arc [start angle=45, end angle=0, radius=1.414] -- (1.414,0)--(2,0) arc [start angle=0, end angle=90, radius=1] -- (1,1); 39 | \draw (1,-0.02)--(1,0.02) node[below] {$\scaleobj{0.6}{1}$}; 40 | \draw (1.414,-0.02)--(1.414,0.02) node[below] {$\scaleobj{0.6}{\sqrt{2}}$}; 41 | \draw[style=dashed,color=red,domain=-0.1:1.4] plot(\x,-\x); 42 | \draw[color=black,domain=-0.1:2.2] plot(\x,0); 43 | \draw[style=dashed] (0,0)--(0,-1.414) arc [start angle=270, end angle=450, radius=1.414]; 44 | \draw (1,0) circle [radius=1]; 45 | %\fill[pattern=north west lines](0,0)--(-2,0)--(-2,2)--(0,2)arc(90:270:0.8); 46 | %\fill[pattern=north west lines]arc(-45:0:1); 47 | \end{tikzpicture} 48 | \begin{tikzpicture}[scale=15] 49 | \begin{scope} 50 | \clip (0,0) arc (-90:0:1/8) arc (90:180:1/8); 51 | \fill[gray,even odd rule] (0,0) arc (-90:0:1/8) arc (90:180:1/8) 52 | arc (-90:270:1/16) arc (-180:180:1/16) arc (-90:0:1/16) arc (90:180:1/16); 53 | \end{scope} 54 | \draw [-stealth,thick](-0.05,0)--(0.3,0); 55 | \draw [-stealth,thick](0,-0.05)--(0,0.3); 56 | \node[right]at(0.3,0){$x$}; 57 | \node[left]at(0,0.3){$y$}; 58 | \draw (0,0) arc (-90:90:1/8) (0,0) arc (-90:90:1/16) 59 | (0,0) arc (180:0:1/8) (0,0) arc (180:0:1/16) (0,0)--(1/8,1/8); 60 | \node [below]at(0.069,0.0627){$A$}; 61 | \node [above]at(0.136,0.123){$B$}; 62 | \node [right]at(0.105,0.0541){$C$}; 63 | \end{tikzpicture} 64 | 65 | \begin{tikzpicture}[scale=15] 66 | \begin{scope} 67 | \clip (0,0) arc (-90:0:1/8) arc (90:180:1/8); 68 | \fill[pattern=horizontal lines] 69 | (0,0) arc (-90:0:1/8) --(1/16,1/16) arc (90:0:1/16); 70 | \fill[pattern=vertical lines] 71 | (0,0) arc (180:90:1/8) --(1/16,1/16) arc (0:90:1/16); 72 | \end{scope} 73 | \draw [-stealth,thick](-0.05,0)--(0.3,0); 74 | \draw [-stealth,thick](0,-0.05)--(0,0.3); 75 | \node[right]at(0.3,0){$x$}; 76 | \node[left]at(0,0.3){$y$}; 77 | \draw (0,0) arc (-90:90:1/8) (0,0) arc (-90:90:1/16) 78 | (0,0) arc (180:0:1/8) (0,0) arc (180:0:1/16) (0,0)--(1/8,1/8); 79 | \node [below]at(0.069,0.0627){$A$}; 80 | \node [above]at(0.136,0.123){$B$}; 81 | \node [right]at(0.105,0.0541){$C$}; 82 | \end{tikzpicture} 83 | \begin{tikzpicture}[scale=1.5] 84 | \begin{scope} 85 | \draw[-stealth] (-0.25,0) -- (3.35,0) node (xaxis) [below] {$x$}; 86 | \draw[-stealth] (0,-0.25) -- (0,1.35) node (yaxis) [left] {$y$}; 87 | \draw (3,0.025)--(3,-0.025) node[below=-0.5mm] {3}; 88 | \draw (0.025,1) -- (-0.025,1) node[left=-0.75mm] {1}; 89 | \end{scope} 90 | \draw (-0.15,-0.15) node {$o$}; 91 | \draw[fill=gray!30] (2,0) arc [start angle=0, end angle=180, radius=1] -- (3,0) -- (2,1) -- (1,1); %,pattern=dots,even odd rule 92 | \draw[domain=2:3,fill=green!20] plot (\x,3-\x); 93 | \draw[samples=300,domain=0:2.0] plot (\x,{(1-(1-\x)^2)^(1/2)}); 94 | \draw[dashed] (0,1) -- (1,1); 95 | \draw[dashed] (2,0) -- (2,1); 96 | \draw[dashed] (1,0) -- (1,1); 97 | \end{tikzpicture} 98 | 99 | \begin{tikzpicture} 100 | \node[above,xscale=1.2,yscale=1.4]{\Huge\bfseries 欢迎同学们进行错误指正!}; 101 | \node[xscale=1.2,above,yscale=-1.4,scope fading=south,opacity=0.2]{\Huge\bfseries 欢迎同学们进行错误指正!}; 102 | \end{tikzpicture} 103 | 104 | \begin{tikzpicture} 105 | \draw[help lines,black] (0,0) grid (9,9); %网格线 106 | \draw [->] (0,0)--(9.5,0) node[below right] { $X$}; 107 | \draw [->] (0,0)--(0,9.5) node[above left] {$Y$}; 108 | \node[below left] at (0,0) {0}; 109 | \foreach \i in {1,...,9} 110 | \draw (\i,-0.05)--++(90:0.1) node[below=1mm]{\i}; 111 | %\draw (\i,-0.05)--(\i,0.05) node[below=1mm]{\i}; 112 | \foreach \i in {1,...,9} 113 | \draw (0.05,\i)--++(180:0.1) node[left=-0.5mm]{\i}; 114 | %\draw (-0.05,\i)--(0.05,\i) node[left=1mm]{\i}; 115 | \end{tikzpicture} 116 | 117 | \begin{tikzpicture}[y={(0:1cm)},x={(225:0.86cm)}, z={(90:1cm)}] 118 | 119 | % coordinates for the lower grid 120 | \path 121 | (1,3,0) coordinate (bm0) -- 122 | (4,3,0) coordinate (fm0) coordinate[midway] (lm0) -- 123 | (4,8,0) coordinate[pos=0.25] (fm1) coordinate[midway] (fm2) coordinate[pos=0.75] (fm3) coordinate (fm4) -- 124 | (1,8,0) coordinate (bm4) coordinate[midway] (lm4)-- 125 | (bm0) coordinate[pos=0.25] (bm3) coordinate[midway] (bm2) coordinate[pos=0.75] (bm1); 126 | \draw[dashed] 127 | (lm0) -- 128 | (lm4) coordinate[pos=0.25] (lm1) coordinate[midway] (lm2) coordinate[pos=0.75] (lm3); 129 | 130 | % the blocks 131 | \DrawBlock{b}{1}{4} 132 | \DrawBlock{b}{2}{3.7} 133 | \DrawBlock{b}{3}{4.3} 134 | \DrawBlock{b}{4}{5} 135 | \DrawBlock{f}{1}{3.3} 136 | \DrawBlock{f}{2}{3.5} 137 | \DrawBlock{f}{3}{4} 138 | \DrawBlock{f}{4}{4.7} 139 | 140 | \foreach \Point/\Height in {lm1/3.7,lm2/4.3,lm3/5} 141 | \draw[ultra thin,dashed,opacity=0.2] (\Point) -- ++(0,0,\Height); 142 | 143 | % the lower grid 144 | \foreach \x in {1,2,3} 145 | \draw[dashed] (fm\x) -- (bm\x); 146 | \draw[dashed] (fm0) -- (bm0) -- (bm4); 147 | \draw (fm0) -- (fm4) -- (bm4); 148 | \draw[dashed] (lm0) -- (lm4); 149 | 150 | % coordinates for the surface 151 | \coordinate (curvefm0) at ( $ (fm0) + (0,0,4) $ ); 152 | \coordinate (curvebm0) at ( $ (bm0) + (0,0,4) $ ); 153 | \coordinate (curvebm4) at ( $ (bm4) + (0,0,6) $ ); 154 | \coordinate (curvefm4) at ( $ (fm4) + (0,0,5.7) $ ); 155 | 156 | % the surface 157 | \filldraw[ultra thick,fill=gray!25,fill opacity=0.2] 158 | (curvefm0) to[out=-30,in=210] 159 | (curvefm4) to[out=-4,in=260] 160 | (curvebm4) to[out=215,in=330] 161 | (curvebm0) to[out=240,in=-20] 162 | (curvefm0); 163 | 164 | % lines from grid to surface 165 | \draw[very thick,name path=leftline] (curvefm0) -- (fm0); 166 | \draw[very thick] (curvefm4) -- (fm4); 167 | \draw[very thick,name path=rightline] (curvebm4) -- (bm4); 168 | \draw[very thick,dashed] (curvebm0) -- (bm0); 169 | 170 | % coordinate system 171 | \coordinate (O) at (0,0,0); 172 | \draw[-latex] (O) -- +(5,0,0) node[above left] {$x$}; 173 | \path[name path=yaxis] (O) -- +(0,10,0) coordinate (yaxisfinal) node[above] {$y$}; 174 | \draw[-latex] (O) -- +(0,0,5) node[left] {$z$}; 175 | \path[name intersections={of=yaxis and leftline,by={yaxis1}}]; 176 | \path[name intersections={of=yaxis and rightline,by={yaxis2}}]; 177 | \draw (O) -- (yaxis1); 178 | \draw[densely dashed,opacity=0.1] (yaxis1) -- (yaxis2); 179 | \draw[-latex] (yaxis2) -- (yaxisfinal); 180 | 181 | % the stippling 182 | \path[postaction={stipple={amplitude=1cm,stipple density=0.15}}] 183 | ( $ (fm4) + (0,0,4.7) $ ) -- (fm4); 184 | \path[postaction={stipple={amplitude=1cm,stipple density=0.05}}] 185 | ( $ (lm4) + (0,0,4.7) $ ) -- (lm4); 186 | \end{tikzpicture} 187 | 188 | \tikz[baseline]\node[strike out,draw,anchor=text]{me}; 189 | \tikz[baseline] \node [cross out,draw,anchor=text] {me}; 190 | \tikz\node [cross out,draw=red] at (1.5,1) {cross out}; 191 | $f(x)=\dfrac{\left(x^2+1\right)\cancel{(x-1)}}{\cancel{(x-1)}(x+1)}$\\[0.5cm] 192 | $\bcancel{3}\qquad\bcancel{1234567}$\qquad 193 | $\xcancel{3}\qquad\xcancel{1234567}$\qquad 194 | $\hcancel{3}\qquad\hcancel[red]{1234567}$ 195 | 196 | \begin{tikzpicture}[->,>=stealth,auto,node distance=7em, thick,main node/.style={circle,fill=blue!2,draw,font=\sffamily\small}] font=\sffamily\small\bfseries \node[main node] (1) {1}; 197 | \node[main node] (2) [right of=1] {2}; 198 | \node[main node] (3) [below right of=2] {3}; 199 | \node[main node] (4) [below left of=3] {4}; 200 | \node[main node] (5) [left of=4] {5}; 201 | \node[main node] (6) [below left of=1] {6}; 202 | \draw (1.20) -- (2.160) node[midway, above] {5}; 203 | \draw (2.200) -- (1.-20) node[midway, below] {3}; 204 | \draw (2.-45) -- (3.135) node[midway, above] {4}; 205 | \draw (5.0) -- (4.180) node[midway, below] {2}; 206 | \draw (1.-155) -- (6.65) node[midway, above] {-2}; 207 | \draw (6.25) -- (1.-115) node[midway, below] {3}; 208 | \draw (6.20) -- (3.160) node[midway, above] {4}; 209 | \draw (3.200) -- (6.-20) node[midway, below] {4}; 210 | \draw (1.-90) -- (5.90) node[midway,above] {3~~~~~}; 211 | \draw (2.-90) -- (4.90) node[midway, above] {3~~~~~}; 212 | %\draw (4.120) -- (1.-55) node[pos=.2,above] {4x} 213 | \draw (4.120) -- (1.-60) node[midway, above] {4}; 214 | \draw (6.-55) -- (4.150) node[midway, above] {-1}; 215 | \end{tikzpicture} 216 | 217 | \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm, 218 | thick,main node/.style={circle,fill=blue!20,draw,font=\sffamily\Large\bfseries}] 219 | \node[main node] (1) {1}; 220 | \node[main node] (8) [ left of=1] {8}; 221 | \node[main node] (11) [ below of=1] {11}; 222 | \node[main node] (12) [ left of=8] {12}; 223 | \node[main node] (13) [ below of=12] {13}; 224 | 225 | \node[main node] (7) [ left of=13] {7}; 226 | \node[main node] (14) [ below left of=11] {14}; 227 | \node[main node] (10) [ below left of=14] {10}; 228 | \node[main node] (5) [below of=10]{5}; 229 | \node[main node] (9) [ right of=11] {9}; 230 | \node[main node] (2) [below right of=14] {2}; 231 | \node[main node] (3) [ right of=2] {3}; 232 | \node[main node] (4) [below left of=2] {4}; 233 | 234 | \node[main node] (15) [ below right of=2] {15}; 235 | \node[main node] (16) [right of=3] {16}; 236 | \node[main node] (6) [ below of=16] {6}; 237 | 238 | 239 | \path[every node/.style={font=\sffamily\small}] 240 | (1) edge node [left] {} (11) 241 | (2) edge node [right] {} (11) 242 | (3) edge node [right] {} (6) 243 | edge node [right] {} (11) 244 | edge node [right] {} (16) 245 | (4) edge node [left] {} (2) 246 | edge node [left] {} (10) 247 | edge node [left] {} (11) 248 | edge [bend right] node{} (13) 249 | edge node [bend right]{} (15) 250 | (6) edge[bend left] node [left] {} (5) 251 | edge node [left] {} (15) 252 | (8) edge node [left] {} (11) 253 | edge node [left] {} (2) 254 | (9) edge node [left] {} (11) 255 | (10)edge node[left]{} (2) 256 | edge[bend left] node [left] {} (11) 257 | (13) edge node [left] {} (11) 258 | edge node [left] {} (12) 259 | (14) edge node [left] {} (2) 260 | edge node [left] {} (4) 261 | edge node [left] {} (8) 262 | edge node [left] {} (10) 263 | edge node [left] {} (11) 264 | edge node [left] {} (13); 265 | \end{tikzpicture} 266 | 267 | \begin{tikzpicture}[>=latex,text height=1.5ex,text depth=0.25ex] 268 | \matrix[row sep=0.5cm,column sep=0.5cm] { 269 | % First line: Control input 270 | & 271 | \node (y_0) [measurement] {$\mathbf{y}_{0}$}; & 272 | \node (y_1) [measurement] {$\mathbf{y}_{1}$}; & 273 | \node (y_2) [measurement] {$\mathbf{y}_{2}$}; & 274 | \node (y_3) [measurement] {$\mathbf{y}_{3}$}; & 275 | \\ 276 | % Second line: System noise & input matrix 277 | \node ({S_{3}}') [input] {$\mathbf{S_{3}}'$}; & 278 | \node ({A_{0}}') [matrx] {$\mathbf{A_{0}}'$}; & 279 | \node ({A_{1}}') [matrx] {$\mathbf{A_{1}}'$}; & 280 | \node ({A_{2}}') [matrx] {$\mathbf{A_{2}}'$}; & 281 | \node ({A_{3}}') [matrx] {$\mathbf{A_{3}}'$}; & 282 | \node ({S_{0}}') [input] {$\mathbf{S_{0}}'$}; & 283 | \\ 284 | \node ({S_{0}}) [input] {$\mathbf{S_{0}}$}; & 285 | \node ({A_{0}}) [matrx] {$\mathbf{A_{0}}$}; & 286 | \node ({A_{1}}) [matrx] {$\mathbf{A_{1}}$}; & 287 | \node ({A_{2}}) [matrx] {$\mathbf{A_{2}}$}; & 288 | \node ({A_{3}}) [matrx] {$\mathbf{A_{3}}$}; & 289 | \node ({S_{3}}) [input] {$\mathbf{S_{3}}$}; & 290 | \\ 291 | % Fifth line: 输入 292 | & 293 | \node (x_0) [state]{$\mathbf{x}_{0}$}; & 294 | 295 | \node (x_1) [state2]{$\mathbf{x}_{1}$}; & 296 | 297 | \node (x_2) [state3]{$\mathbf{x}_{2}$}; & 298 | 299 | \node (x_3) [state4]{$\mathbf{x}_{3}$}; & 300 | 301 | \\ 302 | }; 303 | 304 | % The diagram elements are now connected through arrows: 305 | \path[->] 306 | ({S_{0}}') edge[thick] ({A_{3}}') 307 | ({A_{3}}') edge[thick] ({A_{2}}') 308 | ({A_{2}}') edge[thick] ({A_{1}}') 309 | ({A_{1}}') edge[thick] ({A_{0}}') 310 | ({A_{0}}') edge[thick] ({S_{3}}') 311 | 312 | ({S_{0}}) edge[thick] ({A_{0}}) 313 | ({A_{0}}) edge[thick] ({A_{1}}) 314 | ({A_{1}}) edge[thick] ({A_{2}}) 315 | ({A_{2}}) edge[thick] ({A_{3}}) 316 | ({A_{3}}) edge[thick] ({S_{3}}) 317 | 318 | (x_0) edge ({A_{0}}) 319 | (x_1) edge ({A_{1}}) 320 | (x_2) edge ({A_{2}}) 321 | (x_3) edge ({A_{3}}) 322 | ({A_{0}}') edge (y_0) 323 | ({A_{1}}') edge (y_1) 324 | ({A_{2}}') edge (y_2) 325 | ({A_{3}}') edge (y_3) 326 | 327 | (x_0) edge[->,bend right=37,green] ({A_{0}}') 328 | (x_1) edge[->,bend right=37,green] ({A_{1}}') 329 | (x_2) edge[->,bend right=37,green] ({A_{2}}') 330 | (x_3) edge[->,bend right=37,green] ({A_{3}}') 331 | ({A_{3}}) edge[->,bend right=37,green] (y_3) 332 | ({A_{2}}) edge[->,bend right=37,green] (y_2) 333 | ({A_{1}}) edge[->,bend right=37,green] (y_1) 334 | ({A_{0}}) edge[->,bend right=37,green] (y_0) 335 | ; 336 | \end{tikzpicture} 337 | 338 | \begin{tikzpicture}[label distance = 2mm] 339 | 340 | \draw[->] (-1,0) -- (5,0) node[below,circle,draw,label distance = 1cm,label=right:This is $x$] {$x$}; 341 | \draw[->] (0,-1) -- (0,4) node[left,rectangle,draw] {$y$}; 342 | \draw[color = green,line width = 3mm] (0,0) -- plot coordinates {(1,0) (1,1) (0,1)} -- cycle; 343 | \draw[color = black,thick,rotate = 45] (3,3) circle (1cm and 2cm); 344 | \draw[step=0.25cm,color = blue] (1,1) grid (3,3); 345 | \tikzstyle{my style}=[yellow,dashed,thick]; 346 | \draw[style = my style] (2,0) parabola (3,3); 347 | \draw[style = my style] (1,0) arc (0:90:1cm); 348 | 349 | \begin{scope}[dashed] 350 | \draw (2,2) circle (2cm); 351 | \draw (2,2) circle (1.5cm); 352 | \draw (2,2) circle (1cm); 353 | \draw (2,2) circle (0.5cm); 354 | \end{scope} 355 | \draw (5,4) node [circle,fill=gray!20,label = right:3,label=above:12,label=below:6,label = left:9]{clock}; 356 | \draw [thick,dashed,domain=0:2] plot[id = x] function {x*x}; 357 | \draw [thick,domain=0:1.5] plot [id = x] function {2*x*x}; 358 | \end{tikzpicture} 359 | \begin{tikzpicture} 360 | \draw[line width=0.2cm,red] (1,1) .. controls (3,3) 361 | and (0,3) .. (2,1); 362 | %\draw (1,0.5) node[draw,shape=circle,anchor=south west]{A} -- (0,0) node[draw,shape=circle,anchor=north east]{B}; 363 | \path (1,0.5) node[draw,shape=circle](v0){A}; 364 | \path (0,0) node[draw,shape=circle](v1){B}; 365 | \draw (v0) -- (v1); 366 | 367 | \foreach \i in {1,...,4} 368 | { 369 | \filldraw[black] (\i,0) circle (1pt); 370 | \foreach \j in {1,...,3} 371 | { 372 | \filldraw[black] (\j,-1) circle (1pt); 373 | \draw (\i,0) -- (\j,-1); 374 | } 375 | } 376 | 377 | % \foreach \i/\j in {60/red,120/green,180/blue} 378 | % { 379 | % \draw[\j] (1,1) arc (\i:240:1cm); 380 | % } 381 | \draw[red] (3,1) arc (60:240:1cm); 382 | \draw[green] (3,1) arc (120:240:1cm); 383 | \draw[blue] (3,1) arc (180:240:1cm); 384 | 385 | \end{tikzpicture} 386 | 387 | \begin{tikzpicture}[> = stealth, % arrow head style 388 | shorten > = 1pt, % don't touch arrow head to node 389 | auto, 390 | node distance = 3cm, % distance between nodes 391 | semithick % line style 392 | ,scale=.8,auto=left,every node/.style={circle,fill=blue!20}] 393 | \node (n1) at (0,0) {1}; 394 | \node (n2) at (0,-2) {2}; 395 | \node (n3) at (0,-4) {3}; 396 | \node (n4) at (0,-6) {4}; 397 | \node (n5) at (0,-8) {5}; 398 | \draw (n1)--(n2); 399 | \draw (n2)--(n3); 400 | \draw (n3)--(n4); 401 | \draw [red,very thick](n4)--(n5); 402 | \draw [red,very thick] (n1) .. controls (-2,-2.5) ..(n4); 403 | \draw [red,very thick](n1) .. controls (2,-3.5) ..(n5); 404 | \end{tikzpicture} 405 | 406 | 过程介绍: 407 | \begin{enumerate} 408 | \item 包含tikz宏包,并且载入要使用的库。在本例中就是 409 | \lstinline{tikz}与 410 | \lstinline{positioning,arrows.meta}两条命令; 411 | \item 先定义好需要的样式(style)。本例中先定义了要用到的方框与箭头的样式。当然,这是因为有现成的图形参照,如果没有也可后面再定义。先定义好需要的样式(style)。一般我会把style单独放在一个文件中由主文件来调用; 412 | \item 绘制方框后连线。 413 | \end{enumerate} 414 | 说明: 415 | \begin{enumerate} 416 | \item 绘制方框的语句格式一般是 417 | \begin{lstlisting} 418 | \node[样式](名称){标题}; 419 | \end{lstlisting} 420 | 注意结尾的分号,绘制线条的语句最后先要加分号。名称是调用时使用,可以用汉字,标题是显示出来的文字,二者不一样; 421 | \item 样式的内容挺多的,方框中一般会用到形状(shape)、边框颜色(draw)、填充色(fill)、宽度(text width)、最小高度(minimum height)。颜色方面可以参考xcolor宏包的说明文档。长度单位有好几个,我一般常用的是pt与cm,1pt=0.351mm; 422 | \item 位置的表示也包含在样式定义中,一般形式是:方位 = 尺寸 of 参考对象。方位包括left、right、below、above、below left、below right、above left、above right 8种,要注意below left这样的顺序不能颠倒; 423 | \item 这里我们绘制箭头的库选用的是arrows.meta(24种箭头),这个库比arrows(14种)要丰富些。箭头的形状有很多种,详情请参考\href{https://stuff.mit.edu/afs/athena/contrib/tex-contrib/beamer/pgf-1.01/doc/generic/pgf/version-for-tex4ht/en/pgfmanualse24.html}{arrows.meta的24种箭头},本例中箭头样式选的是Latex样式,其后的length = 4mm, width = 1.5mm代表箭头的长宽,可以通过这两个参数调整箭头的锋锐程度。大家可以根据需要设置; 424 | \item 在线条上加文字的方法是通过加入node来实现,注意node在连线(即–)中的位置,如果放在–左边就表示文字是在线段的左边,反之在右边。实际上我们可以通过xshift、yshift两个参数来随意调整位置; 425 | \item 语句 426 | \begin{lstlisting} 427 | \draw[arrow1](0, 50pt)node[right, yshift = -15pt]{输入源程序} -- (词法); 428 | \end{lstlisting} 429 | 其中的(0, 50pt)是指在绝对坐标0, 50pt处开始绘制,图形坐标的原点(0, 0)就是代码中第一个方框的中心处。如果我们在(0, 50pt)前加两个加号,例如++(0, 50pt),那就变成了相对坐标,是相对于上一个节点。例如语句: 430 | \begin{lstlisting} 431 | \draw[arrow1](生成) -- node[right, yshift = 5pt, xshift = 5pt]{目标代码}++(0, -50pt); 432 | \end{lstlisting} 433 | ++(0, -50pt)的意思就是相对于“生成”这个节点向下移动50pt的坐标。当我们不清楚绝对坐标时就用相对坐标来绘制,挺方便的。 434 | \end{enumerate} 435 | % 定义方框样式 436 | \tikzset{ 437 | rect1/.style = { 438 | shape = rectangle, 439 | draw = green, 440 | text width = 3cm, 441 | align = center, 442 | minimum height = 1cm, 443 | } 444 | } 445 | % 定义箭头样式 446 | \tikzset{ 447 | arrow1/.style = { 448 | draw = purple, thick, -{Latex[length = 4mm, width = 1.5mm]}, 449 | } 450 | } 451 | % 双箭头 452 | \tikzset{ 453 | arrow2/.style = { 454 | draw = purple, thick, {Latex[length = 4mm, width = 1.5mm]}-{Latex[length = 4mm, width = 1.5mm]}, 455 | } 456 | } 457 | \begin{center} 458 | \begin{tikzpicture} 459 | % 绘制中间方框 460 | \node[rect1, fill = green!60!white](词法){词法分析}; 461 | \node[rect1, fill = green!40!white, below = of 词法](语法){语法分析}; 462 | \node[rect1, fill = green!20!white, below = of 语法, text width = 5cm](语义中间){语义分析、中间表示生成}; 463 | \node[rect1, fill = green!60!black, below = of 语义中间](优化){\color{white}代码优化}; 464 | \node[rect1, fill = green!30!black, below = of 优化](生成){\color{white}代码生成}; 465 | % 绘制两侧方框 466 | \node[rectangle, fill = red!20!white, draw = red, text width = 0.7cm, minimum height = 4cm, align = center, left = 2cm of 语义中间](符号){符号表管理}; 467 | \node[rectangle, fill = blue!20!white, draw = blue, text width = 0.7cm, minimum height = 4cm, align = center, right = 2cm of 语义中间](出错处理){出错处理}; 468 | % 绘制中间连线 469 | \draw[arrow1](0, 50pt)node[right, yshift = -15pt]{输入源程序} -- (词法); 470 | \draw[arrow1](词法) -- node[right]{单词流}(语法); 471 | \draw[arrow1](语法) -- node[right]{文法}(语义中间); 472 | \draw[arrow1](语义中间) -- node[right]{中间表示}(优化); 473 | \draw[arrow1](优化) -- node[right]{优化后中间表示}(生成); 474 | \draw[arrow1](生成) -- node[right, yshift = 5pt, xshift = 5pt]{目标代码}++(0, -50pt); 475 | % 绘制两侧连线 476 | \draw[arrow2](符号) -- (词法.west); 477 | \draw[arrow2](符号) -- (语法.west); 478 | \draw[arrow2](符号) -- (语义中间); 479 | \draw[arrow2](符号) -- (优化.west); 480 | \draw[arrow2](符号) -- (生成.west); 481 | \draw[arrow2](出错处理) -- (词法.east); 482 | \draw[arrow2](出错处理) -- (语法.east); 483 | \draw[arrow2](出错处理) -- (语义中间); 484 | \draw[arrow2](出错处理) -- (优化.east); 485 | \draw[arrow2](出错处理) -- (生成.east); 486 | % 绘制虚线框 487 | \draw[thick, dashed, draw = purple](-125pt, 27pt)node[below right]{编译器前端} -- (125pt, 27pt) -- (125pt, -250pt) -- (-125pt, -250pt)node[above right]{编译器后端} -- (-125pt, 27pt); 488 | \draw[thick, dashed, draw = purple](-125pt, -135pt) -- (125pt, -135pt); 489 | \end{tikzpicture} 490 | \\ 编译器结构图 491 | \end{center} 492 | 493 | \begin{tikzpicture}[domain=-4:3.5,line width=2pt] 494 | \clip (-5,-5) rectangle (6,6);%只在这个区域内画图 495 | %绘制网格 496 | \draw[ thin,color=gray] (-4,-2) grid (4,4); 497 | %绘制y=sin(x) 498 | \draw[color=blue,name path=c1] plot (\x,{sin(\x r)}) 499 | node[right] {$f(x) = \sin x$}; 500 | %绘制y= 0.1 * e^ x 501 | \draw[color=black,name path=c2] plot (\x,{0.1*exp(\x)}) 502 | node[right] {$f(x) = 0.1 *\mathrm{e}^ x$}; 503 | %求交点, i-\s是每个交点的名称.i是前缀 \t表示总的交点数 504 | \fill [name intersections ={of ={ c1 and c2},name=i,total=\t}] 505 | \foreach \s in {1,...,\t}{(i-\s) circle(3pt) node[above]{\s}}; 506 | \end{tikzpicture} 507 | 508 | 下面两个函数表达式: 509 | \[ 510 | \sgn\left(x\right)=\left\{\begin{array}{l} 511 | 1,x\geq 0\\ 512 | 0,x<0\\ 513 | \end{array}\right. 514 | \] 515 | \[ 516 | \textrm{sigmoid}\left(x\right)=\frac{1}{1+\textrm{e}^{-x}} 517 | \] 518 | \begin{center} 519 | \begin{tikzpicture} 520 | \draw[->](-1.2,0)--(1.2,0)node[left,below,font=\tiny]{$x$}; 521 | \draw[->](0,-0.2)--(0,1.2)node[right,font=\tiny]{$y$}; 522 | \foreach \x in {-1,0,1}{\draw(\x,0)--(\x,0.05)node[below,outer sep=2pt,font=\tiny]at(\x,0){\x};} 523 | \foreach \y in {1}{\draw(0,\y)--(0.05,\y)node[left,outer sep=2pt,font=\tiny]at(0,\y){\y};} 524 | \draw[color=red, thick,smooth,domain=0:1]plot(\x,1); 525 | \draw[color=red, thick,smooth,domain=-1:-0.02]plot(\x,0); 526 | \draw[color=red,smooth]circle(0.02); 527 | \end{tikzpicture} 528 | \begin{tikzpicture} 529 | \draw[->](-1.2,0)--(1.2,0)node[left,below,font=\tiny]{$x$}; 530 | \draw[->](0,-0.2)--(0,1.2)node[right,font=\tiny]{$y$}; 531 | \draw[dashed](-1.2,1)--(1.2,1); 532 | \foreach \x in {-1,-0.5,0,0.5,1}{\draw(\x,0)--(\x,0.05)node[below,outer sep=2pt,font=\tiny]at(\x,0){\x};} 533 | \foreach \y in {0.5,1}{\draw(0,\y)--(0.05,\y)node[left,outer sep=2pt,font=\tiny]at(0,\y){\y};} 534 | \draw[color=red ,domain=-1.2:1.2]plot(\x,{1/(1+(e^(-1*(\x))))}); 535 | \end{tikzpicture} 536 | \end{center} -------------------------------------------------------------------------------- /class/ch08.tex: -------------------------------------------------------------------------------- 1 | \chapter{思维导图} 2 | 使用以下代码可绘制出思维导图,如图\ref{fig:mindmap}所示: 3 | \begin{lstlisting} 4 | \documentclass[tikz]{standalone} 5 | \usepackage{xcolor} 6 | \usetikzlibrary{mindmap} %for mindmap 7 | \definecolor{DeepSkyBlue4}{RGB}{0,104,139} 8 | \begin{document} 9 | \tikzstyle{level 2 concept}+=[sibling angle=40] 10 | \begin{tikzpicture}[scale=0.49, transform shape] 11 | \path[mindmap,concept color=black,text=white] 12 | node[concept] {Pure Mathematics} [clockwise from=45] 13 | child[concept color=DeepSkyBlue4]{ 14 | node[concept] {Analysis} [clockwise from=180] 15 | child { 16 | node[concept] {Multivariate \& Vector Calculus} 17 | [clockwise from=120] 18 | child {node[concept] {ODEs}}} 19 | child { node[concept] {Functional Analysis}} 20 | child { node[concept] {Measure Theory}} 21 | child { node[concept] {Calculus of Variations}} 22 | child { node[concept] {Harmonic Analysis}} 23 | child { node[concept] {Complex Analysis}} 24 | child { node[concept] {Stochastic Analysis}} 25 | child { node[concept] {Geometric Analysis} 26 | [clockwise from=-40] 27 | child {node[concept] {PDEs}}}} 28 | child[concept color=black!50!green, grow=-40]{ 29 | node[concept] {Combinatorics} [clockwise from=10] 30 | child {node[concept] {Enumerative}} 31 | child {node[concept] {Extremal}} 32 | child {node[concept] {Graph Theory}}} 33 | child[concept color=black!25!red, grow=-90]{ 34 | node[concept] {Geometry} [clockwise from=-30] 35 | child {node[concept] {Convex Geometry}} 36 | child {node[concept] {Differential Geometry}} 37 | child {node[concept] {Manifolds}} 38 | child {node[concept,color=black!50!green!50!red,text=white] {Discrete Geometry}} 39 | child { 40 | node[concept] {Topology} [clockwise from=-150] 41 | child {node [concept,color=black!25!red!50!brown,text=white] 42 | {Algebraic Topology}}}} 43 | child[concept color=brown,grow=140]{ 44 | node[concept] {Algebra} [counterclockwise from=70] 45 | child {node[concept] {Elementary}} 46 | child {node[concept] {Number Theory}} 47 | child {node[concept] {Abstract} [clockwise from=180] 48 | child {node[concept,color=red!25!brown,text=white] {Algebraic Geometry}}} 49 | child {node[concept] {Linear}}} 50 | node[extra concept,concept color=black] at (200:5) {Applied Mathematics} 51 | child[grow=145,concept color=black!50!yellow] { 52 | node[concept] {Probability} [clockwise from=180] 53 | child {node[concept] {Stochastic Processes}}} 54 | child[grow=175,concept color=black!50!yellow] {node[concept] {Statistics}} 55 | child[grow=205,concept color=black!50!yellow] {node[concept] {Numerical Analysis}} 56 | child[grow=235,concept color=black!50!yellow] {node[concept] {Symbolic Computation}}; 57 | \end{tikzpicture} 58 | \end{document} 59 | \end{lstlisting} 60 | 61 | \begin{figure}[htpb] 62 | \centering 63 | \includegraphics[width=0.4\linewidth]{mindmap.png} 64 | \caption{使用Tikz制作思维导图示例。}\label{fig:mindmap} 65 | \end{figure} 66 | 67 | \begin{tikzpicture} 68 | \path [ 69 | mindmap, 70 | text = white, 71 | level 1 concept/.append style = 72 | {font=\Large\bfseries, sibling angle=90}, 73 | level 2 concept/.append style = 74 | {font=\normalsize\bfseries}, 75 | level 3 concept/.append style = 76 | {font=\small\bfseries}, 77 | tex/.style = {concept, ball color=blue, 78 | font=\Huge\bfseries}, 79 | engines/.style = {concept, ball color=green!50!black}, 80 | formats/.style = {concept, ball color=blue!50!black}, 81 | systems/.style = {concept, ball color=red!90!black}, 82 | editors/.style = {concept, ball color=orange!90!black} 83 | ] 84 | node [tex] {\TeX} [clockwise from=0] 85 | child[concept color=green!50!black, nodes={engines}] { 86 | node {Engines} [clockwise from=90] 87 | child { node {\TeX} } 88 | child { node {pdf\TeX} } 89 | child { node {\XeTeX} } 90 | child { node {Lua\TeX} }} 91 | child [concept color=blue, nodes={formats}] { 92 | node {Formats} [clockwise from=300] 93 | child { node {\LaTeX} } 94 | child { node {Con\TeX t} }} 95 | child [concept color=red, nodes={systems}] { 96 | node {Systems} [clockwise from=210] 97 | child { node {\TeX Live} [clockwise from=300] 98 | child { node {Mac \TeX} }} 99 | child { node {MiK\TeX} [clockwise from=60] 100 | child { node {Pro \TeX t} }}} 101 | child [concept color=orange, nodes={editors}] { 102 | node {Editors} }; 103 | \end{tikzpicture} 104 | 105 | \begin{tikzpicture}[mindmap,scale=0.9] 106 | \begin{scope}[ 107 | every node/.style={concept,circular drop shadow,execute at begin node=\hskip0pt}, 108 | root concept/.append style={ 109 | concept color=black,fill=white,line width=1ex,text=black,font=\large\scshape}, 110 | text=white,yi/.style={concept color=red,faded/.style={concept color=red!50}}, 111 | er/.style={concept color=blue,faded/.style={concept color=blue!50}}, 112 | san/.style={concept color=orange,faded/.style={concept color=orange!50}}, 113 | si/.style={concept color=green!50!black,faded/.style={concept color=green!50!black!50}}, 114 | wu/.style={concept color=db,faded/.style={concept color=db!50}}, 115 | grow cyclic, 116 | level 1/.append style={level distance=5.5cm,sibling angle=90,font=\scshape}, 117 | level 2/.append style={level distance=3.2cm,sibling angle=38,font=\scriptsize} 118 | ] 119 | \node[root concept]at (current page.center){\Large 数专考纲\\mindmap} 120 | % [clockwise from=90] 121 | child[yi]{node{\large 数学分析}%[clockwise from=145] 122 | child{node{极限与连续}} 123 | child{node{一元函数微积分\\及其应用}} 124 | child{node{多元函数微分学}} 125 | child{node{级数理论\\与广义积分}} 126 | } 127 | child[er]{node{\large 英语一} 128 | child{node{无}} 129 | child{node{无}} 130 | child{node{无}} 131 | child{node{无}} 132 | } 133 | child[san]{node{\large 政治}%[clockwise from=0] 134 | child{node{无}} 135 | child{node{无}} 136 | child{node{无}} 137 | child{node{无}} 138 | } 139 | child[si]{node{\large 高等代数}%[clockwise from=-60] 140 | child{node{高等代数}} 141 | child{node{行列式理论}} 142 | child{node{线性方程组理论}} 143 | child{node{矩阵理论}} 144 | child{node{二次型理论}} 145 | child{node{线性空间理论}} 146 | child{node{线性变换理论}} 147 | child{node{欧式空间理论}} 148 | }; 149 | \end{scope} 150 | \end{tikzpicture} -------------------------------------------------------------------------------- /class/ch09.tex: -------------------------------------------------------------------------------- 1 | \chapter*{总结} 2 | 总体感觉, Tikz 画图操作比较精确, 重要的是它与\LaTeX 完美内嵌。 唯一一点不习惯的是它的代码看起来没有 Matlab 整齐。 3 | 4 | 有一个经疑问, 既然 TikZ 画图这么好看, 能否把它画的图另存为单独的文件呢?方法当然有, 就是使用 standalone 文档类。如下图就是用 standalone画好之后的 pdf 文件插入。 5 | 6 | \begin{tikzpicture}[>= stealth] 7 | \draw [->] (0,0,0) -- (2,0,0) node [at end, right] {$x$ 轴}; 8 | \draw [->] (0,0,0) -- (0,2,0) node [at end, left] {$y$ 轴}; 9 | \draw [->] (0,0,0) -- (0,0,2) node [at end, left] {$z$ 轴}; 10 | \filldraw [red, rotate around z=0] (0,0) -- (1,1) -- (1,0); 11 | \draw [green, rotate around z=45] (0,0) -- (1,1) -- (1,0); 12 | \draw [blue, rotate around z=90] (0,0) -- (1,1) -- (1,0); 13 | \end{tikzpicture} 14 | \begin{tikzpicture}[>=Stealth,scale=0.2,smooth] 15 | %\draw[help lines] (0,0) grid (3,2); 16 | \draw[->](-10,0)--(0,0) node[below left=-1.2pt]{$O$}--(20,0) node[below=1.5pt]{$x$}; 17 | \draw[->](0,-8)--(0,10)node[left]{$y$}; 18 | %\draw [circle] (0,0) circle (5) ; 19 | \coordinate (a) at (15,10); 20 | \node [circle,draw] (P) at (5,0) [minimum size=50pt,below] {$P$}; 21 | \draw[blue] (a) -- (tangent cs:node=P,point={(a)},solution=1) 22 | -- (P.center) -- (tangent cs:node=P,point={(a)},solution=2)-- cycle; 23 | \end{tikzpicture} 24 | \begin{center} 25 | \begin{tikzpicture}[ 26 | every node/.style ={inner sep=0pt}, 27 | pgfornamentstyle/.style={color=green!50!black,fill=green!80!black}] 28 | \node[text width=12cm,outer sep=1.2cm,text centered,color=red!90! black](Greeting) 29 | {\calligra \Huge 第一届八一赛\\ 网络大学生数学竞赛\\2019年8月1号上午9点 \\ 30 | \pgfornament[color=red!90!black,width=4cm]{72}}; 31 | \foreach \corner/\sym in {north west/none, north east/v, south west/h, south east/c}{ 32 | \node[anchor=\corner](\corner) 33 | at(Greeting.\corner) 34 | {\pgfornament[width=2cm,symmetry=\sym]{63}};} 35 | \path(north west)--(south west) 36 | node[midway, anchor=east] 37 | {\pgfornament[height=2cm]{9}} 38 | (north east)--(south east) 39 | node[midway,anchor=west] 40 | {\pgfornament[height=2cm, symmetry=v]{9}}; 41 | \pgfornamenthline{north west}{north east}{north}{87} 42 | \pgfornamenthline{south west}{south east}{south}{87} 43 | \end{tikzpicture} 44 | \end{center} -------------------------------------------------------------------------------- /class/ch10.tex: -------------------------------------------------------------------------------- 1 | \chapter{特殊纸张} 2 | \tikzstyle{topline}=[draw=blue] 3 | \tikzstyle{bottomline}=[draw=blue] 4 | \tikzstyle{midline}=[draw=red] 5 | \tikzstyle{dashedline}=[draw=red,dashed] 6 | \noindent\makebox[\textwidth][c]{\bf\scalebox{2.5}[3]{办公专用草纸}} 7 | %\vspace{0.1pt} 8 | \par\noindent 9 | \begin{tikzpicture}[scale=1] 10 | \foreach\i in{20.6,19.2,...,-0.4}{ 11 | \draw[midline](0,\i-1)--(\textwidth,\i-1); 12 | \draw[dashedline](0,\i-0.6)--(\textwidth,\i-0.6); 13 | \draw[midline](0,21)--(\textwidth,21);%次顶线 14 | \draw[midline](0,21.1)--(\textwidth,21.1);%顶线 15 | } 16 | \end{tikzpicture} 17 | \noindent\makebox[\textwidth][l]{\bf\scalebox{1}[1]{办公专用草纸}\hfill\today} 18 | 19 | %%稿纸效果 20 | %\begin{tikzpicture}[scale=1,domain=0:17] 21 | %\draw(8.5,24)node{\bf\scalebox{2}[2.5]{办公用纸} 22 | % \clip(0,-1)rectangle(17,24); 23 | % \foreach\m in(0,1,2,...,19)\draw[dash pattern=on 2.5pt off 2.5pt]plot(\x,1.2*\m); 24 | % \foreach\n in(-1,0,1,...,23)\draw[thick]plot(\x,1.2*\n+0.3); 25 | %\end{tikzpicture} 26 | %\rule{1.5cm}{Opt} 27 | %\begin{tikzpicture}[scale=1,domain=0:15] 28 | %\draw(7.5,20)node{\bf\scalebox{2}[2.5]{办公用纸}}; 29 | %\clip(0,-1)rectangle(15,20); 30 | %\foreach\m in{0,1,2,...,19} 31 | %\draw[dash pattern=on 2.5pt off 2.5pt]plot(\x,\m); 32 | %\foreach\n in{-1,0,1...,23} 33 | %\draw[]plot(\x,\n+0.3); 34 | %\end{tikzpicture} -------------------------------------------------------------------------------- /delete-temp-files.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | del /q *.aux *.bbl *.blg *.log *.out *.toc *.bcf *.xml *.synctex *.nlo *.nls *.bak *.ind *.idx *.ilg *.lof *.lot *.ent-x *.tmp *.ltx *.los *.lol *.loc *.listing *.gz *.userbak *.nav *.snm *.vrb *.synctex(busy) 3 | 4 | 5 | del /q *.nav *.snm *.vrb *.fls *.xdv *.fdb_latexmk -------------------------------------------------------------------------------- /elegantbook.cls: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%% 2 | %% start of file `elegantbook.cls'. 3 | %% Copyright 2013-2019 ElegantLaTeX (elegantlatex2e@gmail.com) 4 | %% 5 | %% This work may be distributed and/or modified freely 6 | %% available at https://github.com/ElegantLaTeX/ElegantBook 7 | % 8 | %%%%%%%%%%%%%%%%%%%%% 9 | % % !Mode:: "TeX:UTF-8" 10 | \NeedsTeXFormat{LaTeX2e} 11 | \ProvidesClass{elegantbook}[2019/08/18 v3.09 ElegantBook document class] 12 | 13 | \RequirePackage{kvoptions} 14 | \RequirePackage{etoolbox} 15 | \SetupKeyvalOptions{family=ELEGANT, prefix=ELEGANT@, setkeys=\kvsetkeys} 16 | \newcommand{\ekv}[1]{\kvsetkeys{ELEGANT}{#1}} 17 | 18 | % ----- Colors ----- 19 | \DeclareStringOption[blue]{color} 20 | \DeclareStringOption[en]{lang} 21 | \DeclareStringOption[answer]{result} 22 | \DeclareStringOption[fancy]{mode} 23 | \DeclareStringOption[show]{base} 24 | \DeclareStringOption[normal]{device} 25 | \DeclareStringOption[numbers]{cite} 26 | \DeclareStringOption[newtxmath]{math} 27 | \DeclareStringOption[marginfalse]{marginpar} 28 | \DeclareStringOption[onecol]{toc} 29 | % ----- backward compatibility 30 | \DeclareVoidOption{green}{\ekv{color=green}} 31 | \DeclareVoidOption{cyan}{\ekv{color=cyan}} 32 | \DeclareVoidOption{blue}{\ekv{color=blue}} 33 | \DeclareVoidOption{gray}{\ekv{color=gray}} 34 | \DeclareVoidOption{black}{\ekv{color=black}} 35 | \DeclareVoidOption{nocolor}{\ekv{color=none}} 36 | 37 | \DeclareVoidOption{en}{\ekv{lang=en}} 38 | \DeclareVoidOption{cn}{\ekv{lang=cn}} 39 | 40 | \DeclareVoidOption{fancy}{\ekv{mode=fancy}} 41 | \DeclareVoidOption{simple}{\ekv{mode=simple}} 42 | 43 | \DeclareVoidOption{answer}{\ekv{result=answer}} 44 | \DeclareVoidOption{noanswer}{\ekv{result=noanswer}} 45 | 46 | \DeclareVoidOption{hide}{\ekv{base=hide}} 47 | \DeclareVoidOption{show}{\ekv{base=show}} 48 | 49 | \DeclareVoidOption{normal}{\ekv{device=normal}} 50 | \DeclareVoidOption{pad}{\ekv{device=pad}} 51 | 52 | \DeclareVoidOption{numbers}{\ekv{cite=numbers}} 53 | \DeclareVoidOption{authoryear}{\ekv{cite=authoryear}} 54 | 55 | \DeclareVoidOption{newtxmath}{\ekv{math=newtx}} 56 | \DeclareVoidOption{mtpro2}{\ekv{math=mtpro2}} 57 | 58 | \DeclareVoidOption{margintrue}{\ekv{marginpar=margintrue}} 59 | \DeclareVoidOption{marginfalse}{\ekv{marginpar=marginfalse}} 60 | 61 | \DeclareVoidOption{onecol}{\ekv{toc=onecol}} 62 | \DeclareVoidOption{twocol}{\ekv{toc=twocol}} 63 | 64 | % ----- Math option ----- 65 | \newcommand\mailto[1]{\href{mailto:#1}{\nolinkurl{#1}}} 66 | 67 | % ----- Title Style ----- 68 | \DeclareStringOption[hang]{titlestyle}[hang] 69 | % ----- backward compatibility 70 | \DeclareVoidOption{hang}{\ekv{titlestyle=hang}} 71 | \DeclareVoidOption{display}{\ekv{titlestyle=display}} 72 | % ----- Default Options ----- 73 | \DeclareDefaultOption{\PassOptionsToClass{\CurrentOption}{book}} 74 | 75 | \ProcessKeyvalOptions*\relax 76 | % \ProcessOptions*\relax 77 | \LoadClass[a4paper,oneside]{book} 78 | 79 | 80 | \RequirePackage{indentfirst,comment} 81 | % fontsetting 82 | \ifdefstring{\ELEGANT@math}{mtpro2}{ 83 | \let\Bbbk\relax 84 | \RequirePackage[lite]{mtpro2} 85 | }{\relax} 86 | 87 | 88 | \PassOptionsToPackage{no-math}{fontspec} 89 | \RequirePackage{amsmath,mathrsfs,amsfonts,amssymb} 90 | \ifdefstring{\ELEGANT@lang}{cn}{ 91 | \RequirePackage[UTF8, scheme=plain]{ctex} 92 | } 93 | 94 | \RequirePackage{ifxetex} 95 | 96 | % \AtBeginDocument{% 97 | % \addtocontents{toc}{\protect\pagestyle{empty}}% 98 | % \addtocontents{lof}{\protect\thispagestyle{empty}}% 99 | % } 100 | 101 | 102 | \RequirePackage{newtxtext} 103 | \RequirePackage{anyfontsize} 104 | \ifdefstring{\ELEGANT@math}{newtxmath}{ 105 | \RequirePackage{newtxmath} 106 | \RequirePackage{esint} 107 | %%% use yhmath pkg, uncomment following code 108 | % \let\oldwidering\widering 109 | % \let\widering\undefined 110 | % \RequirePackage{yhmath} 111 | % \let\widering\oldwidering 112 | 113 | %%% use esvect pkg, uncomment following code 114 | % \RequirePackage{esvect} 115 | 116 | \DeclareSymbolFont{CMlargesymbols}{OMX}{cmex}{m}{n} 117 | \let\sumop\relax\let\prodop\relax 118 | \DeclareMathSymbol{\sumop}{\mathop}{CMlargesymbols}{"50} 119 | \DeclareMathSymbol{\prodop}{\mathop}{CMlargesymbols}{"51} 120 | }{\relax} 121 | 122 | % ----- Handle Colors ----- 123 | %% 章节以及页脚图形 124 | 125 | \RequirePackage{xcolor} 126 | \ifdefstring{\ELEGANT@color}{green}{ 127 | \definecolor{structurecolor}{RGB}{0,120,2}% 128 | \definecolor{main}{RGB}{0,120,2}% 129 | \definecolor{second}{RGB}{230,90,7}% 130 | \definecolor{third}{RGB}{0,160,152}% 131 | }{\relax} 132 | \ifdefstring{\ELEGANT@color}{cyan}{ 133 | \definecolor{structurecolor}{RGB}{31,186,190}% 134 | \definecolor{main}{RGB}{59,180,5}% 135 | \definecolor{second}{RGB}{175,153,8}% 136 | \definecolor{third}{RGB}{244,105,102}% 137 | }{\relax} 138 | \ifdefstring{\ELEGANT@color}{blue}{ 139 | \definecolor{structurecolor}{RGB}{60,113,183} 140 | \definecolor{main}{RGB}{0,166,82}% 141 | \definecolor{second}{RGB}{255,134,24}% 142 | \definecolor{third}{RGB}{0,174,247}% 143 | }{\relax} 144 | \ifdefstring{\ELEGANT@color}{gray}{ 145 | \definecolor{structurecolor}{RGB}{150,150,150} 146 | \definecolor{main}{RGB}{150,150,150}% 147 | \definecolor{second}{RGB}{150,150,150}% 148 | \definecolor{third}{RGB}{150,150,150}% 149 | }{\relax} 150 | \ifdefstring{\ELEGANT@color}{black}{ 151 | \definecolor{structurecolor}{RGB}{0,0,0} 152 | \definecolor{main}{RGB}{0,0,0}% 153 | \definecolor{second}{RGB}{0,0,0}% 154 | \definecolor{third}{RGB}{0,0,0}% 155 | }{\relax} 156 | 157 | %green color 158 | \definecolor{structure1}{RGB}{0,120,2}% 159 | \definecolor{main1}{RGB}{0,120,2}% 160 | \definecolor{second1}{RGB}{230,90,7}% 161 | \definecolor{third1}{RGB}{0,160,152}% 162 | %cyan color 163 | \definecolor{structure2}{RGB}{31,186,190}% 164 | \definecolor{main2}{RGB}{59,180,5}% 165 | \definecolor{second2}{RGB}{175,153,8}% 166 | \definecolor{third2}{RGB}{244,105,102}% 167 | %blue color 168 | \definecolor{structure3}{RGB}{60,113,183} 169 | \definecolor{main3}{RGB}{0,166,82}% 170 | \definecolor{second3}{RGB}{255,134,24}% 171 | \definecolor{third3}{RGB}{0,174,247}% 172 | % gray color 173 | \definecolor{structure4}{RGB}{150,150,150} 174 | \definecolor{main4}{RGB}{150,150,150}% 175 | \definecolor{second4}{RGB}{150,150,150}% 176 | \definecolor{third4}{RGB}{150,150,150}% 177 | % black color 178 | \definecolor{structure5}{RGB}{0,0,0} 179 | \definecolor{main5}{RGB}{0,0,0}% 180 | \definecolor{second5}{RGB}{0,0,0}% 181 | \definecolor{third5}{RGB}{0,0,0}% 182 | 183 | % corlor definition 184 | \definecolor{winered}{rgb}{0.5,0,0} 185 | \definecolor{bule}{RGB}{18,29,57} 186 | 187 | 188 | \newcommand{\base}[2]{% 189 | \nointerlineskip \vspace{0.1\baselineskip}\hspace{\fill} 190 | {\color{#1} 191 | \resizebox{0.3\linewidth}{1.5ex} 192 | {{% 193 | {\begin{tikzpicture} 194 | \node (C) at (0,0) {}; 195 | \node (D) at (4,0) {}; 196 | \path (C) to [ornament=#2] (D); 197 | \end{tikzpicture}}}}}% 198 | \hspace{\fill} 199 | \par\nointerlineskip \vspace{0.1\baselineskip} 200 | } 201 | 202 | % ----- Title Style ----- 203 | \ifdefstring{\ELEGANT@titlestyle}{hang}{\def\style{hang}}{\relax} 204 | \ifdefstring{\ELEGANT@titlestyle}{display}{\def\style{display}}{\relax} 205 | 206 | 207 | \newtoks\email 208 | \newtoks\version 209 | \newtoks\institute 210 | \newtoks\weixin 211 | \newtoks\subtitle 212 | 213 | \RequirePackage[sort&compress]{natbib} 214 | \setlength{\bibsep}{0.0pt} 215 | \def\bibfont{\footnotesize} 216 | 217 | 218 | 219 | \RequirePackage{enumerate} 220 | % list/itemize/enumerate setting 221 | \RequirePackage[shortlabels,inline]{enumitem} 222 | \setlist{nolistsep} 223 | 224 | % caption settings 225 | \RequirePackage{caption} 226 | \captionsetup{labelfont = bf} 227 | \RequirePackage[font=small,labelfont={bf,color=structurecolor}]{caption} 228 | \captionsetup[table]{skip=3pt} 229 | \captionsetup[figure]{skip=3pt} 230 | 231 | \AtBeginDocument{ 232 | \setlength{\abovedisplayskip}{3pt} 233 | \setlength{\belowdisplayskip}{3pt} 234 | \setcounter{tocdepth}{1} 235 | \RequirePackage[flushmargin,stable]{footmisc} 236 | \setlength{\footnotesep}{12pt} 237 | } 238 | 239 | \ifdefstring{\ELEGANT@toc}{twocol}{ 240 | \renewcommand{\tableofcontents}{% 241 | \setlength{\columnsep}{2em} 242 | %\setlength{\columnseprule}{.8pt} 243 | \begin{multicols}{2}[\chapter*{\contentsname}]% 244 | \@starttoc{toc}% 245 | \end{multicols}} 246 | }{\relax} 247 | 248 | 249 | %% 常用宏包 250 | \linespread{1.3} 251 | 252 | \RequirePackage{graphicx} 253 | %\RequirePackage{enumerate} 254 | 255 | \RequirePackage{booktabs} 256 | \RequirePackage{multicol,multirow} 257 | \RequirePackage{xcolor} 258 | \RequirePackage{fancyvrb} 259 | \RequirePackage{makecell,lipsum,hologo,setspace} 260 | 261 | %%中文结构名字 262 | \ifdefstring{\ELEGANT@lang}{cn}{ 263 | \setlength\parindent{2\ccwd} 264 | \renewcommand{\contentsname}{目\hspace{2em}录} 265 | \renewcommand{\figurename}{图} 266 | \renewcommand{\tablename}{表} 267 | \renewcommand{\partname}{\color{structurecolor}} 268 | \renewcommand{\thepart}{第\zhnumber{\arabic{part}}部分} 269 | \renewcommand{\listfigurename}{插图目录} 270 | \renewcommand{\listtablename}{表格目录} 271 | \renewcommand{\bibname}{参考文献} 272 | \renewcommand{\appendixname}{附录~\thechapter} 273 | \renewcommand{\indexname}{索\hspace{2em}引} 274 | \newcommand\figref[1]{\textbf{图}~\ref{#1}} 275 | \newcommand\tabref[1]{\textbf{表}~\ref{#1}} 276 | \renewcommand{\chaptername}{第 \thechapter\,章} 277 | \RequirePackage[\ELEGANT@cite]{gbt7714} 278 | }{\relax} 279 | \ifdefstring{\ELEGANT@lang}{en}{ 280 | \setlength\parindent{2em} 281 | \newcommand\figref[1]{\textbf{Figure}~\ref{#1}} 282 | \newcommand\tabref[1]{\textbf{Table}~\ref{#1}} 283 | \renewcommand{\chaptername}{Chapter \thechapter} 284 | \bibliographystyle{aer} 285 | }{\relax} 286 | 287 | \RequirePackage{xpatch} 288 | \xpatchcmd{\part}{\thispagestyle{plain}} 289 | {\thispagestyle{plain}}{}{} 290 | \xpatchcmd{\@endpart}{\vfil\newpage}{\vfil\newpage 291 | }{}{} 292 | \graphicspath{{./figure/}{./figures/}{./image/}{./images/}{./graphics/}{./graphic/}{./pictures/}{./picture/}} 293 | 294 | \RequirePackage{tikz} 295 | \usetikzlibrary{backgrounds,calc,shadows} 296 | \usepackage[object=vectorian]{pgfornament} %% 297 | 298 | \newcommand*{\eitemi}{\tikz \draw [baseline, ball color=structurecolor,draw=none] circle (2pt);} 299 | \newcommand*{\eitemii}{\tikz \draw [baseline, fill=structurecolor,draw=none,circular drop shadow] circle (2pt);} 300 | \newcommand*{\eitemiii}{\tikz \draw [baseline, fill=structurecolor,draw=none] circle (2pt);} 301 | \setlist[enumerate,1]{label=\color{structurecolor}\arabic*.} 302 | \setlist[enumerate,2]{label=\color{structurecolor}(\alph*).} 303 | \setlist[enumerate,3]{label=\color{structurecolor}\Roman*.} 304 | \setlist[enumerate,4]{label=\color{structurecolor}\Alph*.} 305 | \setlist[itemize,1]{label={\eitemi}} 306 | \setlist[itemize,2]{label={\eitemii}} 307 | \setlist[itemize,3]{label={\eitemiii}} 308 | 309 | 310 | %% device settings 311 | 312 | \RequirePackage{geometry} 313 | \ifdefstring{\ELEGANT@device}{normal}{ 314 | \geometry{ 315 | a4paper, 316 | top=25.4mm, bottom=25.4mm, 317 | headheight=2.17cm, 318 | headsep=4mm, 319 | footskip=12mm 320 | } 321 | 322 | \ifdefstring{\ELEGANT@marginpar}{margintrue}{ 323 | \geometry{ 324 | marginparwidth=5cm, marginparsep=5mm, 325 | left=2cm,right=7cm, 326 | } 327 | }{\relax} 328 | }{\relax} 329 | 330 | \ifdefstring{\ELEGANT@device}{pad}{ 331 | \geometry{ 332 | paperwidth=7.5in, 333 | paperheight=10in, 334 | margin=16mm, 335 | headheight=2.17cm, 336 | footskip=4mm 337 | }}{\relax} 338 | 339 | \RequirePackage{hyperref} 340 | \hypersetup{ 341 | breaklinks, 342 | unicode, 343 | linktoc=all, 344 | bookmarksnumbered=true, 345 | bookmarksopen=true, 346 | pdfkeywords={ElegantBook}, 347 | colorlinks, 348 | linkcolor=winered, 349 | citecolor=winered, 350 | urlcolor = winered, 351 | plainpages=false, 352 | pdfstartview=FitH, 353 | pdfborder={0 0 0}, 354 | linktocpage 355 | } 356 | \let\email\relax 357 | \newcommand\email[1]{\href{mailto:#1}{\nolinkurl{#1}}} 358 | 359 | %% 章节设置 360 | \RequirePackage[center,pagestyles]{titlesec} 361 | \RequirePackage{apptools} 362 | \RequirePackage[toc,page,title,titletoc]{appendix} 363 | 364 | \setcounter{secnumdepth}{5} 365 | 366 | \titleformat{\chapter}[\style]{\bfseries} 367 | {\filcenter\LARGE\enspace\bfseries{\color{structurecolor}\IfAppendix{\appendixname}{\chaptername}\enspace}}{1pt}{\bfseries\color{structurecolor}\LARGE\filcenter}[\ifdefstring{\ELEGANT@base}{hide}{}{\filcenter\base{structurecolor}{88}}] 368 | 369 | \titleformat{\section}[hang]{\bfseries} 370 | {\Large\bfseries{\color{structurecolor}\thesection}\enspace}{1pt}{\color{structurecolor}\Large\bfseries\filright} 371 | 372 | \titleformat{\subsection}[hang]{\bfseries}{ 373 | \large\bfseries\color{structurecolor}\thesubsection\enspace}{1pt}{\color{structurecolor}\large\bfseries\filright} 374 | 375 | \titleformat{\subsubsection}[hang]{\bfseries} 376 | {\large\bfseries\color{structurecolor}\thesubsubsection\enspace}{1pt}{\color{structurecolor}\large\bfseries\filright} 377 | 378 | 379 | \titlespacing{\chapter}{0pt}{-20pt}{1.3\baselineskip} 380 | %\titlespacing{\subsection}{0pt}{0.5\baselineskip}{-\baselineskip} 381 | 382 | 383 | 384 | %%define the note and proof environment 385 | \RequirePackage{pifont,manfnt,bbding} 386 | % list/itemize/enumerate setting 387 | \RequirePackage[shortlabels]{enumitem} 388 | \setlist{nolistsep} 389 | 390 | 391 | \RequirePackage[many]{tcolorbox} 392 | 393 | % \newlength{\normalparindent} 394 | % \setlength{\normalparindent}{\parindent} 395 | 396 | \ifdefstring{\ELEGANT@mode}{fancy}{ 397 | \tcbset{ 398 | common/.style={ 399 | fontupper=\ifdefstring{\ELEGANT@lang}{en}{\itshape}{\upshape\kaishu}, 400 | lower separated=false, 401 | % before upper={\setlength{\parindent}{\normalparindent}}, 402 | coltitle=white, 403 | colback=gray!5, 404 | boxrule=0.5pt, 405 | fonttitle=\bfseries, 406 | enhanced, 407 | breakable, 408 | top=8pt, 409 | before skip=8pt, 410 | attach boxed title to top left={yshift=-0.11in,xshift=0.15in}, 411 | boxed title style={boxrule=0pt,colframe=white,arc=0pt,outer arc=0pt}, 412 | separator sign={.}, 413 | }, 414 | defstyle/.style={ 415 | common, 416 | colframe=main, 417 | colback=main!5, 418 | colbacktitle=main, 419 | overlay unbroken and last={\node[anchor=south east, outer sep=0pt] at (\linewidth-width,0) {\textcolor{main}{$\clubsuit$}}; } 420 | }, 421 | thmstyle/.style={ 422 | common, 423 | colframe=second, 424 | colback=second!5, 425 | colbacktitle=second, 426 | overlay unbroken and last={\node[anchor=south east, outer sep=0pt] at (\linewidth-width,0) {\textcolor{second}{$\heartsuit$}}; } 427 | }, 428 | propstyle/.style={ 429 | common, 430 | colframe=third, 431 | colback=third!5, 432 | colbacktitle=third, 433 | overlay unbroken and last={\node[anchor=south east, outer sep=0pt] at (\linewidth-width,0) {\textcolor{third}{$\spadesuit$}}; } 434 | }, 435 | } 436 | 437 | \newtcbtheorem[auto counter,number within=chapter]{definition}{ 438 | \ifdefstring{\ELEGANT@lang}{en}{Definition}{定义} 439 | }{defstyle}{def} 440 | 441 | \newtcbtheorem[auto counter,number within=chapter]{theorem}{ 442 | \ifdefstring{\ELEGANT@lang}{en}{Theorem}{定理} 443 | }{thmstyle}{thm} 444 | 445 | \newtcbtheorem[auto counter,number within=chapter]{proposition}{ 446 | \ifdefstring{\ELEGANT@lang}{en}{Proposition}{命题} 447 | }{propstyle}{pro} 448 | 449 | \newtcbtheorem[auto counter,number within=chapter]{corollary}{ 450 | \ifdefstring{\ELEGANT@lang}{en}{Corollary}{推论} 451 | }{thmstyle}{cor} 452 | 453 | \newtcbtheorem[auto counter,number within=chapter]{lemma}{ 454 | \ifdefstring{\ELEGANT@lang}{en}{Lemma}{引理} 455 | }{thmstyle}{lem} 456 | 457 | }{\relax} 458 | 459 | \ifdefstring{\ELEGANT@mode}{simple}{ 460 | \let\openbox\relax 461 | \RequirePackage{amsthm} 462 | \let\proof\relax 463 | \let\endproof\relax 464 | % declare a new theorem style 465 | \newtheoremstyle{edefstyle}% 466 | {3pt}% Space above 467 | {3pt}% Space below 468 | {\ifdefstring{\ELEGANT@lang}{en}{\itshape}{\upshape\kaishu}}% Body font 469 | {}% Indent amount 470 | {\bfseries\color{main}}% Theorem head font 471 | {}% Punctuation after theorem head 472 | {0.5em}% Space after theorem head 473 | {\thmname{#1} \thmnumber{#2} \thmnote{(#3)}}% Theorem head spec (can be left empty, meaning ‘normal’) 474 | % -------------------------------------------------% 475 | \newtheoremstyle{ethmstyle}% 476 | {3pt}% Space above 477 | {3pt}% Space below 478 | {\ifdefstring{\ELEGANT@lang}{en}{\itshape}{\upshape\kaishu}}% Body font 479 | {}% Indent amount 480 | {\bfseries\color{second}}% Theorem head font 481 | {}% Punctuation after theorem head 482 | {.5em}% Space after theorem head 483 | {\thmname{#1} \thmnumber{#2} \thmnote{(#3)}}% Theorem head spec (can be left empty, meaning ‘normal’) 484 | % -------------------------------------------------% 485 | \newtheoremstyle{eprostyle}% 486 | {3pt}% Space above 487 | {3pt}% Space below 488 | {\ifdefstring{\ELEGANT@lang}{en}{\itshape}{\upshape\kaishu}}% Body font 489 | {}% Indent amount 490 | {\bfseries\color{third}}% Theorem head font 491 | {}% Punctuation after theorem head 492 | {.5em}% Space after theorem head 493 | {\thmname{#1} \thmnumber{#2} \thmnote{(#3)}}% Theorem head spec (can be left empty, meaning ‘normal’) 494 | 495 | \theoremstyle{edefstyle} 496 | \newtheorem{edefinition}{\ifdefstring{\ELEGANT@lang}{en}{Definition}{定义}}[chapter] 497 | 498 | \theoremstyle{ethmstyle} 499 | \newtheorem{etheorem}{\ifdefstring{\ELEGANT@lang}{en}{Theorem}{定理}}[chapter] 500 | \newtheorem{elemma}{\ifdefstring{\ELEGANT@lang}{en}{Lemma}{引理}}[chapter] 501 | \newtheorem{ecorollary}{\ifdefstring{\ELEGANT@lang}{en}{Corollary}{推论}}[chapter] 502 | 503 | \theoremstyle{eprostyle} 504 | \newtheorem{eproposition}{\ifdefstring{\ELEGANT@lang}{en}{Proposition}{命题}}[chapter] 505 | 506 | \newenvironment{theorem}[2] 507 | {\ifstrempty{#1}{\etheorem}{\etheorem[#1]}\ifstrempty{#2}{}{\label{thm:#2}}} 508 | {\endetheorem} 509 | 510 | \newenvironment{definition}[2] 511 | {\ifstrempty{#1}{\edefinition}{\edefinition[#1]}\ifstrempty{#2}{}{\label{def:#2}}} 512 | {\endedefinition} 513 | 514 | \newenvironment{lemma}[2] 515 | {\ifstrempty{#1}{\elemma}{\elemma[#1]}\ifstrempty{#2}{}{\label{lem:#2}}} 516 | {\endelemma} 517 | 518 | \newenvironment{corollary}[2] 519 | {\ifstrempty{#1}{\ecorollary}{\ecorollary[#1]}\ifstrempty{#2}{}{\label{cor:#2}}} 520 | {\endecorollary} 521 | 522 | \newenvironment{proposition}[2] 523 | {\ifstrempty{#1}{\eproposition}{\eproposition[#1]}\ifstrempty{#2}{}{\label{pro:#2}}} 524 | {\endeproposition} 525 | }{\relax} 526 | 527 | % main(green-def): example exercise problem solution 528 | % second(orange-thm): proof note remark 529 | % third(blue-prop): assumptions property conclusion custom 530 | 531 | %% Example with counter 532 | \newcounter{exam}[chapter] 533 | \setcounter{exam}{0} 534 | \renewcommand{\theexam}{\thechapter.\arabic{exam}} 535 | \newenvironment{example}[1][]{ 536 | \refstepcounter{exam}\par\noindent\textbf{\color{main}{% 537 | \ifdefstring{\ELEGANT@lang}{en}{Example}{例} 538 | }\theexam #1 \,}\rmfamily % 539 | }{ 540 | \par\medskip\ignorespacesafterend % 541 | } 542 | 543 | %% Exercise with counter 544 | \newcounter{exer}[chapter] 545 | \setcounter{exer}{0} 546 | \renewcommand{\theexer}{\thechapter.\arabic{exer}} 547 | \newenvironment{exercise}[1][]{ 548 | \refstepcounter{exer}\par\noindent\makebox[-3pt][r]{\scriptsize\color{red!90}\HandPencilLeft\quad}\textbf{\color{main}{% 549 | \ifdefstring{\ELEGANT@lang}{en}{Exercise}{练习} 550 | }\theexer #1 \,}\rmfamily % 551 | }{ 552 | \par\medskip\ignorespacesafterend % 553 | } 554 | 555 | %% Exercise with counter 556 | \newcounter{prob}[chapter] 557 | \setcounter{prob}{0} 558 | \renewcommand{\theprob}{\thechapter.\arabic{prob}} 559 | \newenvironment{problem}[1][]{ 560 | \refstepcounter{prob}\par\noindent\textbf{\color{main}{% 561 | \ifdefstring{\ELEGANT@lang}{en}{Problem}{例题} 562 | }\theprob #1 \,}\rmfamily % 563 | }{ 564 | \par\medskip\ignorespacesafterend % 565 | } 566 | 567 | 568 | 569 | \newenvironment{note}{\par\noindent{\makebox[0pt][r]{\scriptsize\color{red!90}\textdbend\quad}\textbf{\color{second}% 570 | \ifdefstring{\ELEGANT@lang}{en}{Note}{注意}\, 571 | }}\ifdefstring{\ELEGANT@lang}{en}{\itshape}{\kaishu}}{\par} 572 | 573 | \newenvironment{proof}{\par\noindent\textbf{\color{second}% 574 | \ifdefstring{\ELEGANT@lang}{en}{Proof}{证明}\; 575 | }\color{black!90}\small}{ 576 | %\hfill$\Box$\quad 577 | \par} 578 | \newenvironment{remark}{\noindent\textbf{\color{second}% 579 | \ifdefstring{\ELEGANT@lang}{en}{Remark}{注}\, 580 | }}{\par} 581 | \newenvironment{assumption}{\par\noindent\textbf{\color{third}% 582 | \ifdefstring{\ELEGANT@lang}{en}{Assumption}{假设}\, 583 | }}{\par} 584 | \newenvironment{conclusion}{\par\noindent\textbf{\color{third}% 585 | \ifdefstring{\ELEGANT@lang}{en}{Conclusion}{结论}\, 586 | }}{\par} 587 | \newenvironment{solution}{\par\noindent\textbf{\color{main}% 588 | \ifdefstring{\ELEGANT@lang}{en}{Solution}{解}\; 589 | }\ifdefstring{\ELEGANT@lang}{en}{\itshape}{\kaishu}}{\vskip2ex\par} 590 | \newenvironment{property}{\par\noindent\textbf{\color{third}% 591 | \ifdefstring{\ELEGANT@lang}{en}{Property}{性质}\; 592 | }}{\par} 593 | \newenvironment{custom}[1]{\par\noindent\textbf{\color{third} 594 | \ifdefstring{\ELEGANT@lang}{en}{#1}{#1}\, 595 | }}{\par} 596 | 597 | \RequirePackage{multicol} 598 | \tcbset{ 599 | introduction/.style={ 600 | enhanced, 601 | breakable, 602 | colback=structurecolor!10, 603 | colframe=structurecolor, 604 | fonttitle=\bfseries, 605 | colbacktitle=structurecolor, 606 | fontupper=\ifdefstring{\ELEGANT@lang}{en}{\sffamily}{\kaishu}, 607 | attach boxed title to top center={yshift=-3mm,yshifttext=-1mm}, 608 | boxrule=0pt, 609 | toprule=0.5pt, 610 | bottomrule=0.5pt, 611 | top=8pt, 612 | before skip=8pt, 613 | sharp corners 614 | }, 615 | } 616 | 617 | \newenvironment{introduction}[1][\ifdefstring{\ELEGANT@lang}{en}{Introduction}{内容提要}]{ 618 | \begin{tcolorbox}[introduction,title={#1}] 619 | \begin{multicols}{2} 620 | \begin{itemize}[label=\textcolor{structurecolor}{\scriptsize\SquareShadowBottomRight}] 621 | }{% 622 | \end{itemize} 623 | \end{multicols} 624 | \end{tcolorbox}} 625 | 626 | \RequirePackage{adforn} 627 | \newenvironment{problemset}[1][\ifdefstring{\ELEGANT@lang}{en}{\textbf{\chaptername\, Exercise}}{\textbf{\chaptername\, 习题}}]{ 628 | \begin{center} 629 | \ifdefstring{\ELEGANT@lang}{en}{\addcontentsline{toc}{section}{\texorpdfstring{\chaptername\,}{Chapter} Exercise} }{\addcontentsline{toc}{section}{\texorpdfstring{\chaptername\,}{章节}习题}} 630 | \textcolor{structurecolor}{\Large\bfseries\adftripleflourishleft~#1~\adftripleflourishright} 631 | \end{center} 632 | \begin{enumerate}[label=\textcolor{structurecolor}{\arabic*.}]}{% 633 | \end{enumerate}} 634 | 635 | \def\relsec{\endgroup start} 636 | \def\endrelsec{end\begingroup\def \@currenvir {relsec}} 637 | 638 | \ifdefstring{\ELEGANT@result}{noanswer}{ 639 | \AtBeginDocument{ 640 | \excludecomment{solution} 641 | \excludecomment{proof} 642 | \excludecomment{inline} 643 | } 644 | }{\relax} 645 | 646 | 647 | %页眉页脚 648 | \RequirePackage{fancyhdr} 649 | \RequirePackage{lastpage} 650 | \fancyhf{} 651 | 652 | 653 | \ifdefstring{\ELEGANT@base}{hide}{ 654 | \fancyfoot[c]{\color{structurecolor}\ifdefstring{\ELEGANT@lang}{en}{\itshape}{\kaishu}\scriptsize--\;\thepage\;--} 655 | \if@twoside 656 | \fancyhead[ER]{\color{structurecolor}\ifdefstring{\ELEGANT@lang}{en}{\itshape}{\kaishu}\leftmark} 657 | \fancyhead[OL]{\color{structurecolor}\ifdefstring{\ELEGANT@lang}{en}{\itshape}{\kaishu}\rightmark} 658 | \else 659 | \fancyhead[R]{\color{structurecolor}\ifdefstring{\ELEGANT@lang}{en}{\itshape}{\kaishu}\rightmark} 660 | \fi 661 | }{\relax} 662 | 663 | 664 | \ifdefstring{\ELEGANT@base}{show}{ 665 | \fancyfoot[c]{\catcode`\$=3\relax\base{structurecolor}{88}} 666 | \if@twoside 667 | \fancyhead[EL,OR]{\color{structurecolor}\ifdefstring{\ELEGANT@lang}{en}{\itshape}{\kaishu}--\;\thepage/\pageref*{LastPage}\;--} 668 | \fancyhead[ER]{\color{structurecolor}\ifdefstring{\ELEGANT@lang}{en}{\itshape}{\kaishu}\leftmark} 669 | \fancyhead[OL]{\color{structurecolor}\ifdefstring{\ELEGANT@lang}{en}{\itshape}{\kaishu}\rightmark} 670 | \else 671 | \fancyhead[R]{\color{structurecolor}\ifdefstring{\ELEGANT@lang}{en}{\itshape}{\kaishu}--\;\thepage/\pageref*{LastPage}\;--} 672 | \fancyhead[L]{\color{structurecolor}\ifdefstring{\ELEGANT@lang}{en}{\itshape}{\kaishu}\rightmark} 673 | \fi 674 | }{\relax} 675 | 676 | 677 | \renewcommand{\headrule}{\color{structurecolor}\hrule width\textwidth} 678 | \pagestyle{fancy} 679 | \renewcommand{\headrulewidth}{1pt} 680 | % \renewcommand{\headrule}{} 681 | \fancypagestyle{plain}{\renewcommand{\headrulewidth}{0pt}\fancyhf{}\renewcommand{\headrule}{}} 682 | \renewcommand{\sectionmark}[1]{\markright{\thesection\, #1}{} } 683 | \renewcommand{\chaptermark}[1]{\markboth{\chaptername \, #1\,}{}} 684 | 685 | %%封面 686 | \newcommand*{\extrainfo}[1]{\def\@extrainfo{#1}} 687 | 688 | \def\IfEmpty#1{% 689 | \edef\1{\the#1} 690 | \ifx\1\empty 691 | } 692 | \def \ifempty#1{\def\temp{#1} \ifx\temp\empty } 693 | 694 | \newcommand*{\logo}[1]{ 695 | \def\@logo{\includegraphics[width=4.2cm]{#1} 696 | } 697 | } 698 | \ifdefstring{\ELEGANT@device}{normal}{ 699 | \newcommand*{\cover}[1]{ 700 | \def\@cover{\includegraphics[width=\linewidth]{#1} 701 | } 702 | }}{\relax} 703 | 704 | \ifdefstring{\ELEGANT@device}{pad}{ 705 | \newcommand*{\cover}[1]{ 706 | \def\@cover{\includegraphics[trim=0 26bp 0 26bp,clip=true, width=\linewidth]{#1} 707 | } 708 | }}{\relax} 709 | 710 | \renewcommand{\baselinestretch}{1.35} 711 | 712 | \renewcommand*{\maketitle}{% 713 | \hypersetup{pageanchor=false} 714 | \begin{titlepage} 715 | \newgeometry{margin = 0in} 716 | \parindent=0pt 717 | \@cover 718 | \setlength{\fboxsep}{0pt} 719 | \colorbox{second}{\makebox[\linewidth][c]{\shortstack[c]{\vspace{0.5in}}}} 720 | \vfill 721 | \vskip-2ex 722 | \hspace{2em} 723 | \parbox{0.8\textwidth}{ 724 | \bfseries\Huge \@title\par 725 | } 726 | \vfill 727 | \vspace{-0.5cm} 728 | \setstretch{2.5} 729 | \hspace{2.5em} 730 | \begin{minipage}[c]{0.68\linewidth} 731 | {\color{darkgray}\bfseries\Large \the\subtitle\\[2ex]} 732 | \color{gray}\kaishu\normalsize 733 | {\renewcommand{\arraystretch}{0.618} 734 | \begin{tabular}{l} 735 | \ifdefstring{\ELEGANT@lang}{en}{\textbf{Author: }}{\textbf{作者:}}\@author \\ 736 | 737 | \ifdefstring{\ELEGANT@lang}{en}{\textbf{Institute: }}{\textbf{Email:}}\the\institute\\ 738 | 739 | \ifdefstring{\ELEGANT@lang}{en}{\textbf{weixin: }}{\textbf{微信公众号:}}\the\weixin\\ 740 | 741 | \ifdefstring{\ELEGANT@lang}{en}{\textbf{Update: }}{\textbf{完成时间:}}\@date\\ 742 | 743 | \ifdefstring{\ELEGANT@lang}{en}{\textbf{Version: }} 744 | {\textbf{版本:}}\the\version \\ 745 | \end{tabular}} 746 | \end{minipage} 747 | \begin{minipage}[c]{0.27\linewidth} 748 | \begin{tikzpicture}[remember picture,overlay] 749 | \begin{pgfonlayer}{background} 750 | \node[opacity=0.8,anchor=south east,outer sep=0pt,inner sep=0pt] at ($(current page.south east) +(-0.8in,1.5in)$) {\@logo}; 751 | \end{pgfonlayer} 752 | \end{tikzpicture} 753 | \end{minipage} 754 | \vfill 755 | \begin{center} 756 | \setstretch{1.3} 757 | \parbox[t]{0.7\textwidth}{\centering \itshape \@extrainfo} 758 | \end{center} 759 | \vfill 760 | \end{titlepage} 761 | \restoregeometry 762 | \thispagestyle{empty} 763 | } 764 | 765 | 766 | 767 | \RequirePackage{listings} 768 | \renewcommand{\ttdefault}{cmtt} 769 | \lstdefinestyle{mystyle}{ 770 | basicstyle=% 771 | \ttfamily 772 | \lst@ifdisplaystyle\small\fi 773 | } 774 | 775 | \lstset{basicstyle=\ttfamily,style=mystyle,breaklines=true} 776 | 777 | \definecolor{lightgrey}{rgb}{0.9,0.9,0.9} 778 | \definecolor{frenchplum}{RGB}{190,20,83} 779 | \lstset{language=[LaTeX]TeX, 780 | texcsstyle=*\color{winered}, 781 | numbers=none, 782 | breaklines=true, 783 | keywordstyle=\color{winered}, 784 | commentstyle=\color{gray}, 785 | emph={elegantpaper,fontenc,fontspec,xeCJK,FiraMono,xunicode,newtxmath,figure,fig,image,img,table,itemize,enumerate,newtxtext,newtxtt,ctex,microtype,description,times,newtx,booktabs,tabular,PDFLaTeX,XeLaTeX,type1cm,BibTeX,device,color,mode,lang,amsthm,tcolorbox,titlestyle,cite,marginnote,ctex,listings,base}, 786 | emphstyle={\color{frenchplum}}, 787 | morekeywords={DeclareSymbolFont,SetSymbolFont,toprule,midrule,bottomrule,institute,version,includegraphics,setmainfont,setsansfont,setmonofont ,setCJKmainfont,setCJKsansfont,setCJKmonofont,RequirePackage,figref,tabref,email,maketitle,keywords,definecolor,extrainfo,logo,cover,subtitle,appendix,chapter,hypersetup,mainmatter,tableofcontents,elegantpar,heiti,kaishu,lstset,pagecolor,zhnumber,marginpar,part,equote,marginnote}, 788 | frame=single, 789 | tabsize=2, 790 | rulecolor=\color{structurecolor}, 791 | framerule=0.2pt, 792 | columns=flexible, 793 | % backgroundcolor=\color{lightgrey} 794 | } 795 | \newcommand\bmmax{0} 796 | \RequirePackage{bm} 797 | 798 | -------------------------------------------------------------------------------- /figure/cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hoganbin/TikZ-Learning-Notes/d78da88fe07f9c5203680caaa37ebb35c28f71a9/figure/cover.jpg -------------------------------------------------------------------------------- /figure/cover.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hoganbin/TikZ-Learning-Notes/d78da88fe07f9c5203680caaa37ebb35c28f71a9/figure/cover.pdf -------------------------------------------------------------------------------- /figure/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hoganbin/TikZ-Learning-Notes/d78da88fe07f9c5203680caaa37ebb35c28f71a9/figure/logo.png -------------------------------------------------------------------------------- /mindmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hoganbin/TikZ-Learning-Notes/d78da88fe07f9c5203680caaa37ebb35c28f71a9/mindmap.png -------------------------------------------------------------------------------- /reference.bib: -------------------------------------------------------------------------------- 1 | 2 | @article{en3, 3 | title={{The Mechanism and Effectiveness of Credit Scoring of P2P Lending Platform: Evidence from Renrendai.com}}, 4 | author={Li, Qiang and Chen, Liwen and Zeng, Yong}, 5 | journal={China Finance Review International}, 6 | volume={8}, 7 | number={3}, 8 | pages={256--274}, 9 | year={2018}, 10 | publisher={Emerald Publishing Limited} 11 | } 12 | 13 | 14 | @article{en2, 15 | author = {Carlstrom, Charles T and Fuerst, Timothy S}, 16 | title = {{Agency Costs, Net Worth, and Business Fluctuations: A Computable General Equilibrium Analysis}}, 17 | journal = {The American Economic Review}, 18 | pages = {893-910}, 19 | ISSN = {0002-8282}, 20 | year = {1997}, 21 | type = {Journal Article} 22 | } 23 | 24 | @article{en1, 25 | author = {Quadrini, Vincenzo}, 26 | title = {{Financial Frictions in Macroeconomic Fluctuations}}, 27 | journal = {FRB Richmond Economic Quarterly}, 28 | volume = {97}, 29 | number = {3}, 30 | pages = {209-254}, 31 | year = {2011}, 32 | type = {Journal Article} 33 | } 34 | 35 | @article{cn1, 36 | author = {方军雄}, 37 | key = {fang1 jun1 xiong2}, 38 | title = {{所有制、制度环境与信贷资金配置}}, 39 | journal = {经济研究}, 40 | number = {12}, 41 | pages = {82-92}, 42 | ISSN = {0577-9154}, 43 | year = {2007}, 44 | type = {Journal Article} 45 | } 46 | 47 | @article{cn2, 48 | author = {刘凤良 and 章潇萌 and 于泽}, 49 | key = {liu2 feng4 liang2 zhang1 xiao1 meng2 yu2 ze2}, 50 | title = {{高投资、结构失衡与价格指数二元分化}}, 51 | journal = {金融研究}, 52 | number = {02}, 53 | pages = {54-69}, 54 | ISSN = {1002-7246}, 55 | year = {2017}, 56 | type = {Journal Article} 57 | } 58 | 59 | @article{cn3, 60 | author = {吕捷 and 王高望}, 61 | key = {lv3 jie2 wang2 gao1 wang4}, 62 | title = {{CPI 与 PPI “背离”的结构性解释}}, 63 | journal = {经济研究}, 64 | volume = {50}, 65 | number = {04}, 66 | pages = {136-149}, 67 | ISSN = {0577-9154}, 68 | year = {2015}, 69 | type = {Journal Article} 70 | } 71 | 72 | -------------------------------------------------------------------------------- /settings.tex: -------------------------------------------------------------------------------- 1 | \usepackage{amsmath} 2 | \usepackage{url} 3 | \usepackage{xcolor} 4 | \usepackage{color} 5 | \usepackage{cancel} 6 | \usepackage{pgfornament} 7 | \usepackage{calligra} 8 | \usepackage{pstricks-add} 9 | %\usepackage{tkz-linknodes} 10 | \usepackage{metalogo} 11 | \usepackage{scalerel} %\scaleobj{1.5}{} 缩放公式大小 12 | \usepackage{siunitx} %需用到\ang[options]{degrees}命令 13 | \definecolor{pink}{RGB}{249,164,186} 14 | \definecolor{grassgreen}{RGB}{128,255,0} 15 | \def\sgn{\mathop{\rm sgn}} 16 | %\setCJKmainfont[AutoFakeBold,AutoFakeSlant]{STSong} 17 | %\setCJKsansfont[AutoFakeBold,AutoFakeSlant]{KaiTi} 18 | %\setCJKmonofont[AutoFakeBold,AutoFakeSlant]{STFangsong} 19 | %\usepackage{verbatim} 20 | %\usepackage[active,tightpage]{preview} 21 | %\PreviewEnvironment{tikzpicture} 22 | %\setlength\PreviewBorder{5pt} 23 | \usepackage{tikz,pgfplots} 24 | \usepackage{circuitikz} 25 | \usetikzlibrary{ 26 | shapes.geometric, %几何形状 27 | calc, %计算 28 | positioning, %用于提供位置表达语句的支持,通俗讲就是定位 29 | arrows.meta, %提供各种箭头 30 | automata, %绘制状态转换图 31 | matrix, %构建矩阵 32 | topaths,%用于to/edge算子构建的路径 33 | shapes.misc, %约分 34 | chains, %绘制链状图形的库,一般画流程图必需的库 35 | shadings, %提供已定义好的图案如菱形 36 | quotes, %提供引用句法 37 | angles, %用来标示角 38 | patterns, %定义图样,如条纹 39 | fadings, %用于灰度图 40 | fit, %创建数个坐标点 41 | decorations.pathmorphing, %装饰线 42 | decorations.text, 43 | quotes,through, 44 | intersections, %两个路径的交点 45 | backgrounds, %背景路径 46 | shapes, 47 | arrows, %箭头路径 48 | snakes, 49 | mindmap, %思维导图 50 | shadows, 51 | circuits.ee.IEC%电路图 52 | } 53 | \tikzstyle{state}=[circle,label=below:$r$, 54 | thick, 55 | minimum size=1.2cm, 56 | draw=blue!80, 57 | fill=blue!20] 58 | \tikzstyle{state2}=[circle,label=below:$e$, 59 | thick, 60 | minimum size=1.2cm, 61 | draw=blue!80, 62 | fill=blue!20] 63 | \tikzstyle{state3}=[circle,label=below:$a$, 64 | thick, 65 | minimum size=1.2cm, 66 | draw=blue!80, 67 | fill=blue!20] 68 | \tikzstyle{state4}=[circle,label=below:$d$, 69 | thick, 70 | minimum size=1.2cm, 71 | draw=blue!80, 72 | fill=blue!20] 73 | % The measurement vector is represented by an orange circle. 74 | \tikzstyle{measurement}=[circle, 75 | thick, 76 | minimum size=1.2cm, 77 | draw=orange!80, 78 | fill=orange!25] 79 | 80 | % The control input vector is represented by a purple circle. 81 | \tikzstyle{input}=[circle, 82 | thick, 83 | minimum size=1.2cm, 84 | draw=purple!80, 85 | fill=purple!20] 86 | 87 | % The input, state transition, and measurement matrices 88 | % are represented by gray squares. 89 | % They have a smaller minimal size for aesthetic reasons. 90 | \tikzstyle{matrx}=[rectangle, 91 | thick, 92 | minimum size=1cm, 93 | draw=gray!80, 94 | fill=gray!20] 95 | 96 | % The system and measurement noise are represented by yellow 97 | % circles with a "noisy" uneven circumference. 98 | % This requires the TikZ library "decorations.pathmorphing". 99 | \tikzstyle{noise}=[circle, 100 | thick, 101 | minimum size=1.2cm, 102 | draw=yellow!85!black, 103 | fill=yellow!40, 104 | decorate, 105 | decoration={random steps, 106 | segment length=2pt, 107 | amplitude=2pt}] 108 | 109 | % Everything is drawn on underlying gray rectangles with 110 | % rounded corners. 111 | \tikzstyle{background}=[rectangle, 112 | fill=gray!10, 113 | inner sep=0.2cm, 114 | rounded corners=5mm] 115 | 116 | 117 | 118 | 119 | 120 | \usepackage{scalerel} %\scaleobj{1.5}{} 缩放公式大小 121 | \newcommand\hcancel[2][black]{\setbox0=\hbox{#2}\rlap{\raisebox{.45\ht0}{\textcolor{#1}{\rule{\wd0}{1pt}}}}#2} 122 | 123 | 124 | \definecolor{pink}{RGB}{249,164,186} 125 | \definecolor{grassgreen}{RGB}{128,255,0} 126 | 127 | \pgfkeys{/pgf/decoration/.cd, 128 | stipple density/.store in=\pgfstippledensity, 129 | stipple density=.1, 130 | stipple scaling function/.store in=\pgfstipplescalingfunction, 131 | stipple scaling function=sin(\pgfstipplex*180)*0.875+0.125, 132 | stipple radius/.store in=\pgfstippleradius, 133 | stipple radius=0.25pt 134 | } 135 | \pgfdeclaredecoration{stipple}{draw}{ 136 | \state{draw}[width=\pgfdecorationsegmentlength]{ 137 | \pgfmathparse{\pgfdecoratedcompleteddistance/\pgfdecoratedpathlength}% 138 | \let\pgfstipplex=\pgfmathresult% 139 | \pgfmathparse{int(\pgfstippledensity*100)}% 140 | \let\pgfstipplen=\pgfmathresult 141 | \pgfmathloop 142 | \ifnum\pgfmathcounter<\pgfmathresult\relax 143 | \pgfpathcircle{% 144 | \pgfpoint{(rnd)*\pgfdecorationsegmentlength}% 145 | {(\pgfstipplescalingfunction)*(rnd^4)*\pgfdecorationsegmentamplitude+\pgfstippleradius}}% 146 | {\pgfstippleradius}% 147 | \repeatpgfmathloop 148 | } 149 | } 150 | 151 | \tikzset{stipple/.style={ 152 | decoration={stipple, segment length=2pt, #1}, 153 | decorate, 154 | fill 155 | }} 156 | % end of stippling code 157 | 158 | \newcommand\DrawBlock[3]{ 159 | \ifx#1b\relax 160 | \path[draw] 161 | (lm\the\numexpr#2-1\relax) -- ++(0,0,#3) coordinate (blocklf) 162 | (bm\the\numexpr#2-1\relax) -- ++(0,0,#3) coordinate (blocklb) 163 | (lm#2) -- ++(0,0,#3) coordinate (blockrf) 164 | (bm#2) -- ++(0,0,#3) coordinate (blockrb); 165 | \filldraw[fill=white,draw=black] 166 | (lm\the\numexpr#2-1\relax) -- (blocklf) -- (blocklb) -- (blockrb) -- (blockrf) -- (lm#2); 167 | \else 168 | \ifx#1f\relax 169 | \path[draw] 170 | (fm\the\numexpr#2-1\relax) -- ++(0,0,#3) coordinate (blocklf) 171 | (lm\the\numexpr#2-1\relax) -- ++(0,0,#3) coordinate (blocklb) 172 | (fm#2) -- ++(0,0,#3) coordinate (blockrf) 173 | (lm#2) -- ++(0,0,#3) coordinate (blockrb); 174 | \filldraw[fill=white,draw=black] 175 | (fm\the\numexpr#2-1\relax) -- (blocklf) -- (blocklb) -- (blockrb) -- (blockrf) -- (fm#2); 176 | \fi 177 | \fi 178 | \draw (blocklf) -- (blockrf); 179 | } 180 | 181 | \tikzset{ 182 | every picture/.style={ 183 | >=latex, 184 | node distance=5mm and 5mm 185 | %有无and的区别见手册positioning部分 186 | }} 187 | 188 | %定义框形状 189 | \tikzstyle{SS} %开始结束 190 | =[rounded corners, draw,rectangle] 191 | \tikzstyle{IO} %输入输出 192 | =[trapezium, trapezium left angle=70, trapezium right angle=110, draw] 193 | \tikzstyle{NR} %内容 194 | =[draw] 195 | \tikzstyle{PD} %判断 196 | =[diamond, aspect=4, draw, inner sep=1.5pt] 197 | 198 | 199 | 200 | %\usepackage{background} 201 | %\definecolor{bg}{RGB}{58,95,205} 202 | %\backgroundsetup{opacity=0.05,scale=1.2,angle=0,contents={ 203 | % \begin{tikzpicture} 204 | % \node[minimum width=18cm,minimum height=25cm,inner sep=0pt,outer sep=0pt,](box){}; 205 | % \fill[left color=bg!70!black!70,right color=bg!70!black] (box.south west)--(box.south east)--(box.north east)--(box.north west)--cycle; 206 | % \shade[inner color=bg!70!black,outer color=white!30!bg] (3,6)circle(.3cm); 207 | % \draw[opacity=.2,blue] (4,-6)circle(3cm); 208 | % \draw[opacity=.2,blue] (3,-5)circle(5cm); 209 | % \draw[opacity=.2,blue] (2,-3)circle(6cm); 210 | % \shade[inner color=bg!70!black,outer color=white!30!bg,xshift=-2cm,yshift=-11cm] (3,6)circle(.3cm); 211 | % \shade[inner color=bg!70!black,outer color=white!30!bg,xshift=1.3cm,yshift=-12cm] (3,6)circle(.3cm); 212 | % \shade[inner color=bg!70!black,outer color=white!30!bg,xshift=-4cm,yshift=-8cm] (3,6)circle(.3cm); 213 | % \shade[inner color=bg!70!black,outer color=white!30!bg,xshift=-6cm,yshift=-10cm] (3,6)circle(.3cm); 214 | % \shade[inner color=bg!70!black,outer color=white!30!bg,xshift=-6cm,yshift=-13cm] (3,6)circle(.3cm); 215 | % \end{tikzpicture} 216 | %}} 217 | 218 | %\usepackage{draftwatermark} 219 | %\SetWatermarkText{\shortstack 220 | % {微信公众号:八一考研数学竞赛 221 | %}} 222 | %\SetWatermarkLightness{0.50}%设置水印亮度 223 | %\SetWatermarkScale{0.3}%设置水印大小 --------------------------------------------------------------------------------