Loading [MathJax]/jax/output/CommonHTML/jax.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >[论文工具] LaTeX论文撰写常见用法及实战技巧归纳(持续更新)

[论文工具] LaTeX论文撰写常见用法及实战技巧归纳(持续更新)

作者头像
Eastmount
发布于 2023-10-07 03:19:38
发布于 2023-10-07 03:19:38
2.5K01
代码可运行
举报
运行总次数:1
代码可运行

回过头来,我们在编程过程中,经常会遇到各种各样的问题。然而,很多问题都无法解决,网上夹杂着各种冗余的回答,也缺乏系统的实战技巧归纳。为更好地从事科学研究和编程学习,后续将总结各类常见实战技巧,希望对您有所帮助。

本文主要介绍LaTeX论文撰写的常见用法和实战技巧总结,包括论文的基本结构、算法、图片、表格、公式、特殊符号、参考文献、序号等方法。全文将持续更新,一方面作为自己的学习笔记,另一方面希望能帮助初学者解决实际问题,且看且珍惜


基本论文结构

什么是LaTeX

LaTeX是一种基于ΤΕΧ的排版系统,由美国计算机学家莱斯利·兰伯特在20世纪80年代初期开发,利用这种格式,即使使用者没有排版和程序设计的知识也可以充分发挥由TeX所提供的强大功能,能在几天、甚至几小时内生成很多具有书籍质量的印刷品。对于生成复杂表格和数学公式,这一点表现得尤为突出。因此它非常适用于生成高印刷质量的科技和数学类文档。

LaTeX的工作方式类似网页,它们都是由源文件(.tex or .html)经由引擎(TeX or browser)渲染产生最终效果,从而得到PDF文件或生成页面。两者极其神似,包括语法规则与工作方式。

官方下载地址如下:

  • Tex Live下载地址:http://www.tug.org/texlive/
  • 清华大学镜像地址:https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/Images/
  • Tex studio下载地址:http://www.texstudio.org/

强烈推荐大家直接下载LaTex模块进行修改,这篇文章更多是告诉大家基本语法,安装过程请大家下来去尝试,希望对您有所帮助!


基本结构

LaTeX文档分为导言区和正文区(文稿区),在导言区我们可以使用documentclass命令引入一个文档类,也可以有book类、report类、letter类,其中百分号表示注释,不参与文档编译且不作为输出。在正文区用begin和end输入一个环境,如下图所示:

接着将环境的名称设置为document,一个LaTeX文件有且只能有一个document文件,添加正文内容再编译文档。

导言区主要用于全局设置,比如文档标题、作者、日期,再通过maketitle显示标题。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
% 导言区
\documentclass{article}

\title{My First Document}
\author{Eastmount}
\date{\today}

% 正文区
\begin{document}
  \maketitle
  Hello World!
\end{document}

显示如下图所示:


篇章结构

学术论文通常包括两种结构,如下图所示,左边表示理论型,右边表示实验型。

在LaTeX中我们可以通过section定义小结,也可以用subsection定义子小结。同时更推荐大家下载IEEE结构进行修改,后面我也会讲到。

  • \section{Section title}
  • \label{sec:mysection}
  • \subsection{title}
  • \subsubsection{title}
  • \section*{} unnumbered section
  • \appendix

举个示例:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
% 导言区
\documentclass{article}
\usepackage{ctex}

\title{My First Document}
\author{Eastmount}
\date{\today}

% 正文区
\begin{document}
  \maketitle
  
  % 构建文章小结
  \section{Introduction}
  \section{Related Work}
  \section{System Model}
  \section{Mathematics and algorithms}
  \section{Experiments}
  \subsection{Datasets}
  \subsubsection{实验条件}
  \subsubsection{评价指标}
  \subsection{Results}
  \section{Acknowledgment}
  
\end{document}

输出结果如下图所示:


算法

通常采用两种方法进行算法的编写,包括:

  • 使用algorithm、algorithmic宏包
  • 使用algorithm2e宏包

algorithm

导入包:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\usepackage{algorithm}
\usepackage{algorithmic}

算法代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{algorithm}[!ht]
  \caption{Feature extraction based on abstract syntax tree.}
  
  \begin{algorithmic}[1]
  
  \REQUIRE {$X=\left\{x_1,x_2,...,x_n\right\}$, where $x_i$ is the $i^{th}$ PowerShell script.}
  \ENSURE {$V^{(ast)}=\left\{v_1,v_2,...,v_n\right\}$, where $v_i$ is the $i^{th}$ sequence vector generated by AST-based feature extraction method (i.e., AST2Vec).}
  \STATE $V^{(ast)} \leftarrow \emptyset$ , $S \leftarrow \emptyset$, $F \leftarrow \emptyset$, $W \leftarrow \emptyset$ 
  
  \FOR{$i \leftarrow 1$ {\bf to} $n$}
    \STATE $t_i = ExtractAstSequences( x_i )$ 
    \STATE $s_i = PostorderTraversal( t_i )$ 
    \STATE $S.append( s_i )$
  \ENDFOR
  \STATE $F = BuildFeatureSetFromAst(S) $
  \STATE $//$ Count all distinct features of AST sequences.
  \FOR{each $f_k \in F$}
    \STATE $w_k = CalculateWordVectors( f_k )$ 
    \STATE $W.append( w_k )$
  \ENDFOR
  \STATE $//$ Calculate word vectors for each AST node.
  \FOR{each $s_i \in S$}
    \STATE $v_i = GenerateAstEmbedding( s_i )$ 
    \STATE $V^{(ast)}.append( v_i )$
  \ENDFOR
  \STATE {\bf return} {$V^{(ast)}$}  
