【Latex】

本文详细介绍了使用LatexOverLeaf平台的基础知识,包括文档类型设置、序言中的元素、格式化命令、图片添加、图片标签和引用、列表创建、数学公式、摘要撰写、章节划分、段落处理、表格制作以及参考文献引用的方法。
摘要由CSDN通过智能技术生成

Latex-OverLeaf

使用简介

简单的框架

//代表文档的类型,是文章、简历还是什么,控制着文章的样式
\documentclass{article}
//在documentclass{article}和begin{document}中间的称为序言,一般可以定义一些相关的属性
//要编写的文档的类型
//要编写的语言
//要使用的包
//其他元素

//文档正文,文章的内容全部写在这个里面
\begin{document}
.....
\end{document}

序言

//定义文档的类型为article和字体大小12pt以及纸张大小letterpaper
\documentclass[12pt, letterpaper]{article}
//定义了文章的编码
\usepackage[utf8]{inputenc}
//定义文章标题
\title{First document}
//定义作者姓名
//在author的命令中定义添加上标和脚注
\author{Hubert Farnsworth \thanks{funded by the Overleaf team}}
//添加日期
\date{February 2017}


//定义了但不会显示,需要使用\maketitle命令
//latex中的单行注释使用%

简单的格式化命令

%加粗
Some of the \textbf{greatest}
%下划线
discoveries in \underline{science}
%斜体
were made by \textbf{\textit{accident}}.
%强调,在普通文本中,强调的文本是斜体,但是如果在斜体文本中使用,则将文字变为普通文本
\emph{...}

添加图片

LATEX 本身不能管理图像,因此需要使用一个 包 (package)。包可用于更改 LATEX 文档的默认外观,或实现更多功能。在这个例子中,要实现在文档中添加图片,因此需要使用 graphicx 包。graphicx 包提供了新的命令 \includegraphics{...}\graphicspath{...}。要使用 graphicx 软件包,要现在序言中添加:\usepackage{graphicx}

添加图片

\documentclass{article}
\usepackage[utf8]{inputenc}

% 包的引入
\usepackage{graphicx}

% 配置图像所在的文件夹路径
\graphicspath{{images/} }

\title{First document}
\author{Hubert Farnsworth \thanks{funded by the Overleaf team},GuozongHao}
\date{February 2017}

\begin{document}
\maketitle
First document. This is a simple example, with no extra parameters or packages included.
Some of the \textbf{greatest}
% 引入对应的图片
\includegraphics{0.jpg}
discoveries in \underline{science}
were made by \textbf{\textit{accident}}.
% This line here is a comment. It will not be printed in the document.
\end{document}

在这里插入图片描述

图片的lable以及如何引用图片

\begin{figure}[h]
    \centering
    \includegraphics[width=0.25\textwidth]{images/0.jpg}
    % :此命令为图形设置标题。你可以将这条命令放置在图的上方或下方。
    \caption{a nice plot}
    % 如果你需要在文档中引用图像,请使用这条命令为图像设置标签。标签可以为图像编上号,并与下一个命令结合,对图片进行引用。
    \label{fig:grey}
\end{figure}

discoveries in \underline{science}
were made by \textbf{\textit{accident}}.

% 通过这种方式来引用图片的编号
as show the figure \ref{fig:grey}

列表的创建

无序列表

\begin{itemize}
  \item The individual entries are indicated with a black dot, a so-called bullet.
  \item The text in the entries may be of any length.
\end{itemize}

有序列表

\begin{enumerate}
  \item This is the first entry in our list
  \item The list numbers increase with each entry we add
\end{enumerate}

Latex中的数学表达式

LATEX 中有两种模式用于数学表达式: 内联 (inline) 模式和 显示 (display) 模式。第一种模式(内联)编写的公式是文本中的一部分,第二种模式(显示)编写的公式不在段落中,而是放在单独的行上。

内联表达式

要在内联模式下添加数学表达式,可以使用以下定界符之一:\(... \)$ ... $\begin{math} ... \end{math}

In physics, the mass-energy equivalence is stated
by the equation $E=mc^2$, discovered in 1905 by Albert Einstein.

显示表达式

显示模式有两种版本:编号和非编号。

\[... \]`,`\begin{displaymath} ... \end{displaymath}` 或 `\begin{equation} ... \end{equation}
The mass-energy equivalence is described by the famous equation
% 非编号
\[E=mc^2 \]

discovered in 1905 by Albert Einstein.
In natural units (c = 1), the formula expresses the identity
% 编号
\begin{equation}
E=m
\end{equation}

基本格式

研究如何编写摘要以及如何将LATEX文档格式化为不同的章节,分节和段落。

概要

在科学文献中,通常会在概要部分里面简述论文的主要内容。在 LATEX 中有针对概要部分设计的环境。概要环境会将文本以特殊格式放在文档顶部。

\begin{document}

