/ LaTeX  

【持续更新】论文常用LaTeX代码

论文常用LaTeX代码

这个代码不局限于数模论文里用的了,但说用在数模里面是一点问题都没有的啊。

由于我现在各类作业、实验报告、大作业均有LaTeX\LaTeX书写,所以这里面的代码类别就会比较丰富,我也会持续更新的(只要我还在用LaTeX\LaTeX)。

图片

  • 导言区代码

    1
    2
    3
    \usepackage{graphicx} %插入图片的宏包
    \usepackage{float} %设置图片浮动位置的宏包
    \usepackage{subfigure} %插入多图时用子图显示的宏包
  1. 单图

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    \begin{figure}[htbp]
    \centering
    \includegraphics[width=.9\textwidth]{XXX.pdf} % 图片相对位置
    \caption{Electric Vehicles: January 2020} % 图片标题
    \label{fig:American} % 图片标签
    \end{figure}

    \begin{figure}[H]
    \centering
    \includegraphics[width=.4\textwidth]{ex2-3jie.pdf} % 图片相对位置
    \caption{习题2.3解图} % 图片标题
    \label{fig:ex4-9}
    \end{figure}
  2. 多图并列放置(子图格式)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    \begin{figure}[htbp]
    \centering
    \subfigure[Hot Map of one Room]{ % 图片1([]内为子图标题)
    \label{fig:sub.roomhot} % 子图1的标签
    \includegraphics[width=0.45\textwidth]{XXX.jpg}}% 子图1的相对位置
    \subfigure[Hot Map of one Floor]{ % 图片2
    \label{fig:sub.floorhot} % 子图2的标签
    \includegraphics[width=0.45\textwidth]{XXX.jpg}}% 子图2的相对位置
    \caption{Hot Map of one Room and one Floor} % 总图标题
    \label{fig:hot} % 总图标签
    \end{figure}
  3. 多图并列放置(全图格式)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    \begin{figure}[htbp]
    \centering %图片全局居中
    %并排几个图,就要写几个minipage
    \begin{minipage}[b]{0.45\textwidth} %所有minipage宽度之和小于1
    \centering %图片局部居中
    \includegraphics[width=0.8\textwidth]{DV_demand}
    %此时的图片宽度比例是相对于这个minipage的,不是全局
    \caption{name 1}
    \label{fig:1}
    \end{minipage}
    \begin{minipage}[b]{0.45\textwidth}
    \centering %图片局部居中
    \includegraphics[width=0.8\textwidth]{P+R_demand}
    \caption{name 2}
    \label{fig:2}
    \end{minipage}
    \end{figure}
  4. 放置图片过程中,调整图片尺寸

    1
    2
    \includegraphics[width=0.45\textwidth,trim=85 80 80 85,clip]{room_pic_guidance_new/step179.jpg}}
    % 从左到右依次为左、下、右、上
  5. Visio画图有多余边框

    http://www.mamicode.com/info-detail-2181323.html

  6. 图片环绕文字

    1
    2
    3
    4
    5
    6
    7
    8
    9
    % \usepackage{wrapfig} 				%环绕文字需要引用的宏包
    \begin{wrapfigure}{r}{8cm} %靠文字内容的左侧
    \centering
    \includegraphics[width=.45\textwidth]{01.jpg} % 图片相对位置
    \caption{程控放大器设计框图} % 图片标题
    \label{fig:01} % 图片标签
    \end{wrapfigure}

    1. 放大器采用同相比例放大器,如图 \ref{fig:01} 所示。设$R_1=1\ k\Omega$,则分别选$R_{f4}=1\ k\Omega$,$R_{f3}=3\ k\Omega$$R_{f2}=5\ k\Omega$$R_{f1}=7\ k\Omega$,即可实现增益在2、4、6、8倍之间可控。其中$R_{F0}=300\ k\Omega\gg R_{Fi}$,主要是避免开关切换瞬间运放开环工作。

公式

  1. 局部对齐不标序号

    1
    2
    3
    4
    5
    6
    7
    8
    \begin{equation*} 
    \begin{aligned}
    \text{the initial temperature: } &\quad T_0=1, \\
    \text{the terminal temperature: }&\quad e = 10^{-30},\\
    \text{attenuation coefficient: }&\quad \alpha =0.999, \\
    \text{the solution domain: }&\quad \mathbb{S}=\left\{p \in(0, \infty), t \in\left(0, t_{\max }\right]\right\}
    \end{aligned}
    \end{equation*}