\end{algorithmic}
\label{algorithm1}
\end{algorithm}

运行结果如下图所示:


algorithm2e

导入包:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\usepackage{algorithm}
\usepackage[algo2e]{algorithm2e}

算法代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{algorithm}[!ht]
  \caption{Feature extraction based on abstract syntax tree.}
  \label{algorithm1}
  \SetAlgoLined
  \SetKwInOut{Input}{Input}
  \SetKwInOut{Output}{Output}
  
  \Input{$X=\left\{x_1,x_2,...,x_n\right\}$, where $x_i$ is the $i^{th}$ PowerShell script.}
  \Output{$V^{(ast)}=\left\{v_1,v_2,...,v_n\right\}$, where $v_i$ is the $i^{th}$ sequence vector generated by AST-based feature extraction method (i.e., AST2Vec).}
  
  Initialization: $V^{(ast)} \leftarrow \emptyset$ , $S \leftarrow \emptyset$, $F \leftarrow \emptyset$, $W \leftarrow \emptyset$ 
  
  \For{$i \leftarrow 1$ \KwTo $n$}{
    $t_i = ExtractAstSequences( x_i )$ 
    $s_i = PostorderTraversal( t_i )$ 
    $S.append( s_i )$
  }
  $F = BuildFeatureSetFromAst(S) $
  \tcc{Count all distinct features of AST sequences}
  \For{$f_k \in F$}{
    $w_k = CalculateWordVectors( f_k )$ 
    $W.append( w_k )$
  }
  \tcc{Calculate word vectors for each AST node}
  \For{$s_i \in S$}{
    $v_i = GenerateAstEmbedding( s_i )$ 
    $V^{(ast)}.append( v_i )$
  }
  \Return{$V^{(ast)}$}  
\end{algorithm}

运行结果如下图所示:


图片

基本用法

在LaTeX中插入图片的基本语法如下:

  • 导言区插入:\usepackage{graphicx}
  • 语法:\includegraphics[ < 选项 > ] { < 文件名 > }
  • 格式:EPS、PDF、PNG、JPEG、BMP

下面举例说明:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
% 导言区
\documentclass{article}
\usepackage{ctex}
\usepackage{graphicx}

% 指定图片在当前目录下figures目录下
\graphicspath{{figures/}}

% 正文区
\begin{document}
  % 插入图片
  \includegraphics{fig1}
  % 缩放比例
  \includegraphics[scale=0.5]{fig1}
  % 固定图像高度
  \includegraphics[height=2cm]{fig1.png}
  % 固定图像宽度
  \includegraphics[width=2cm]{fig1.png}
  % 图像高度和宽度基于
  \includegraphics[height=0.2\textheight]{fig1.png}
  \includegraphics[width=0.2\textwidth]{fig1.png}
  % 指定多个参数
  \includegraphics[angle=-45,width=0.5\textwidth]{fig1.png}
\end{document}

显示结果如下图所示,scale=0.5是将图片大小缩小为真实大小的一半,[width=0.2\textwidth] 将图形缩放到文本的0.2倍。


双栏显示

注意,在论文中通常会遇到要横跨两栏的应用场景,此时我们需要这样设置:

  • \begin{figure*}
  • \end{figure*}
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\usepackage{stfloats}
\begin{figure*}[ht]
  \centering
  \includegraphics[width=0.8\textwidth]{4.eps}
  \caption{BER performance of original OFDM system and different companding schemes over AWGN channel (QPSK).}
  \label{fig8}
\end{figure*}

上面代码中,figure* 表示跨双栏,htbp表示的意思是latex会尽量满足排在前面的浮动格式,就是h-t-b-p这个顺序,让排版的效果尽量好。其中,h-here表示在此处,t-top表示在顶部,b-bottom表示底部,p-page表示在本页。为了防止跨页图片跑到最后一页,我们需要在导言区加入stfloats包,然后设置\begin{figure*}[ht] 即可。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
h——放置在此处
t——放置在顶部
b——放置在底部
p——浮动放置
*——两栏放置

双图显示

第一种方式——调用minipage实现,也是最常见的方式。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{figure*}
  \begin{minipage}[t]{0.48\linewidth}
    \centering
    \includegraphics[scale=0.30]{Figure-7.eps}
    \caption{The loss curve of different models.}
    \label{fig7}
  \end{minipage}
  \begin{minipage}[t]{0.48\linewidth}
    \centering
    \includegraphics[scale=0.30]{Figure-8.eps}
    \caption{The accuracy curve of different models.}
    \label{fig8}
  \end{minipage}
