├── .gitattributes ├── .gitignore └── Latex入门教程 └── LaTeX入门教程.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /Latex入门教程/LaTeX入门教程.md: -------------------------------------------------------------------------------- 1 | # 第一章 Latex框架和总体设置 2 | ## 1.1 框架 3 | ```latex 4 | \documentclass[UTF8,a4paper,12pt]{ctexart} 5 | \title{LaTeX入门教程} 6 | \date{} %不显示时间 7 | 8 | \begin{document} 9 | \maketitle 10 | 中文内容 11 | \end{document} 12 | ``` 13 | # 1.2 标题 section 14 | ### 1.2.1 一级标题 15 | ```latex 16 | \section{一级标题} % 有序号 17 | \section*{一级标题} % 无序号 18 | ``` 19 | ### 1.2.2 二级标题 20 | ```latex 21 | \subsection{二级标题} % 有序号 22 | \subsection*{二级标题} % 无序号 23 | ``` 24 | ### 1.2.3 标题label 25 | ```latex 26 | \section{System} % 章节标题 27 | \label{sec:system} %标题的标签 28 | 29 | \ref{sec:conclusions} %在正文中引用这个标题名 30 | ``` 31 | ## 1.3 标题形式 32 | ```latex 33 | % 章节序号 和 序号字体大小 34 | \renewcommand{\thesection}{{\zihao{4} \chinese{section}.}} % 一. 35 | \renewcommand{\thesubsection}{{\zihao{-4}\arabic{section}.\arabic{subsection}}} % 1.1 36 | 37 | \arabic (1, 2, 3, ...) 38 | \alph (a, b, c, ...) 39 | \Alph (A, B, C, ...) 40 | \roman (i, ii, iii, ...) 41 | \Roman (I, II, III, ...) 42 | \chinese (一,二,三,四,...) 43 | ``` 44 | ## 1.4 字体字号 45 | ```latex 46 | {\songti 你好} % 宋体 47 | {\heiti 你好} % 黑体 48 | \textbf{你好} % 加粗 49 | ``` 50 | ``` 51 | {\zihao{4} 你好} % 四号字体 52 | {\zihao{-4} 你好} % 小四号字体 53 | ``` 54 | ## 1.5 行距 55 | 在导言部分 56 | ```latex 57 | % 行距,单倍行距 58 | \usepackage{setspace} 59 | \setstretch{1} 60 | 1:单倍行距 61 | 1.2:1.5倍行距 62 | 1.6:2倍行距 63 | ``` 64 | 或者 65 | ```latex 66 | \linespread{1} 67 | 1:单倍行距 68 | 1.2:1.5倍行距 69 | 1.6:2倍行距 70 | ``` 71 | 72 | ## 1.6 页眉页脚 73 | ```latex 74 | % 页眉页脚 75 | \usepackage{fancyhdr} 76 | \pagestyle{fancy} 77 | \fancyhf{} 78 | \cfoot{\thepage} % 页脚居中写页码 79 | \fancyhead[R]{\textbf{参赛队号 $\#\,6794$}} % 页脚写队名 80 | ``` 81 | ## 1.7 图表公式的编号形式 82 | ```latex 83 | % 图、表、公式的编号 84 | \renewcommand{\thefigure}{\arabic{section}-\arabic{figure}} # 5-1 85 | \renewcommand{\thetable}{\arabic{section}-\arabic{table}} # 5-1 86 | \renewcommand{\theequation}{\arabic{section}-\arabic{equation}} # 5-1 87 | 88 | % 单独一个图的引用 89 | 如图 \ref{Fig:character}所示 % 如图5-1所示 90 | % 对多个图中的字图的引用 91 | 如图 \arabic{section}-\ref{Fig:character:a}所示 % 如图5-1(a)所示 92 | ``` 93 | 94 | ## 1.8 字体 95 | ```latex 96 | \textbf{字体} % 粗体 97 | \textit{字体} % 斜体 98 | \emph{重点} % 强调 99 | ``` 100 | ## 1.9 颜色 101 | ```latex 102 | \definecolor{Red}{RGB}{225,0,0} 103 | \definecolor{Green}{RGB}{0,225,0} 104 | \definecolor{Blue}{RGB}{0,0,225} 105 | 106 | 107 | \textcolor{Red}{text} 108 | \textcolor{Green}{text} 109 | \textcolor{Blue}{text} 110 | ``` 111 | ## 1.10 空格 112 | ```latex 113 | \quad 114 | \qquad 115 | \, 116 | \ (空格) 117 | \/ 118 | ``` 119 | 120 | # 第二章 插入图片 121 | 122 | ## 2.1 单个图片 123 | ```latex 124 | % 添加包 125 | % figure 1 126 | \usepackage{graphicx} 127 | \usepackage{float} 128 | 129 | % 需要添加图片的地方 130 | \begin{figure}[H] % 此处需要用到宏包 float 131 | \centering % 图片居中 132 | \includegraphics[width = 8.3cm]{figures/figure_1.png} 133 | \caption{The caption of this figure.} 134 | \label{fig:figure1label} 135 | \end{figure} 136 | 137 | % 在中文中需要引用图片的地方 138 | 如图 \ref{fig:figure1label} 所示 139 | ``` 140 | 141 | ## 2.2 两个图片并列 142 | ### 2.2.1 两个并排图片,单独标题 143 | 144 | ```latex 145 | % 使用的宏包 146 | \begin{minipage}[t]{0.5\linewidth} 147 | \end{minipage} 148 | ``` 149 | ```latex 150 | \begin{figure}[H] 151 | \begin{minipage}[t]{0.5\linewidth} 152 | \centering 153 | \includegraphics[width=6cm]{figures/butterfly.jpg} 154 | \caption{left} 155 | \label{Fig:left} 156 | \end{minipage} 157 | \begin{minipage}[t]{0.5\linewidth} 158 | \centering 159 | \includegraphics[width=6cm]{figures/butterfly.jpg} 160 | \caption{right} 161 | \label{Fig:right} 162 | \end{minipage} 163 | \end{figure} 164 | ``` 165 | ### 2.2.2 两个并排图片,单独小标题,共享大标题 166 | ```latex 167 | % 使用宏包 168 | \subfigure[小标题]{} 169 | ``` 170 | ```latex 171 | % 添加红包 \usepackage{subfigure} 172 | \begin{figure}[H] 173 | \subfigure[left]{ 174 | \begin{minipage}[t]{0.5\linewidth} 175 | \centering 176 | \includegraphics[width=6cm]{figures/butterfly.jpg} 177 | \label{Fig:left} 178 | \end{minipage} 179 | } 180 | \subfigure[right]{ 181 | \begin{minipage}[t]{0.5\linewidth} 182 | \centering 183 | \includegraphics[width=6cm]{figures/butterfly.jpg} 184 | \label{Fig:right} 185 | \end{minipage} 186 | } 187 | \caption{G1 after first step of algorithm.} 188 | \end{figure} 189 | ``` 190 | 191 | 192 | # 第三章 插入表格 193 | ## 3.1 生成表格 194 | ```latex 195 | \usepackage{booktabs} % 绘制三线表 196 | ``` 197 | ```latex 198 | \begin{table}[htp] 199 | \centering 200 | \caption{常用符号说明} 201 | \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}ll}%表格两边顶格 202 | \toprule 203 | 符号 & 说明 \\ 204 | \midrule 205 | $s(x)$ & 径向基函数 \\ 206 | $I_1,I_2$ & 不同纹理特征的图像\\ 207 | \bottomrule 208 | \end{tabular*} 209 | \label{tab:symbol} 210 | \end{table} 211 | ``` 212 | ## 3.2 表格引用 213 | ```latex 214 | 如表格 \ref{tab:DH}所示。 215 | ``` 216 | 217 | 218 | 219 | # 第四章 数学公式 220 | 221 | ## 4.0 包 222 | ```latex 223 | \usepackage{amsmath} 224 | \usepackage{bm} % 数学公式中使用的黑体 \bm{R} 225 | ``` 226 | ## 4.1 单个方程 227 | ```latex 228 | \begin{equation} 229 | y = ax+b 230 | \end{equation} 231 | ``` 232 | ## 4.2 方程组 233 | ```latex 234 | % 左大括号 235 | \begin{equation} 236 | \begin{cases} 237 | y_1 = a_1x + b_1\\ 238 | y_2 = a_2x + b_2 239 | \end{cases} 240 | \end{equation} 241 | 242 | % 两个方程是一组(使用1个编号),没有左大括号 243 | \begin{equation} 244 | \begin{gathered} 245 | y_1 = a_1x + b_1\\ 246 | y_2 = a_2x + b_2 247 | \end{gathered} 248 | \end{equation} 249 | 250 | % 两个方程是一组(使用1个编号),有左大括号 251 | \begin{equation} 252 | \left \{ 253 | \begin{gathered} 254 | y_1 = a_1x + b_1\\ 255 | y_2 = a_2x + b_2 256 | \end{gathered} 257 | \right . 258 | \end{equation} 259 | ``` 260 | ## 4.3 拆分单个公式 261 | ```latex 262 | % 将一个长的公式分两行写 263 | \begin{equation} 264 | \begin{split} 265 | y =& a + b + c\\ 266 | & + d + e 267 | \end{split} 268 | \end{equation} 269 | ``` 270 | ## 4.4 分段函数 271 | ```latex 272 | \begin{equation} 273 | T= 274 | \begin{cases} 275 | 0 & a<2\\ 276 | 1 & a=2\\ 277 | 3 & a>2 278 | \end{cases} 279 | \end{equation} 280 | ``` 281 | 282 | ## 4.5 矩阵 283 | ```latex 284 | \begin{equation} 285 | \begin{bmatrix} 286 | a & b\\ 287 | c & d 288 | \end{bmatrix} 289 | \end{equation} 290 | ``` 291 | ## 4.6 分子分母 292 | ```latex 293 | \begin{equation} 294 | \frac{a+b}{c+d} 295 | \end{equation} 296 | ``` 297 | ## 4.7 希腊字母 298 | ```latex 299 | # 小写希腊字母(大写希腊字母时,首字母大写即可) 300 | \alpha 301 | \beta 302 | \gamma 303 | \delta 304 | \epsilon 305 | \eta 306 | \theta 307 | \lambda 308 | \mu 309 | \sigma 310 | \tau 311 | \phi 312 | \varphi 313 | \chi 314 | \psi 315 | \omega 316 | ``` 317 | ## 4.8 数学算子 318 | ```latex 319 | \sum # 求和 320 | \prod #乘积 321 | \partial # 微分 322 | \int # 积分 323 | \iint # 二级积分 324 | \iiint #三级积分 325 | ``` 326 | 327 | # 第五章 328 | 329 | ## 5.1 度 330 | ```latex 331 | $90^{\circ}$ 332 | ``` 333 | ## 5.2 角 334 | ```latex 335 | $\angle A = 90^{\circ}$ 336 | ``` 337 | ## 5.3 单引号,双引号 338 | ```latex 339 | `单引号' 340 | ``双引号'' 341 | ``` 342 | ## 5.4 横杠 343 | ```latex 344 | - % 连字符 345 | -- % 数字范围 346 | --- % 破折号 347 | ``` 348 | ## 5.5 下划线 349 | ```latex 350 | \underline{论文} % 单下划线 351 | \uuline{论文} % 双下划线 352 | ``` 353 | 354 | # 第六章 列表 355 | 356 | ## 6.1 列表 357 | ```latex 358 | % 列表里面嵌套列表 359 | \begin{enumerate} 360 | \item [1.] 大学 361 | \begin{enumerate} 362 | \item [1.1] 大一 363 | \item [1.2] 大二 364 | \item [1.3] 大三 365 | \item [1.4] 大四 366 | \end{enumerate} 367 | \item [2.] 研究生 368 | \end{enumerate} 369 | ``` 370 | 371 | # 第七章 插入代码 372 | ## 10.1 包 373 | ```latex 374 | \usepackage{listings} % 插入代码的包 375 | \usepackage{xcolor} %颜色包 376 | 377 | \lstset{ % 378 | language=Matlab, % the language of the code 379 | basicstyle=\zihao{-4}, % the size of the fonts that are used for the code 380 | numbers=left, % where to put the line-numbers 381 | numberstyle=\tiny\color{gray}, % the style that is used for the line-numbers 382 | stepnumber=1, % the step between two line-numbers. If it is 1, each line will be numbered 383 | numbersep=5pt, % how far the line-numbers are from the code 384 | backgroundcolor=\color{white}, % choose the background color. You must add \usepackage{color} 385 | showspaces=false, % show spaces adding particular underscores 386 | showstringspaces=false, % underline spaces within strings 387 | showtabs=false, % show tabs within strings adding particular underscores 388 | frame=single, % adds a frame around the code 389 | rulecolor=\color{black}, % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. commens (green here)) 390 | tabsize=2, % sets default tabsize to 2 spaces 391 | captionpos=b, % sets the caption-position to bottom 392 | breaklines=true, % sets automatic line breaking 393 | breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace 394 | title=\lstname, % show the filename of files included with \lstinputlisting; 395 | % also try caption instead of title 396 | keywordstyle=\color{blackred}, % keyword style 397 | commentstyle=\color{dkgreen}, % comment style 398 | stringstyle=\color{MidnightBlue}, % string literal style 399 | escapeinside={\%*}{*)}, % if you want to add LaTeX within your code 400 | morekeywords={*,...}, % if you want to add more keywords to the set 401 | escapechar=`, % 中文注释 402 | columns=flexible % 非等款输出 403 | } 404 | ``` 405 | 406 | ## 10.2 代码 407 | ```latex 408 | % 先定义颜色 409 | \definecolor{dkgreen}{rgb}{0,0.6,0} 410 | \definecolor{gray}{rgb}{0.5,0.5,0.5} 411 | \definecolor{MidnightBlue}{RGB}{25,25,112} 412 | \definecolor{blackred}{RGB}{199,21,133} % 关键字颜色 413 | 414 | % 代码 415 | \begin{lstlisting}[language = Matlab] 416 | function [W, Z, mu, mse] = pcaEm(X, m) 417 | % Perform EM-like algorithm for PCA (by Sam Roweis). 418 | % Input: 419 | % X: d x n data matrix 420 | % m: dimension of target space 421 | % Output: 422 | % W: d x m weight matrix 423 | % Z: m x n projected data matrix 424 | % mu: d x 1 mean vector 425 | % mse: mean square error 426 | % Reference: 427 | % Pattern Recognition and Machine Learning by Christopher M. Bishop 428 | % EM algorithms for PCA and SPCA by Sam Roweis 429 | % Written by Mo Chen (sth4nth@gmail.com). 430 | d = size(X,1); 431 | mu = mean(X,2); 432 | X = bsxfun(@minus,X,mu); 433 | W = rand(d,m); 434 | 435 | tol = 1e-6; 436 | mse = inf; 437 | maxIter = 200; 438 | for iter = 1:maxIter 439 | Z = (W'*W)\(W'*X); % 12.58 440 | W = (X*Z')/(Z*Z'); % 12.59 441 | 442 | last = mse; 443 | E = X-W*Z; 444 | mse = mean(dot(E(:),E(:))); 445 | if abs(last-mse)