\begin{abstract}
This is a simple paragraph at the beginning of the
document. A brief introduction about the main subject.
\end{abstract}
\end{document}

段落和新行

编写文档内容时,如果需要开始新段落,则必须按两次 “Enter” 键(以插入双空行)。注意,LATEX 会自动缩进段落。 要在开始新段落的情况下开始新行,请插入一个 换行点,可以通过 \\(在示例中为双反斜杠)或 \newline 命令来完成。

注意不要使用多个 \\\newlines 来 “模拟” 段落之间具有较大间距,因为这可能会干扰 LATEX 的排版算法。推荐的方法是继续使用双空行来创建没有任何 \\ 的新段落,然后将 \usepackage{parskip} 添加到序言中。

章节和分段

用来组织文档的命令因文档类型而异,最简单的组织形式是分节,它对所有文档格式均可用。

请注意,\part\chapter 仅在 report 和 book 类中可用。

\section{Introduction}

This is the first section.

Lorem  ipsum  dolor  sit  amet,  consectetuer  adipiscing
elit.   Etiam  lobortisfacilisis sem.  Nullam nec mi et
neque pharetra sollicitudin.  Praesent imperdietmi nec ante.
Donec ullamcorper, felis non sodales...

\section{Second Section}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Etiam lobortis facilisissem.  Nullam nec mi et neque pharetra
sollicitudin.  Praesent imperdiet mi necante...

\subsection{First Subsection}
Praesent imperdietmi nec ante. Donec ullamcorper, felis non sodales...

\section*{Unnumbered Section}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Etiam lobortis facilisissem

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

表格

简单表格

tabular 环境是创建表的默认 LATEX 方法。你必须为此环境指定一个参数,这个例子里是 {c c c}。这告诉 LATEX,表格将有三列,每列中的文本必须居中。你还可以使用 r 将文本向右对齐,使用 l 进行左对齐。符号 & 是分隔符,每行中的分隔符必须始终少于列数。要转到表格的下一行,需要使用换行命令 \\。我们将整个表包装在 center 环境中,以让它出现在页面的中心。

\begin{center}
\begin{tabular}{ c c c }
 cell1 & cell2 & cell3 \\
 cell4 & cell5 & cell6 \\
 cell7 & cell8 & cell9
\end{tabular}
\end{center}

带边框的表格

\begin{center}
\begin{tabular}{ |c|c|c| }
 \hline
 cell1 & cell2 & cell3 \\
 cell4 & cell5 & cell6 \\
 cell7 & cell8 & cell9 \\
 \hline
\end{tabular}
\end{center}

你可以使用水平线命令 \hline 和垂直线参数 | 来添加边框。

  • {|c|c|c|}:这声明表中将会有由垂直线分隔的三列。| 符号指定这些列应由垂直线分隔。
  • \hline:这条命令将插入一条水平线。这个示例中,我们在表格的顶部和底部加入了水平线。\hline 的使用次数没有限制。

在这里插入图片描述

带列名的表格

在 LATEX 中创建表有时会有些棘手,因此你可能需要 TablesGenerator.com 这样的在线工具导出表格的 LATEX 代码。“文件”>“粘贴表数据” 选项从电子表格软件粘贴数据。

\begin{center}
 \begin{tabular}{||c c c c||}
 \hline
 Col1 & Col2 & Col2 & Col3 \\ [0.5ex]
 \hline \hline
 1 & 6 & 87837 & 787 \\
 \hline
 2 & 7 & 78 & 5415 \\
 \hline
 3 & 545 & 778 & 7507 \\
 \hline
 4 & 545 & 18744 & 7560 \\
 \hline
 5 & 88 & 788 & 6344 \\ [1ex]
 \hline
\end{tabular}
\end{center}

在这里插入图片描述

标题,标签和引用

你可以使用与图片几乎相同的方式来为表格添加标题、标签和引用。唯一的区别是,使用 table 环境代替了 figure 环境。

Table \ref{table:data} is an example of referenced \LaTeX{} elements.

\begin{table}[h!]
\centering
\begin{tabular}{||c c c c||}
 \hline
 Col1 & Col2 & Col2 & Col3 \\ [0.5ex]
 \hline\hline
 1 & 6 & 87837 & 787 \\
 2 & 7 & 78 & 5415 \\
 3 & 545 & 778 & 7507 \\
 4 & 545 & 18744 & 7560 \\
 5 & 88 & 788 & 6344 \\ [1ex]
 \hline
\end{tabular}
\caption{Table to test captions and labels}
\label{table:data}
\end{table}

在这里插入图片描述

论文的引用

方法一

在开头添加包

\usepackage{cite}

结尾部分添加要引用的文献

\bibliographystyle{plain}
% 要引用的文献

\cite{Chen2019Machine}
\cite{Kushal2018Machine}

\bibliography{ref}


\end{document}

用法二

  • 26
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值