\end{figure*}

显示效果如下图所示:

第二种方式——调用subfigure实现。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\usepackage{caption}
\usepackage{subfigure}

\begin{figure}[htbp]
  \centering    %居中
  \subfigure[name of the first figure] %第一张子图
  {
    \begin{minipage}[t]{0.4\textwidth}
      \centering
      \includegraphics[scale=0.15]{fig2}
    \end{minipage}
  }
  \subfigure[name of the second figure] %第二张子图
  {
    \begin{minipage}[t]{0.4\textwidth}
      \centering      
      \includegraphics[scale=0.2]{fig3} 
    \end{minipage}
  }
  \caption{name of the figure}        %大图名称
  \label{fig-1}  %图片引用标记
\end{figure}

显示如下图所示:

第三种方法——调用宏包宏包subfig。使用subfig宏包提供的\subfloat命令,需要使用宏包\usepackage{graphicx}和\usepackage{subfig}。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{figure}[!hb]
  \centering
  \subfloat[\label{fig:arm1}$Q^{*}$ values for arm 1]{\includegraphics[width=.5\linewidth]{1.eps}}%
  \subfloat[\label{fig:arm2}$Q^{*}$ values for arm 2]{\includegraphics[width=.5\linewidth]{1.eps}}\\
  \subfloat[\label{fig:arm3}$Q^{*}$ values for arm 3]{\includegraphics[width=.8\linewidth]{1.eps}}
  \caption{$Q^{*}$ values for different arms.}
  \label{fig:arms}
\end{figure}

显示如下图所示:


表格

基本用法

在LaTeX中使用tabular生成表格,插入时需要设置对齐方式(l-左对齐、c-居中对齐、r-右对齐),然后插入数据,其中&用于分割每列,\\用于换行。下面的代码展示常见的三线表。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{table}
  \caption{Symbol Table}
  \centering
  \begin{tabular}{lll}
  \hline
      Symbol & Definition & Unitis\\
      \noalign{\global\arrayrulewidth1pt}\hline\noalign{\global\arrayrulewidth0.4pt}
      \multicolumn{3}{c}{\textbf{Constants}}\\
      $\lambda$ & Mean of Poisson distribution & unitless\\
      $p_{slow}$ & Probability that a vehicle slows down randomly & unitless\\
      \hline
    \end{tabular}
\end{table}

显示如下图所示:

含注释的表格

在IEEE的LaTex模板里希望添加表格的注释,即说明表格字符的含义。具体流程如下:

  • 使用\usepackage{threeparttable}
  • \begin{tabular}后加上\begin{threeparttable},和\end{tabular}前加上\end{threeparttable}
  • 注释加在\begin{tablenotes} 和 \end{tablenotes}之间

导入扩展包如下所示:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\usepackage{threeparttable}
\usepackage{float}
\usepackage{bbding}
\usepackage{pifont}

代码如下:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{table*}[!ht]
  \centering
  \caption{Related work comparison.}
  \begin{threeparttable}
  \resizebox{\textwidth}{!}{
    \begin{tabular}{ccccm{1.2cm}<{\centering}m{1.2cm}<{\centering}cc}\hline
      Related work & Techniques & Focus & Deobfuscation &  AST & KG & Multi-modal & Transformer  \\\hline
      Li et al. \cite{b3} & \makecell[c]{subtree-based deobfuscation \\ OOA mining algorithm} & deobfuscation & \Checkmark & \Checkmark & \XSolid & \XSolid  & \XSolid \\\hline
      PSDEM \cite{b12} & \makecell[c]{two-layer deobfuscation \\  monitor process by dynamic analysis} & deobfuscation & \Checkmark & \XSolid & \XSolid & \XSolid & \XSolid \\\hline
      PowerDrive \cite{b13} & \makecell[c]{multi-stage deobfuscator \\  static analysis by regex \\ dynamic analysis by cmdlet} & deobfuscation & \Checkmark & \XSolid & \XSolid & \XSolid & \XSolid \\\hline
      PowerDecode \cite{b15} & \makecell[c]{syntax check and remove base64 encoding \\ deobfuscate by cmdlet overriding  \\ deobfuscate by regex} & deobfuscation & \Checkmark & \XSolid & \XSolid & \XSolid & \XSolid \\\hline
      Hendler et al. \cite{b18} & \makecell[c]{character-level CNN \\ 4-layer CNN} & binary classification & \XSolid & \XSolid & \XSolid & \XSolid & \XSolid \\\hline
      Fang et al. \cite{b19} & \makecell[c]{hybrid features \\ FastText \\ random forest} & binary classification & \Checkmark & \Checkmark & \XSolid & $\bigcirc$ & \XSolid \\\hline
      Hendler et al. \cite{b2} & \makecell[c]{AMSI-based detection \\ contextual embeddings \\ Token-Char-FastText} & binary classification & \XSolid & \XSolid & \XSolid & \XSolid & \XSolid \\\hline
      FC-PSDS \cite{b25} & \makecell[c]{ features combination \\ random forest and DNN} & binary classification & \Checkmark & \Checkmark & \XSolid & \XSolid & \XSolid \\\hline
      Ruscak et al. \cite{b20} & \makecell[c]{abstract syntax tree \\ random forest} & multi-classification task & \XSolid & \Checkmark & \XSolid & \XSolid & \XSolid \\\hline
      \makecell[c]{\textbf{Our method} \\ \textbf{PowerDetector}} & \makecell[c]{multi-modal embedding \\ Transformer-CNN-BiLSTM \\ multi-layer deobfuscation algorithm } & \makecell[c]{malicious family detection \\ multi-classification task} & \Checkmark & \Checkmark & \Checkmark & \Checkmark & \Checkmark \\\hline
  \end{tabular}}
  
  \begin{tablenotes}
    \footnotesize
    \item In this table, \Checkmark stands for fully cover, $\bigcirc$ stands for partial cover, \XSolid means cannot cover.
  \end{tablenotes}
  \end{threeparttable}
  \label{tab1}