the initial temperature: T0=1,the terminal temperature: e=1030,attenuation coefficient: α=0.999,the solution domain: S={p(0,),t(0,tmax]}\begin{aligned} \text{the initial temperature: } &\quad T_0=1, \\ \text{the terminal temperature: }&\quad e = 10^{-30},\\ \text{attenuation coefficient: }&\quad \alpha =0.999, \\ \text{the solution domain: }&\quad \mathbb{S}=\left\{p \in(0, \infty), t \in\left(0, t_{\max }\right]\right\} \end{aligned}

  1. 一个优化模型的示例

    1
    2
    3
    4
    5
    6
    7
    8
    9
    \begin{align}
    \min &\,Z=\sum_{i \in \mathbb{I}} \sum_{j} \in B(j)\\
    \mathrm{s.t.} &\left\{\begin{array}{llll}
    \sum\limits_{i \in A(i)} V_i y_{ij} \le \sum\limits_{j \in A(i)} E_j x_j,\\
    \sum\limits_{j \in B(i)} y_{ij} \ge 1, \forall i\in \mathbb{I}, \forall j \in B(j), \\
    \sum\limits_{i \in A(i)} x_j \ge 1, \forall i \in \mathbb{I}, \\
    y_{ij}\le x_j, \forall i\in \mathbb{I}, j\in \mathbb{J}. \\
    \end{array}\right.
    \end{align}

minZ=iIjB(j)s.t.{iA(i)ViyijjA(i)Ejxj,jB(i)yij1,iI,jB(j),iA(i)xj1,iI,yijxj,iI,jJ.\begin{aligned} \min &\,Z=\sum_{i \in \mathbb{I}} \sum_{j} \in B(j)\\ \mathrm{s.t.} &\left\{\begin{array}{llll} \sum\limits_{i \in A(i)} V_i y_{ij} \le \sum\limits_{j \in A(i)} E_j x_j,\\ \sum\limits_{j \in B(i)} y_{ij} \ge 1, \forall i\in \mathbb{I}, \forall j \in B(j), \\ \sum\limits_{i \in A(i)} x_j \ge 1, \forall i \in \mathbb{I}, \\ y_{ij}\le x_j, \forall i\in \mathbb{I}, j\in \mathbb{J}. \\ \end{array}\right. \end{aligned}

  1. 添加行属性、列属性的矩阵

    1
    2
    3
    4
    5
    6
    7
    8
    9
    \begin{equation}\label{Eq:matrix1}
    \bordermatrix{%
    & t_1 & t_2 &\cdots &t_n\cr
    u_1 & ? & ? &\cdots & ?\cr
    u_2 & ? & ? &\cdots & ?\cr
    \vdots & \vdots &\vdots &\cdots &\vdots\cr
    u_m & ? & ? &\cdots &?
    },
    \end{equation}
  2. cases示例

    1
    2
    3
    4
    5
    6
    \begin{equation}\label{eq:food_reqiure_fin1}
    W_t=\left\{\begin{array}{ll}
    \ln (Ft)\cdot\left[1-\mathrm{exp}(-k_{\max}t)\right]^3, &\text{if }F>F_w,\\
    \ln (Ft)\cdot\left[1-\mathrm{exp}(-(1-\mathrm{e}^{-\lambda F})k_{\max}t)\right]^3, &\text{if }0\le F\le F_w.\\
    \end{array}\right.
    \end{equation}

Wt={ln(Ft)[1exp(kmaxt)]3,if F>Fw,ln(Ft)[1exp((1eλF)kmaxt)]3,if 0FFw. W_t=\left\{\begin{array}{ll} \ln (Ft)\cdot\left[1-\mathrm{exp}(-k_{\max}t)\right]^3, &\text{if }F>F_w,\\ \ln (Ft)\cdot\left[1-\mathrm{exp}(-(1-\mathrm{e}^{-\lambda F})k_{\max}t)\right]^3, &\text{if }0\le F\le F_w.\\ \end{array}\right.

表格

  1. 符号说明(基础三线表)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    \begin{table}[!htbp]
    \begin{center}
    \caption{Notations} % 表格标题
    \begin{tabular}{c|l} % 三线表格式('c'居中,'l'左对齐,'|'表示竖框线)
    \toprule % 上框线
    \multicolumn{1}{m{3cm}}{\centering Symbol}
    &\multicolumn{1}{m{8cm}}{\centering Definition}\\
    \midrule % 中框线
    $\rho$ & the people density\\
    $\mathit{SD_i}$ & the spatial danger of the $i^{th}$ cellular\\
    $v_i$ & the velocity of the $i^{th}$ visitor\\
    $\overrightarrow{F_{Mi}}$ & the attractive force (spatial danger and velocity) on the $i^{th}$ visitor\\
    $\overrightarrow{F_{ppi}}$ & the people-to-people interaction force on the $i^{th}$ visitor\\
    $\overrightarrow{d_i}$ & the expected movement direction the $i^{th}$ visitor\\
    $\alpha$ &the weight of the spatial danger and visitors’ velocity in $\overrightarrow{d_i}$\\
    $\beta$ &the weight of interaction force between people in $\overrightarrow{d_i}$\\
    $p$ & the ratio of the crowd decentralization\\
    \bottomrule %底框线
    \end{tabular}\label{tb:notation}
    \end{center}
    \end{table}
  2. 基础表格

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    \begin{table}[!htbp]
    \begin{center}
    \caption{Grey prediction accuracy registration}
    \begin{tabular}{c|ccccccc}
    \toprule
    \textbf{Year} &2011 &2012 &2013 &2014 &2015 &2016 &2017\\
    \midrule
    \textbf{EV Amount} & 1000& 1800& 3000&5000&8000&15000&20000 \\
    \bottomrule
    \end{tabular}\label{tb:Gray_Prediction}
    \end{center}
    \end{table}
  3. 固定列宽表格

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    \begin{table}[!htbp]
    \begin{center}
    \caption{Normalized results of raw data for each indicator}
    \begin{tabularx}{32em} % 控制固定总列宽32em
    {*{8}{>{\centering\arraybackslash}X}} % 8栏每栏表格居中
    \toprule
    \textit{C}\textsubscript{1} &\textit{C}\textsubscript{2} &\textit{C}\textsubscript{3} &\textit{C}\textsubscript{4} &\textit{C}\textsubscript{5} &\textit{C}\textsubscript{6} &\textit{C}\textsubscript{7} &\textit{C}\textsubscript{8}\\
    \midrule
    0.0833& 1.0& 0 &0.375& 1 &0.9326 &0.9067 &0 \\
    \bottomrule
    \end{tabularx}\label{tb:Normalized_results}
    \end{center}
    \end{table}
  4. 标题行分两类的表格

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    \begin{table}[!htbp]
    \begin{center}
    \caption{Metabolic rate of different Flying creatures in Static and Dynamic}
    \begin{tabular}{cccc}
    \toprule
    \multirow{2}{*}{Flying creatures} & \multirow{2}{*}{Body weight (g)} &\multicolumn{2}{c}{Metabolic rate (cal$\cdot\text{g}^{-1}\cdot\text{hr}^{-1}$)}\\
    \cmidrule{3-4}
    & & Dynamic & Static\\
    \midrule
    \textbf{Parrot} & 42& 106 & 15.4\\
    \textbf{Gull} & 345 &56 & 7.2\\
    \textbf{Bat} & 512& 60 & 6.9\\
    \textbf{Eagle} & 2117& 36 & 4.5\\
    \bottomrule
    \end{tabular}\label{tb:Metabolic_rate}
    \end{center}
    \end{table}

信件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
% 以下为信件/备忘录部分,不需要可自行去掉
% 如有需要可将整个 letter 环境移动到文章开头或中间
% 请在后一个花括号内填写信件(Letter)或备忘录(Memorandum)标题
\begin{letter}{Memorandum}
\begin{flushleft} % 左对齐环境,无首行缩进
\textbf{To:} Heishan Yan\\
\textbf{From:} Team XXXXXXX\\
\textbf{Date:} October 1st, 2019\\
\textbf{Subject:} A better choice than MS Word: \LaTeX
\end{flushleft}

In the memo, we want to introduce you an alternate typesetting program to the prevailing MS Word: \textbf{\LaTeX}. In fact, the history of \LaTeX\ is even longer than that of MS Word. In 1970s, the famous computer scientist Donald Knuth first came out with a typesetting program, which named \TeX\ \ldots

Firstly, \ldots

Secondly, \ldots

Lastly, \ldots

According to all those mentioned above, it is really worth to have a try on \LaTeX!
\end{letter}

参考文献(MLA)

  1. 普通书籍

    1
    2
    \bibitem{1} Venuti, Fiammetta, and Luca Bruno. "Crowd-structure interaction in lively footbridges under synchronous lateral excitation: A literature review." \emph{Physics of life reviews} 6.3 (2009): 176-206.
    \bibitem{6} Yuan, Weifeng, and Kang Hai Tan. "An evacuation model using cellular automata." \emph{Physica A: Statistical Mechanics and its Applications} 384.2 (2007): 549-566.
  2. 博士论文

    1
    \bibitem{4} Kongjin Zhu. \emph{Study on Evacuation Characteristics and Evacuation Strategy in Typical Rigions of buildings}. Diss. Hefei: University of Science and Technology of China, 2013.
  3. 网站

    1
    \bibitem{3} \emph{Charging Station}. (2019). Retrieved January 1, 2020, from\url{https://en.wikipedia.org/wiki/Charging_station}

代码高亮

1
2
\noindent\textsc{Part A} - \textbf{lab021.m}
\lstinputlisting[language=matlab]{./code/lab021.m}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
\begin{lstlisting}[language=vhdl]
process(sel3) --根据音调编码,分配分频系数
begin
case sel3 is
when"000"=>count_ld<="0111011101110"; --3822 -- 1(中音do!)
when"001"=>count_ld<="0000000110010"; --50 -- 1(低音do)
when"010"=>count_ld<="0000000010100"; --20 -- 2(低音re)
when"011"=>count_ld<="0000000001010"; --10 -- 3(低音mi)
when"100"=>count_ld<="0000000000101"; --5 -- 4(低音fa)
when"101"=>count_ld<="0000000000010"; --2 -- 5(低音sol)
when"110"=>count_ld<="1000111000000"; --4544 -- 6(低音la)
when"111"=>count_ld<="0111111010000"; --4048 -- 7(低音si)
when others=>count_ld<="0111011101110"; --3822
end case;
end process;
\end{lstlisting}

本文标题:【持续更新】论文常用LaTeX代码

文章作者:Levitate_

发布时间:2020年08月30日 - 09:42:10

原始链接:https://levitate-qian.github.io/2020/08/30/latex-code/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。