\end{table*}

运行结果如下图所示:


复杂表格合并multirow

利用multirow宏包实现,multirow命令的基本语法格式如下:

  • \multirow{[行数]}{[宽度]}{[内容]}
  • \multirow{[行数]}*{[内容]}

导入包:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\usepackage{multirow}

代码如下:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{table*}[!ht]
  \centering
  \caption{Detailed performance comparison of single-modal and multi-modal.}
  \resizebox{\textwidth}{!}{
  \begin{tabular}{ccccccccccc}\hline
    \multirow{3}{*}{Model} & \multicolumn{8}{c}{Single-modal} & \multicolumn{2}{c}{\multirow{2}{*}{Multi-modal}} \\
    \cline{2-9}
    & \multicolumn{2}{c}{Token-level} & \multicolumn{2}{c}{Character-level} & \multicolumn{2}{c}{AST-level} & 
    \multicolumn{2}{c}{KG-level} & \multicolumn{2}{c}{} \\
    \cline{2-11}
    & $F_1$ & Acc & $F_1$ & Acc & $F_1$ & Acc & $F_1$ & Acc & $F_1$ & Acc \\\hline
    LR & 0.8727 & 0.8629 & 0.8496 & 0.8528 & 0.8661 & 0.8700 & 0.8646 & 0.8559 & 0.8895 & 0.8857 \\
    RF & 0.8723 & \textbf{0.8676} & \textbf{0.8610} & \textbf{0.8567} & \textbf{0.8807} & \textbf{0.8786} & 0.8723 & 0.8676 & \textbf{0.9017} & \textbf{0.8943}  \\
    SVM & 0.8764 & 0.8661 & 0.8527 & 0.8519 & 0.8755 & 0.8786 & \textbf{0.8771} & 0.8676 & 0.8934 & 0.8912  \\
    KNN & 0.8706 & 0.8669 & 0.8554 & 0.8536 & 0.8644 & 0.8637 & 0.8741 & \textbf{0.8715} & 0.8804 & 0.8771 \\\hline
    CNN & 0.9002 & 0.8974 & 0.8826 & 0.8808 & 0.9019 & 0.8998 & 0.9025 & 0.8998 & 0.9153 &  0.9115 \\
    TextCNN & 0.9049 & 0.9013 & 0.9012 & 0.8966 & 0.9083 & 0.9076 & 0.9036 & 0.9005 & 0.9186 & 0.9178  \\
    BiLSTM & 0.9076 & 0.9069 & 0.9037 & 0.9036 & 0.9126 & 0.9107 & 0.9054 & 0.9025 & 0.9226 & 0.9209  \\
    BiGRU & 0.9041 & 0.9021 & 0.8989 & 0.8966 & 0.9092 & 0.9045 & 0.9046 & 0.9013 & 0.9205 & 0.9201  \\
    Transformer & 0.9123 & 0.9107 & 0.9053 & 0.9029 & 0.9116 & 0.9092 & 0.9121 & 0.9115 & 0.9224 & 0.9178  \\
    CNN-BiLSTM+ATT & \textbf{0.9142} & \textbf{0.9123} & \textbf{0.9081} & \textbf{0.9076} & \textbf{0.9144} & \textbf{0.9139} & \textbf{0.9139} & \textbf{0.9123} & \textbf{0.9262} & \textbf{0.9209} \\\hline
    \textbf{Our Method} & \textbf{0.9236} & \textbf{0.9225} & \textbf{0.9170} & \textbf{0.9169} & \textbf{0.9248} & \textbf{0.9233} & \textbf{0.9204} & \textbf{0.9201} & \textbf{0.9374} &\textbf{0.9358}  \\\hline                                
  \end{tabular}}
  \label{tab5}
\end{table*}

运行结果如下图所示:

表格越界处理方法:


解决自动换行

采用taularx解决相关问题,参考下列这篇博客。

  • https://blog.csdn.net/wanjiac/article/details/107489700

正常显示会越界,如下图所示:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{table*}[h]
  \centering
  \begin{tabular}{cc} \hline
    Use Case Navn: & Opret Server \\\hline
    Scenarie: & At oprette en server med bestemte regler som tillader folk at spille sammen. 
                        The nonlinear companding function introduce some nonlinear distortion to original OFDM signal, 
                        which can be eliminated theoretically by the decompanding function. \\\hline
  \end{tabular}
  \label{tab5}
\end{table*}

运行结果如下图所示,显然越界。

导入包:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\usepackage{tabularx}

代码如下:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{table*}[h]
  \centering
  \begin{tabularx}{\textwidth}{p{4cm} X} \hline
    Use Case Navn: & Opret Server \\\hline
    Scenarie: & At oprette en server med bestemte regler som tillader folk at spille sammen. 
                        The nonlinear companding function introduce some nonlinear distortion to original OFDM signal, 
                        which can be eliminated theoretically by the decompanding function. \\\hline
  \end{tabularx}
  \label{tab5}
\end{table*}

运行结果如下图所示:


公式

LaTeX中的数学模式有两种形式:inline 和 display。前者是指在正文插入行间数学公式,后者独立排列,可以有或没有编号。

  • 行内公式(inline): 用 将公式括起来进行排版,也可以使用小括号和\begin{math}排版。
  • 行间公式(displayed): 用 将公式括起来是无编号的形式,还有 \ [ … \ ]的无编号独立公式形式,块间元素默认是居中显示的。
  • 上标使用^符号,下表使用_符号。
  • 常见数学函数包括 \log、\sin、\cos、\arcsin、\arccos、\ln、\sqrt等。
  • 分数建议使用\frac{3}{4}表示3/4。
  • 如果需要对公式进行自动编号,要在equation环境下进行排版,同时调用\ref直接引用。
  • 各类希腊字母编辑表,常见符号如下图所示。

如果您正在编写包含许多复杂公式的科学文档,则amsmath包引入了几个新命令,这些命令比基本LaTeX提供的命令更强大,更灵活。

  • \usepackage {amsmath}
  • \usepackage {mathtools}

Stone_Stan4d老师的文章“Latex的公式输入”归纳总结了常见的符号,如下图所示:

接着给出一些示例:

(1)矩阵公式:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{equation}
\begin{aligned}
  V^{(token)}=
  \begin{bmatrix}
    v_{11} & v_{12} & \cdots & v_{1m} \\
    v_{21} & v_{22} & \cdots & v_{2m} \\
    \vdots & \vdots & \ddots & \vdots \\
    v_{n1} & v_{n2} & \cdots & v_{nm} \\
  \end{bmatrix}
\end{aligned}
\label{eq1}
\end{equation}

显示如下图所示:

(2)分段函数公式:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{equation}
\begin{aligned}
  TokenPairs[j][k] = 
  \begin{cases}
  v_{jk} + 1 & \exists <f_j,f_k>  \\
  v_{jk} + 0 & other  \\
  \end{cases}.
\end{aligned}\label{eq2}
\end{equation}

显示如下图所示:

(3)分数函数:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{equation}
\begin{aligned}
  Attention(\textbf{Q},\textbf{K},\textbf{V}) = softmax \left( \frac{\textbf{Q}\textbf{K}^T}{\sqrt{d_k}} \right) \textbf{V}.
\end{aligned}\label{eq5}
\end{equation}

显示如下图所示:

(4)准确率公式:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{equation}
\begin{aligned}
  Accuracy = \sum_{i=1}^N Accuracy_i \times w_i .
\end{aligned}\label{eq15}
\end{equation}

显示如下图所示:

需要注意,不同于图表使用“\ref{tab1}”的引用,公式使用“\eqref{eq1}”引用。区别是显示是否带有括号。

详细的公式使用文章推荐如下:

  • https://zhuanlan.zhihu.com/p/450465546

特殊符号

圆圈数字

正常推荐使用pifont宏包。

  • https://zhuanlan.zhihu.com/p/615066252
  • https://milde.users.sourceforge.net/LUCR/Math/mathpackages/amssymb-symbols.pdf
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\usepackage{pifont}
\ding{184}

各种样式如下:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\ding{182}\ding{183}\ding{184}\ding{185}\ding{186}\ding{187}\ding{188}\ding{189}\ding{190}\ding{191}\\

\ding{192}\ding{193}\ding{194}\ding{195}\ding{196}\ding{197}\ding{198}\ding{199}\ding{200}\ding{201}\\

\ding{202}\ding{203}\ding{204}\ding{205}\ding{206}\ding{207}\ding{208}\ding{209}\ding{210}\ding{211}\\

显示效果如下图所示:

然后,有时候出版社的模板无法引用pifont宏包,则使用如下:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
$\textcircled{3}$

但数字编号大的时候,数字会跑到圆圈外面。

解决方法如下:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\normalsize{\textcircled{\scriptsize{3}}}\normalsize\enspace

半圆

导入引用包和代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\usepackage{tikz}
\newcommand*\emptycirc[1][1ex]{\tikz\draw (0,0) circle (#1);} 
\newcommand*\halfcirc[1][1ex]{%
  \begin{tikzpicture}
  \draw[fill] (0,0)-- (90:#1) arc (90:270:#1) -- cycle ;
  \draw (0,0) circle (#1);
  \end{tikzpicture}}
\newcommand*\fullcirc[1][1ex]{\tikz\fill (0,0) circle (#1);}

使用如下:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\fullcirc
\halfcirc
\emptycirc

勾叉

导入引用包和代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\usepackage{pifont}       % \ding{xx}
\usepackage{bbding}       % \Checkmark,\XSolid,... (需要和pifont宏包共同使用)

使用如下:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\checkmark
\Checkmark
\CheckmarkBold
\XSolid
\XSolidBold
\XSolidBrush

其它参见的符号参考Xovee老师的文章,详见参考文献。

参考文献:

  • https://blog.csdn.net/hyk_1996/article/details/124486173
  • https://blog.csdn.net/xovee/article/details/122179352

纸牌

引用代码如下:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
$\clubsuit$
$\spadesuit$
$\heartsuit$
$\diamondsuit$

其它常见的符号推荐如下所示的博客。

  • https://blog.csdn.net/ying_xu/article/details/51240291
  • https://blog.csdn.net/YEN_CSDN/article/details/79966985

参考文献

LaTeX插入参考文献,可以使用BibTex,也可以不使用BibTex。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{thebibliography}{99}  
\bibitem{ref1}Zheng L, Wang S, Tian L, et al., Query-adaptive late fusion for image search and person re-identification, Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2015: 1741-1750.  
\bibitem{ref2}Arandjelović R, Zisserman A, Three things everyone should know to improve object retrieval, Computer Vision and Pattern Recognition (CVPR), 2012 IEEE Conference on, IEEE, 2012: 2911-2918.  
\bibitem{ref3}Lowe D G. Distinctive image features from scale-invariant keypoints, International journal of computer vision, 2004, 60(2): 91-110.  
\bibitem{ref4}Philbin J, Chum O, Isard M, et al. Lost in quantization: Improving particular object retrieval in large scale image databases, Computer Vision and Pattern Recognition, 2008. CVPR 2008, IEEE Conference on, IEEE, 2008: 1-8.  
\end{thebibliography}

上面列出了5个参考文献,{thebibliography}的选项99指的是参考文献的个数最大为99,可以设置为别的数。在正文中引用参考文献的方法是:\cite{ref1}、\cite{ref1, ref5}。

BibTeX 是一种格式和一个程序,用于协调LaTeX的参考文献处理。

在Texlive中,通常有两种格式的引用参考文献。

(1)第一种方式直接在main.tex文件中撰写,以thebibliography的形式。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{thebibliography}{49}

\bibitem{b1} Microsoft, ``What is PowerShell? - PowerShell | Microsoft Docs,'' 
    Website: https://docs.microsoft.com/en-us/powershell/scripting/overview, 2022.

\bibitem{b2} D. Hendler, S. Kels, et al., ``AMSI-Based Detection of Malicious PowerShell 
    Code Using Contextual Embeddings,'' in 15th ACM Asia Conference on Computer and 
    Communications Security (AsiaCCS). ACM, 2020, pp. 679-693.

\bibitem{b49} M. Ring, D. Schlor, et al., ``Malware detection on windows audit logs using 
  LSTMs,'' Computers \& Security, vol.109, 2021, p. 102389. 

\end{thebibliography}

(2)第二种方式将参考文献写在myref.bib,以 \bibliography{myref} 的形式添加。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
@misc{b1,
  title = {What is PowerShell? - PowerShell | Microsoft Docs},
  url = {https://docs.microsoft.com/en-us/powershell/scripting/overview},
  author = {Microsoft},
  year = {2022}
}

@inproceedings{b2,
  title={Amsi-based detection of malicious powershell code using contextual embeddings},
  author={Hendler, Danny and Kels, Shay and Rubin, Amir},
  booktitle={Proceedings of the 15th ACM Asia Conference on Computer and Communications Security (AsiaCCS)},
  pages={679--693},
  year={2020},
  organization = {ACM}
}

@article{b49,
  title={Malware detection on windows audit logs using LSTMs},
  author={Ring, Markus and Schl{\"o}r, Daniel and Wunderlich, Sarah and Landes, Dieter and Hotho, Andreas},
  journal={Computers \& Security},
  volume={109},
  pages={102389},
  year={2021},
  publisher={Elsevier}
}

参考文献BIB格式可以通过谷歌学术下载。同样,ChatGPT能够修改对应的格式,如百度的文心一言。参考文献格式推荐:

  • https://www.jianshu.com/p/f335e75487cb

显示如下图所示:


序号

(1) 无序序列

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{itemize}
  \item Every sentence should make sense.
  \item There is a lot to be said.
  \item Eschew the highfalutin.
\end{itemize}

(2) 有序序列

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{enumerate}
  \item Every sentence should make sense.
  \item There is a lot to be said.
  \item Eschew the highfalutin.
\end{enumerate}

(3) 自定义序列

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
\begin{description}
  \item[Rule 1.] Every sentence should make sense.
  \item[Rule 2.] There is a lot to be said.
  \item[Rule 3.] Eschew the highfalutin.
\end{description}

序列同样可以嵌套,代码如下所示:


总结

写到这里,希望这篇文章对您有所帮助,后续也将继续更新内容。

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2023-10-06 21:30,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 娜璋AI安全之家 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
Latex学习笔记(十)新模板的使用
最近有学长做了个新的MCMlatex模板 点击此处可以下载:下载. 主要内容如下: %% 美赛模板:正文部分 \documentclass[12pt]{article} % 官方要求字号不小于 12 号,此处选择 12 号字体 % 本模板不需要填写年份,以当前电脑时间自动生成 % 请在以下的方括号中填写队伍控制号 \usepackage[1234567]{easymcm} % 载入 EasyMCM 模板文件 \problem{A} % 请在此处填写题号 \usepackage{mathptmx}
zstar
2022/06/14
6840
LaTeX详细教程+技巧总结[通俗易懂]
若想学习Markdown,请参见我的另一篇博客:Markdown详细教程+技巧总结 。 若想直接学习LaTeX数学公式,请参见我的另一篇博客:LaTeX数学公式-详细教程 。
全栈程序员站长
2022/08/29
17.5K0
LaTeX详细教程+技巧总结[通俗易懂]
使用 LaTeX 进行论文写作
最近几个月一直在忙着跑实验,写论文,博客确实也是好久没有更新了,乘着最近论文搞得差不多了,碰巧也是在排版,来记录一下使用 LaTeX 进行论文写作的一些东西。
EmoryHuang
2023/03/12
2.6K0
使用 LaTeX 进行论文写作
LaTeX简单常用方法笔记,附模板
标题:\title{标题} 作者:\author{作者} 学号:\studentid{123} 正文:
小锋学长生活大爆炸
2021/06/11
1.6K0
LaTeX简单常用方法笔记,附模板
妈蛋,这玩意还真不得不会!
因为现在的期刊论文,尤其是计算机类的,越来越多是有统一格式要求的,并且有模板提供,这个模板就是以.tex结尾的文件包。Latex相对于word对数学公式更友好,格式更漂亮规范,处处体现了科研人员的严谨与认真。开始使用Latex到爱上Latex的过程,形容一下,就像“榴莲宝们”第一次吃到榴莲之后欲罢不能的全过程。
谭庆波
2019/05/14
1.1K0
妈蛋,这玩意还真不得不会!
Latex论文表格画法
\begin{table}[htbp] 表示表格的开始。中括号中的 htbp 表示的是表格的浮动格式。当然这个基本参数不仅仅只是对表格有用。需要注意的是,一般使用 [htb] 这样的组合,这样组合的意思就是Latex会尽量满足排在前面的浮动格式,就是 h-t-b 这个顺序,让排版的效果尽量好。         [h] 表示将表格放在当前位置。         [t] 表示将表格放置在页面的顶部。         [b] 表示将表格放置在页面的底部。         [p] 将表格放置在一只允许有浮动对象的页面上。     \caption{my table} 表示表格的标题,该设置可以放在 \begin{tabular} \end{tabular} 环境的前后,使得表格的标题显示在表格的上面或下面。\label{table1} 表示表格名字,用于正文中引用表格。     若要插入跨栏图表, 可以用浮动环境 table* 。\begin{table}[htbp] 变成 \begin{table*}[htbp] ,\end{table} 变成 \end{table*} 。     \begin{tabular}[位置]{列} 和 \begin{tabular*}{宽度}[位置]{列} 设置表格环境参数格式。         \begin{tabular}{|c|c|c|} 。一个 c 表示有一列,格式为居中显示,这是列必选参数。通过添加 | 来表示是否需要绘制竖线。|| 表示画二条紧相邻的竖直线。             l 表示该列左对齐。             c 表示该列居中对齐。             r 表示该列右对齐。         如果只需要某几列的宽度发生改变,可以使用 p{宽度} (以 cm 为单位或以 pt 为单位或 0.2\textwidth)来代替 c 参数,但是表格中的文字是默认左对齐的。因此此时可以添加 p{宽度}<{\centering} 来改变文本对齐方式,但此时需要添加包 \usepackage{array} 。在这里 \centering 参数可以被 \raggedleft 和 \raggedright 替换,分别表示为左对齐和右对齐。         也可以使用 tabular* (\begin{tabular*}{宽度}[位置]{列})环境参数,如上的 {宽度} 可以设置为 {10cm},表示整个表格的宽度为 10cm。但由于设置了表格的整体宽度,为了使表格对齐,需要使用表达式 @{\extracolsep{\fill}} ,但画正式表格一般 不推荐 使用这种表格方式(比较复杂,感觉一般用于画类似三线表格的图表中),可以通过命令调整整个表格的缩放。         \begin{tabular}[位置]{cc}。[位置] 中的参数是位置可选参数,该参数表示表格相对于外部文本行基线的位置,又称为垂直定位参数。一般为默认不设置,表示表格按照外部文本行的基线垂直居中。t表示表格顶部与当前外部文本行的基线重合。b 表示表格底部与当前外部文本行的基线重合。     可用 \setlength{\tabcolsep}{1pt} 来调整表格的列间距离 (十分推荐) 。     可用 \renewcommand\arraystretch{1.5} 来调整表格行间距,意思是将每一行的高度变为原来的1.5倍 (十分推荐) 。     如果表格太大,可以使用 \scalebox{1.5} 来对表格进行缩放,意思是将表格的大小变为原来的1.5倍 (十分推荐),使用的时候需要添加包 \usepackage{graphicx} 。
狼啸风云
2020/05/29
11K0
【Latex】2021数模国赛模板使用
本文用于排版时快速复制需要的内容框架。 所用模板为2021Latex国赛模板 插入图片 width根据需要改. \begin{figure}[H] \centering \includegraphics[width=8cm]{../../所用图片/12.png} \caption{问题一流程图} \end{figure} 连续实心点 \begin{itemize} \item \item \item \end{itemize} 插入公式 \begin{equation} \end{equat
zstar
2022/06/14
5640
LaTeX详细安装步骤和简明教程
配置TeXLive和TeXstudio。TeXLive是编译器为Latex提供运行所需的环境;TeXstudio编辑器,提供操作界面,需要先安装好TeXLive之后,TeXstudio才能使用。
全栈程序员站长
2022/08/30
4K0
LaTeX详细安装步骤和简明教程
Latex 论文elsevier,手把手如何用Latex写论文
这几天在开始写论文,准备发的是elsevier,这个网站的instruction有问题,下载的东西基本上好多的错误,所以我就写博客记录。
林德熙
2018/09/19
11.5K0
Latex 论文elsevier,手把手如何用Latex写论文
LaTeX简单常用方法笔记
API参考手册: http://www.personal.ceu.hu/tex/latex.htm
小锋学长生活大爆炸
2020/08/25
1.2K0
LaTeX简单常用方法笔记
Latex论文写作小技巧记录,不断更新
如果是IEEElatex模板,使用“equation”块,格式如下,会自动设置编号:
小锋学长生活大爆炸
2022/09/20
1.5K0
Latex论文写作小技巧记录,不断更新
MATLAB 与 C 语言的混合编程实战之辛普森积分法、自适应辛普森积分
题目大意是让你用c系语言实现辛普森积分法对定积分的粗略估计,所谓辛普森积分法即为:
glm233
2020/09/28
2K0
MATLAB 与 C 语言的混合编程实战之辛普森积分法、自适应辛普森积分
LaTeX基础操作
一个简单的LaTeX文档通常包括导言区(preamble)和正文区(document body),导言区定义文档的类型、使用的宏包等
esse LL
2024/03/12
3280
How to add subfigure in Latex
In research articles, we need to add subfigures often. To create subfigure in latex, you can use both \begin{minipage}...\end{minipage} and \begin{subfigure}...\end{subfigure} block to insert subfigures or sub-images. Subfigurs are generally inserted horizontally in one or multiple rows. Here, some example codes with output screenshots are provided in the following.
marsggbo
2019/03/27
1.6K0
How to add subfigure in Latex
通俗易懂的Latex教程文档
本篇文档可以搭配视频讲解使用。 讲解视频: https://player.bilibili.com/player.html?aid=933470753&page=1 通俗易懂的Latex教程(附数学
zstar
2022/06/14
2.5K0
通俗易懂的Latex教程文档
还在手写LaTeX表格?你可能需要这款神器
既然你点进来看了,说明你也遇到了类似的问题,也经历过手写和调试LaTeX表格的痛苦,现在就让我们解决它。
博士的沙漏
2020/09/03
3.5K0
还在手写LaTeX表格?你可能需要这款神器
LaTex 排版 (2):表格
aTeX 提供了许多工具来创建和定制表格,在本系列中,我们将使用 tabular 和 tabularx 环境来创建和定制表。
用户1880875
2021/09/09
1.5K0
latex中如何画表格_时态结构总结表格
在写论文的时候我们常常会用到三线表,三线表的基本语法就是下面这个样子的。在插入三线表的时候,在引言区加入\usepackage{booktabs} 如果是在双栏的环境里,如果我们的表格比较大,我们一般需要在表格的环境中加星号, 如果是表格只占一栏,这个时候我们就不需要加星号,我们假设我们使用表格的情况是占双栏的。三线表的精华就是那三根线了啦,用的命令就是 \toprule ,\midrule,\bottomrule 这三个命令。就是上中下,然后就是与rule 的结合。
全栈程序员站长
2022/09/22
1.8K0
latex中如何画表格_时态结构总结表格
Latex 三线表 横线竖线短横线
以这个图为例: 样式复现 导言区先添加: \usepackage{tabu} % 表格插入 \usepackage{multirow} % 一般用以设计表格,将所行合并 \usepackage{multicol} % 合并多列 \usepackage{multirow} % 合并多行 \usepackage{float} % 图片浮
小锋学长生活大爆炸
2022/09/29
4.1K0
Latex 三线表 横线竖线短横线
latex图表教程(scienhub平台支持)
LaTeX 中插入图表通常需要使用 \includegraphics 命令,该命令属于 graphicx 宏包。以下是一个简单的 LaTeX 图表教程:
用户4821680
2024/03/28
3180
相关推荐
Latex学习笔记(十)新模板的使用
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档